diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-11-29 10:49:48 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-11-29 10:50:04 +0100 |
commit | 8e4ba7e572122ccc301319b68dc7490a8df9dfd7 (patch) | |
tree | 4f0ea89800ee38e58b190df1370ccf9d266feb63 /plugins/sonar-design-plugin | |
parent | 0e4d8080593ae2e5892206c7df7d328f8676619f (diff) | |
download | sonarqube-8e4ba7e572122ccc301319b68dc7490a8df9dfd7.tar.gz sonarqube-8e4ba7e572122ccc301319b68dc7490a8df9dfd7.zip |
SONAR-4853 Remove support of LCOM4
Diffstat (limited to 'plugins/sonar-design-plugin')
5 files changed, 0 insertions, 279 deletions
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java index 7cb74ef381c..7ebb93528e0 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java @@ -26,11 +26,9 @@ import org.sonar.plugins.design.batch.FileTangleIndexDecorator; import org.sonar.plugins.design.batch.MavenDependenciesSensor; import org.sonar.plugins.design.batch.PackageTangleIndexDecorator; import org.sonar.plugins.design.batch.ProjectDsmDecorator; -import org.sonar.plugins.design.batch.SuspectLcom4DensityDecorator; import org.sonar.plugins.design.ui.libraries.GwtLibrariesPage; import org.sonar.plugins.design.ui.page.GwtDesignPage; import org.sonar.plugins.design.ui.widgets.FileDesignWidget; -import org.sonar.plugins.design.ui.widgets.LCOM4Widget; import org.sonar.plugins.design.ui.widgets.PackageDesignWidget; import org.sonar.plugins.design.ui.widgets.ResponseForClassWidget; @@ -45,14 +43,12 @@ public class DesignPlugin extends SonarPlugin { ProjectDsmDecorator.class, PackageTangleIndexDecorator.class, FileTangleIndexDecorator.class, - SuspectLcom4DensityDecorator.class, GwtLibrariesPage.class, // UI GwtDesignPage.class, FileDesignWidget.class, PackageDesignWidget.class, - LCOM4Widget.class, ResponseForClassWidget.class); } } diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/SuspectLcom4DensityDecorator.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/SuspectLcom4DensityDecorator.java deleted file mode 100644 index b722957d1c2..00000000000 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/SuspectLcom4DensityDecorator.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.design.batch; - -import org.sonar.api.batch.Decorator; -import org.sonar.api.batch.DecoratorContext; -import org.sonar.api.batch.DependedUpon; -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.measures.Measure; -import org.sonar.api.measures.MeasureUtils; -import org.sonar.api.measures.Metric; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.Resource; -import org.sonar.api.resources.ResourceUtils; -import org.sonar.api.resources.Scopes; - -import java.util.Collection; -import java.util.List; - -public class SuspectLcom4DensityDecorator implements Decorator { - - public boolean shouldExecuteOnProject(Project project) { - return true; - } - - @DependedUpon - public final Metric generatesMetric() { - return CoreMetrics.SUSPECT_LCOM4_DENSITY; - } - - public void decorate(Resource resource, DecoratorContext context) { - if (ResourceUtils.isFile(resource)) { - // do nothing - } else if (Scopes.isDirectory(resource)) { - decorateDirectory(context); - - } else if (Scopes.isProject(resource)) { - decorateProject(context); - } - } - - private void decorateProject(DecoratorContext context) { - double total = 0.0; - int totalFiles = 0; - - List<DecoratorContext> children = context.getChildren(); - boolean hasLcom4=false; - for (DecoratorContext child : children) { - int files = MeasureUtils.getValue(child.getMeasure(CoreMetrics.FILES), 0.0).intValue(); - totalFiles += files; - Measure childSuspectDensity = child.getMeasure(CoreMetrics.SUSPECT_LCOM4_DENSITY); - if (childSuspectDensity!=null && childSuspectDensity.getValue()!=null) { - hasLcom4=true; - total += childSuspectDensity.getValue() * files; - } - } - - if (hasLcom4 && totalFiles > 0) { - context.saveMeasure(CoreMetrics.SUSPECT_LCOM4_DENSITY, total / totalFiles); - } - } - - private void decorateDirectory(DecoratorContext context) { - Collection<Measure> fileLcoms = context.getChildrenMeasures(CoreMetrics.LCOM4); - double files = MeasureUtils.getValue(context.getMeasure(CoreMetrics.FILES), 0.0); - if (!fileLcoms.isEmpty() && files>0.0) { - double suspectFiles = 0.0; - - // directory children are files - for (Measure fileLcom : fileLcoms) { - if (MeasureUtils.getValue(fileLcom, 0.0) > 1.0) { - suspectFiles++; - } - } - double density = (suspectFiles / files) * 100.0; - context.saveMeasure(CoreMetrics.SUSPECT_LCOM4_DENSITY, density); - } - } -} diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/LCOM4Widget.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/LCOM4Widget.java deleted file mode 100644 index 11b203a9e39..00000000000 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/LCOM4Widget.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.design.ui.widgets; - -import org.sonar.api.web.AbstractRubyTemplate; -import org.sonar.api.web.RubyRailsWidget; -import org.sonar.api.web.UserRole; -import org.sonar.api.web.WidgetCategory; - -@UserRole(UserRole.USER) -@WidgetCategory({"Design"}) -public final class LCOM4Widget extends AbstractRubyTemplate implements RubyRailsWidget { - - public String getId() { - return "lcom4"; - } - - public String getTitle() { - return "LCOM4"; - } - - @Override - protected String getTemplatePath() { - return "/org/sonar/plugins/design/ui/widgets/lcom4.html.erb"; - } -} diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/lcom4.html.erb b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/lcom4.html.erb deleted file mode 100644 index a827d0a62de..00000000000 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/lcom4.html.erb +++ /dev/null @@ -1,36 +0,0 @@ -<% - lcom=measure('lcom4') - if lcom - lcom_distribution=measure('lcom4_distribution') - suspect_lcom4_density=measure('suspect_lcom4_density') - - display_chart = suspect_lcom4_density && suspect_lcom4_density.value>1.0 && lcom_distribution && !lcom_distribution.data.blank? -%> -<table width="100%"> - <tbody> - <tr> - <td valign="top" width="<%= display_chart ? '50' : '100' -%>%"> - <div class="dashbox"> - <h3><%= message('widget.lcom4.title') -%></h3> - <p> - <span class="big"><%= format_measure(lcom, :suffix => '', :default => '-', :url => url_for_drilldown('lcom4')) -%></span><%= message('widget.lcom4.per_class.suffix') -%> <%= dashboard_configuration.selected_period? ? format_variation(lcom) : trend_icon(lcom, :big => true) -%> - </p> - <p> - <%= format_measure(suspect_lcom4_density, :suffix => message('widget.lcom4.files_having_lcom_greater_than_one'), :url => url_for_drilldown('lcom4')) %> <%= dashboard_configuration.selected_period? ? format_variation(suspect_lcom4_density) : trend_icon(suspect_lcom4_density) -%> - </p> - </div> - </td> - - <% - if display_chart - query="ck=distbar&c=777777&w=180&h=100&fs=8&bgc=ffffff&v=" + u(lcom_distribution.data) - %> - <td valign="top" width="50px"> - <a href="<%= url_for_drilldown('lcom4') -%>"><%= chart(query, :id => 'lcom4_distribution', :alt => '') -%></a> - </td> - <% end %> - - </tr> - </tbody> -</table> -<% end %> diff --git a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/SuspectLcom4DensityDecoratorTest.java b/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/SuspectLcom4DensityDecoratorTest.java deleted file mode 100644 index 9c85627b301..00000000000 --- a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/SuspectLcom4DensityDecoratorTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.plugins.design.batch; - -import org.junit.Test; -import org.sonar.api.batch.DecoratorContext; -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.measures.Measure; -import org.sonar.api.resources.JavaFile; -import org.sonar.api.resources.JavaPackage; -import org.sonar.api.resources.Project; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static org.mockito.Mockito.*; - -public class SuspectLcom4DensityDecoratorTest { - - @Test - public void shouldNotDecorateFiles() { - DecoratorContext context = mock(DecoratorContext.class); - when(context.getMeasure(CoreMetrics.FILES)).thenReturn(new Measure(CoreMetrics.FILES, 1.0)); - when(context.getMeasure(CoreMetrics.LCOM4)).thenReturn(newLcom4(3)); - - SuspectLcom4DensityDecorator decorator = new SuspectLcom4DensityDecorator(); - decorator.decorate(new JavaFile("org.foo.Bar"), context); - - verify(context, never()).saveMeasure(eq(CoreMetrics.SUSPECT_LCOM4_DENSITY), anyDouble()); - } - - @Test - public void shouldComputeDensityOnPackages() { - DecoratorContext context = mock(DecoratorContext.class); - when(context.getMeasure(CoreMetrics.FILES)).thenReturn(new Measure(CoreMetrics.FILES, 4.0)); - when(context.getChildrenMeasures(CoreMetrics.LCOM4)).thenReturn(Arrays.asList(newLcom4(1), newLcom4(3), newLcom4(5), newLcom4(1))); - - SuspectLcom4DensityDecorator decorator = new SuspectLcom4DensityDecorator(); - decorator.decorate(new JavaPackage("org.foo"), context); - - verify(context).saveMeasure(CoreMetrics.SUSPECT_LCOM4_DENSITY, 50.0); - } - - @Test - public void shouldConsolidateDensityOnProjects() { - List<DecoratorContext> children = Arrays.asList( - newContext(3, 20.0), - newContext(0, 0.0), - newContext(5, 50.0)); - - DecoratorContext context = mock(DecoratorContext.class); - when(context.getChildren()).thenReturn(children); - - SuspectLcom4DensityDecorator decorator = new SuspectLcom4DensityDecorator(); - decorator.decorate(new Project("Foo"), context); - - verify(context).saveMeasure(CoreMetrics.SUSPECT_LCOM4_DENSITY, (20.0*3 + 50.0*5) / (3.0+5.0)); - } - - @Test - public void doNotComputeDensityWhenLcom4IsMissing() { - DecoratorContext context = mock(DecoratorContext.class); - when(context.getMeasure(CoreMetrics.FILES)).thenReturn(new Measure(CoreMetrics.FILES, 4.0)); - when(context.getChildrenMeasures(CoreMetrics.LCOM4)).thenReturn(Collections.<Measure>emptyList()); - - SuspectLcom4DensityDecorator decorator = new SuspectLcom4DensityDecorator(); - decorator.decorate(new JavaPackage("org.foo"), context); - - verify(context, never()).saveMeasure(eq(CoreMetrics.SUSPECT_LCOM4_DENSITY), anyDouble()); - } - - private Measure newLcom4(int lcom4) { - return new Measure(CoreMetrics.LCOM4, (double) lcom4); - } - - private DecoratorContext newContext(int files, double density) { - DecoratorContext context = mock(DecoratorContext.class); - when(context.getMeasure(CoreMetrics.FILES)).thenReturn(new Measure(CoreMetrics.FILES, (double) files)); - when(context.getMeasure(CoreMetrics.SUSPECT_LCOM4_DENSITY)).thenReturn(new Measure(CoreMetrics.SUSPECT_LCOM4_DENSITY, density)); - return context; - } -} |