From: Simon Brandhof Date: Fri, 25 May 2012 16:03:29 +0000 (+0200) Subject: Fix some quality flaws X-Git-Tag: 3.1~52 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2a34a135a65c416f8703944b5713356802f9ab54;p=sonarqube.git Fix some quality flaws --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java index df2fc4d9768..128152622f2 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/MyFavouritesFilter.java @@ -19,8 +19,8 @@ */ package org.sonar.plugins.core.filters; +import org.sonar.api.measures.CoreMetrics; import org.sonar.api.web.Criterion; - import org.sonar.api.web.Filter; import org.sonar.api.web.FilterColumn; import org.sonar.api.web.FilterTemplate; @@ -42,12 +42,11 @@ public class MyFavouritesFilter extends FilterTemplate { filter.setDisplayAs(Filter.LIST); filter.setFavouritesOnly(true); filter.add(Criterion.createForQualifier("VW", "SVW", "TRK", "BRC", "DIR", "PAC", "FIL", "CLA", "UTS", "LIB")); - filter.add(FilterColumn.create("metric", "alert_status", FilterColumn.DESC, false)); + filter.add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false)); filter.add(FilterColumn.create("name", null, FilterColumn.ASC, false)); - filter.add(FilterColumn.create("metric", "ncloc", FilterColumn.DESC, false)); - filter.add(FilterColumn.create("metric", "violations_density", FilterColumn.DESC, false)); + filter.add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false)); + filter.add(FilterColumn.create("metric", CoreMetrics.VIOLATIONS_DENSITY_KEY, FilterColumn.DESC, false)); filter.add(FilterColumn.create("date", null, FilterColumn.DESC, false)); - return filter; } } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/ProjectFilter.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/ProjectFilter.java index 189d85d0ec2..c9e635881d9 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/ProjectFilter.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/ProjectFilter.java @@ -19,6 +19,8 @@ */ package org.sonar.plugins.core.filters; +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.resources.Qualifiers; import org.sonar.api.web.Criterion; import org.sonar.api.web.Filter; import org.sonar.api.web.FilterColumn; @@ -39,12 +41,12 @@ public class ProjectFilter extends FilterTemplate { public Filter createFilter() { Filter filter = Filter.create(); filter.setDisplayAs(Filter.LIST); - filter.add(Criterion.createForQualifier("TRK")); - filter.add(FilterColumn.create("metric", "alert_status", FilterColumn.DESC, false)); + filter.add(Criterion.createForQualifier(Qualifiers.PROJECT)); + filter.add(FilterColumn.create("metric", CoreMetrics.ALERT_STATUS_KEY, FilterColumn.DESC, false)); filter.add(FilterColumn.create("name", null, FilterColumn.ASC, false)); filter.add(FilterColumn.create("version", null, FilterColumn.DESC, false)); - filter.add(FilterColumn.create("metric", "ncloc", FilterColumn.DESC, false)); - filter.add(FilterColumn.create("metric", "violations_density", FilterColumn.DESC, false)); + filter.add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false)); + filter.add(FilterColumn.create("metric", CoreMetrics.VIOLATIONS_DENSITY_KEY, FilterColumn.DESC, false)); filter.add(FilterColumn.create("date", null, FilterColumn.DESC, false)); filter.add(FilterColumn.create("links", null, FilterColumn.DESC, false)); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/TreeMapFilter.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/TreeMapFilter.java index 0d5cb7a863f..985bb434b65 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/TreeMapFilter.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/filters/TreeMapFilter.java @@ -19,8 +19,9 @@ */ package org.sonar.plugins.core.filters; +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.resources.Qualifiers; import org.sonar.api.web.Criterion; - import org.sonar.api.web.Filter; import org.sonar.api.web.FilterColumn; import org.sonar.api.web.FilterTemplate; @@ -40,11 +41,11 @@ public class TreeMapFilter extends FilterTemplate { public Filter createFilter() { Filter filter = Filter.create(); filter.setDisplayAs(Filter.TREEMAP); - filter.add(Criterion.createForQualifier("TRK")); + filter.add(Criterion.createForQualifier(Qualifiers.PROJECT)); filter.add(FilterColumn.create("name", null, FilterColumn.ASC, false)); - filter.add(FilterColumn.create("metric", "ncloc", FilterColumn.DESC, false)); - filter.add(FilterColumn.create("metric", "violations_density", FilterColumn.DESC, false)); - + filter.add(FilterColumn.create("metric", CoreMetrics.NCLOC_KEY, FilterColumn.DESC, false)); + filter.add(FilterColumn.create("metric", CoreMetrics.VIOLATIONS_DENSITY_KEY, FilterColumn.DESC, false)); + return filter; } } diff --git a/sonar-server/src/main/java/org/sonar/server/filters/Filter.java b/sonar-server/src/main/java/org/sonar/server/filters/Filter.java index 12ed8983d86..351477d93ed 100644 --- a/sonar-server/src/main/java/org/sonar/server/filters/Filter.java +++ b/sonar-server/src/main/java/org/sonar/server/filters/Filter.java @@ -46,7 +46,6 @@ public class Filter { private String keyRegexp; private String nameRegexp; private boolean onDirectChildren = false; - private boolean isViewContext = false; // filters on measures private List measureCriteria = Lists.newLinkedList(); @@ -63,7 +62,7 @@ public class Filter { private boolean isNumericMetric = true; private boolean ascendingSort = true; - public Filter setPath(Integer rootSnapshotId, Integer snapshotId, String snapshotPath, boolean isViewContext) { + public Filter setPath(Integer rootSnapshotId, Integer snapshotId, String snapshotPath) { this.baseSnapshotId = snapshotId; if (rootSnapshotId == null) { this.rootSnapshotId = snapshotId; @@ -71,7 +70,6 @@ public class Filter { this.rootSnapshotId = rootSnapshotId; } this.baseSnapshotPath = StringUtils.defaultString(snapshotPath, ""); //With Oracle the path can be null (see SONAR-2582) - this.isViewContext = isViewContext; return this; } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/filters.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/filters.rb index 1a4583cefd9..55551c9c884 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/filters.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/filters.rb @@ -27,9 +27,9 @@ class Filters if filter.resource_id snapshot=Snapshot.find(:first, :conditions => {:project_id => filter.resource_id, :islast => true}) if snapshot - java_filter.setPath(snapshot.root_snapshot_id, snapshot.id, snapshot.path, (snapshot.view? || snapshot.subview?)) + java_filter.setPath(snapshot.root_snapshot_id, snapshot.id, snapshot.path) else - java_filter.setPath(-1, -1, '', false) + java_filter.setPath(-1, -1, '') end end diff --git a/sonar-server/src/test/java/org/sonar/server/filters/FilterExecutorTest.java b/sonar-server/src/test/java/org/sonar/server/filters/FilterExecutorTest.java index 20b6ed429ae..22c8d9ade94 100644 --- a/sonar-server/src/test/java/org/sonar/server/filters/FilterExecutorTest.java +++ b/sonar-server/src/test/java/org/sonar/server/filters/FilterExecutorTest.java @@ -90,7 +90,7 @@ public class FilterExecutorTest extends AbstractDbUnitTestCase { public void filterOnBaseSnapshot() { setupData("shared"); FilterExecutor executor = new FilterExecutor(getSession(), new Derby()); - FilterResult result = executor.execute(Filter.createForAllQualifiers().setPath(2, 2, "", false)); + FilterResult result = executor.execute(Filter.createForAllQualifiers().setPath(2, 2, "")); assertSnapshotIds(result, 4); } @@ -321,7 +321,7 @@ public class FilterExecutorTest extends AbstractDbUnitTestCase { setupData("views"); FilterExecutor executor = new FilterExecutor(getSession(), new Derby()); Filter filter = new Filter() - .setPath(2, 2, "", true) + .setPath(2, 2, "") .setQualifiers(Sets.newHashSet(Qualifiers.SUBVIEW, Qualifiers.PROJECT)); FilterResult result = executor.execute(filter);