From bab46aebf920654af1adb2b9aabf7f9b86988660 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Tue, 1 Feb 2011 14:17:45 +0100 Subject: [PATCH] Move calculation of accessors from squid to sonar --- .../squid/bridges/CopyBasicMeasuresBridge.java | 1 - .../plugins/squid/decorators/FunctionsDecorator.java | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/bridges/CopyBasicMeasuresBridge.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/bridges/CopyBasicMeasuresBridge.java index a783141cc75..14cd8876c55 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/bridges/CopyBasicMeasuresBridge.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/bridges/CopyBasicMeasuresBridge.java @@ -57,7 +57,6 @@ public final class CopyBasicMeasuresBridge extends Bridge { copy(squidCode, sonarResource, Metric.LINES_OF_CODE, CoreMetrics.NCLOC); copy(squidCode, sonarResource, Metric.LINES, CoreMetrics.LINES); copy(squidCode, sonarResource, Metric.COMMENT_LINES_WITHOUT_HEADER, CoreMetrics.COMMENT_LINES); - copy(squidCode, sonarResource, Metric.ACCESSORS, CoreMetrics.ACCESSORS); copy(squidCode, sonarResource, Metric.PUBLIC_API, CoreMetrics.PUBLIC_API); copy(squidCode, sonarResource, Metric.COMPLEXITY, CoreMetrics.COMPLEXITY); copy(squidCode, sonarResource, Metric.STATEMENTS, CoreMetrics.STATEMENTS); diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/FunctionsDecorator.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/FunctionsDecorator.java index 3bd9e65f2e3..e8ec5e24d2b 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/FunctionsDecorator.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/FunctionsDecorator.java @@ -33,13 +33,18 @@ public final class FunctionsDecorator implements Decorator { public void decorate(Resource resource, DecoratorContext context) { if (Scopes.isType(resource)) { - int methods=0; + int methods=0, accessors=0; for (DecoratorContext child : context.getChildren()) { - if (child.getResource() instanceof JavaMethod && !((JavaMethod)child.getResource()).isAccessor()) { - methods++; + if (child.getResource() instanceof JavaMethod) { + if (((JavaMethod)child.getResource()).isAccessor()) { + accessors++; + } else { + methods++; + } } } context.saveMeasure(new Measure(CoreMetrics.FUNCTIONS, (double)methods)); + context.saveMeasure(new Measure(CoreMetrics.ACCESSORS, (double)accessors)); } } -- 2.39.5