diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-12-12 11:51:24 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-12-12 11:51:24 +0100 |
commit | dceec13d5c22aaa67f9f19d6196b3ae4330b23ff (patch) | |
tree | 6acec7e8f0d4013c1e7afb1455617f901a56bf82 | |
parent | 5c1cabf8355199f03924bbabf34f98b315a01f51 (diff) | |
download | sonarqube-dceec13d5c22aaa67f9f19d6196b3ae4330b23ff.tar.gz sonarqube-dceec13d5c22aaa67f9f19d6196b3ae4330b23ff.zip |
Fix some violations
13 files changed, 51 insertions, 45 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java index e7c897d9fb3..bde5e90cc58 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java @@ -90,7 +90,10 @@ public class CloseReviewsDecorator implements Decorator { protected int closeReviewsOnResolvedViolations(Resource resource, int resourceId, int snapshotId) { String conditions = " WHERE resource_id=" + resourceId + " AND " + "( " - + " (manual_violation=:automaticViolation AND status!='CLOSED' AND rule_failure_permanent_id NOT IN " + "(SELECT permanent_id FROM rule_failures WHERE snapshot_id=" + snapshotId + " AND permanent_id IS NOT NULL))" + + " ( " + + " manual_violation=:automaticViolation AND status!='CLOSED' AND " + + " rule_failure_permanent_id NOT IN (SELECT permanent_id FROM rule_failures WHERE snapshot_id=" + snapshotId + " AND permanent_id IS NOT NULL)" + + " )" + " OR " + " (manual_violation=:manualViolation AND status='RESOLVED')" + ")"; diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasures.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasures.java index 790a4f96a37..168d97fea21 100644 --- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasures.java +++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/PurgeRuleMeasures.java @@ -47,8 +47,9 @@ public final class PurgeRuleMeasures extends Purge { } private void purge(Integer sid) { - Query query = getSession().createQuery("SELECT m.id FROM " + MeasureModel.class.getSimpleName() + " m, " + Snapshot.class.getSimpleName() + " s WHERE s.id = m.snapshotId and " + - "(s.rootId=:rootSid OR s.id=:rootSid) and m.ruleId is not null"); + Query query = getSession().createQuery( + "SELECT m.id FROM " + MeasureModel.class.getSimpleName() + " m, " + Snapshot.class.getSimpleName() + " s " + + " WHERE s.id = m.snapshotId AND (s.rootId=:rootSid OR s.id=:rootSid) and m.ruleId is not null"); query.setParameter("rootSid", sid); List<Integer> measureIds = query.getResultList(); PurgeUtils.deleteMeasuresById(getSession(), measureIds); diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java index 198340252c4..be23b8433f9 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java @@ -54,7 +54,8 @@ public class MavenDependenciesSensor implements Sensor { private DependencyTreeBuilder treeBuilder; private SonarIndex index; - public MavenDependenciesSensor(ArtifactRepository localRepository, ArtifactFactory artifactFactory, ArtifactMetadataSource artifactMetadataSource, ArtifactCollector artifactCollector, DependencyTreeBuilder treeBuilder, SonarIndex index) { + public MavenDependenciesSensor(ArtifactRepository localRepository, ArtifactFactory artifactFactory, ArtifactMetadataSource artifactMetadataSource, + ArtifactCollector artifactCollector, DependencyTreeBuilder treeBuilder, SonarIndex index) { this.localRepository = localRepository; this.artifactFactory = artifactFactory; this.artifactMetadataSource = artifactMetadataSource; diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/GwtDesignPage.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/GwtDesignPage.java index 22dd200c31a..360fb5174f8 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/GwtDesignPage.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/GwtDesignPage.java @@ -21,13 +21,16 @@ package org.sonar.plugins.design.ui.page; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.resources.Java; -import org.sonar.api.resources.Resource; +import org.sonar.api.resources.Qualifiers; import org.sonar.api.web.*; import org.sonar.plugins.design.ui.page.client.DesignPage; @ResourceLanguage(Java.KEY) -@ResourceQualifier({Resource.QUALIFIER_PROJECT, Resource.QUALIFIER_MODULE, Resource.QUALIFIER_PACKAGE, Resource.QUALIFIER_DIRECTORY}) -@DefaultTab(metrics={CoreMetrics.DEPENDENCY_MATRIX_KEY, CoreMetrics.PACKAGE_FEEDBACK_EDGES_KEY, CoreMetrics.PACKAGE_CYCLES_KEY, CoreMetrics.PACKAGE_TANGLE_INDEX_KEY, CoreMetrics.PACKAGE_TANGLES_KEY, CoreMetrics.FILE_CYCLES_KEY, CoreMetrics.FILE_TANGLE_INDEX_KEY, CoreMetrics.FILE_TANGLES_KEY, CoreMetrics.FILE_FEEDBACK_EDGES_KEY}) +@ResourceQualifier({Qualifiers.PROJECT, Qualifiers.MODULE, Qualifiers.PACKAGE, Qualifiers.DIRECTORY}) +@DefaultTab(metrics = { + CoreMetrics.DEPENDENCY_MATRIX_KEY, CoreMetrics.PACKAGE_FEEDBACK_EDGES_KEY, CoreMetrics.PACKAGE_CYCLES_KEY, CoreMetrics.PACKAGE_TANGLE_INDEX_KEY, + CoreMetrics.PACKAGE_TANGLES_KEY, CoreMetrics.FILE_CYCLES_KEY, CoreMetrics.FILE_TANGLE_INDEX_KEY, CoreMetrics.FILE_TANGLES_KEY, + CoreMetrics.FILE_FEEDBACK_EDGES_KEY}) @NavigationSection({NavigationSection.RESOURCE, NavigationSection.RESOURCE_TAB}) @UserRole(UserRole.USER) public class GwtDesignPage extends GwtPage { diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/DependencyInfo.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/DependencyInfo.java index 412322fb779..6b68914f04e 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/DependencyInfo.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/DependencyInfo.java @@ -58,7 +58,8 @@ public final class DependencyInfo extends Composite { public void showOrPopup(String dependencyId) { if (popupMode) { - Window.open(Links.urlForResourcePage(Configuration.getResourceId(), DesignPage.GWT_ID, "layout=false&depId=" + dependencyId), "dependency", Links.DEFAULT_POPUP_HTML_FEATURES); + Window.open(Links.urlForResourcePage(Configuration.getResourceId(), DesignPage.GWT_ID, "layout=false&depId=" + dependencyId), + "dependency", Links.DEFAULT_POPUP_HTML_FEATURES); } else { INSTANCE.show(dependencyId); @@ -68,7 +69,7 @@ public final class DependencyInfo extends Composite { public void show(String dependencyId) { panel.clear(); currentDependencyId = dependencyId; - if (dependencyId !=null) { + if (dependencyId != null) { panel.add(loading); loadDependency(dependencyId); } diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java index 37d65067e3e..4f096542882 100644 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java +++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoAntInitializer.java @@ -25,7 +25,6 @@ import org.sonar.api.batch.Initializer; import org.sonar.api.batch.SupportedEnvironment; import org.sonar.api.resources.Project; -import java.util.Hashtable; import java.util.Map; @SupportedEnvironment("ant") diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java index 3b835911d41..b0f3f1cf9e3 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java +++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java @@ -58,7 +58,7 @@ public class PastMeasuresLoader implements BatchExtension { } public List<Object[]> getPastMeasures(Resource resource, PastSnapshot projectPastSnapshot) { - if (projectPastSnapshot != null && projectPastSnapshot.getProjectSnapshot()!=null) { + if (projectPastSnapshot != null && projectPastSnapshot.getProjectSnapshot() != null) { return getPastMeasures(resource.getEffectiveKey(), projectPastSnapshot.getProjectSnapshot()); } return Collections.emptyList(); @@ -66,32 +66,33 @@ public class PastMeasuresLoader implements BatchExtension { public List<Object[]> getPastMeasures(String resourceKey, Snapshot projectPastSnapshot) { String sql = "select m.metric_id, m.characteristic_id, m.rule_id, m.value from project_measures m, snapshots s" + - " where m.snapshot_id=s.id and m.metric_id in (:metricIds) " + - " and (s.root_snapshot_id=:rootSnapshotId or s.id=:rootSnapshotId) and s.status=:status and s.project_id=(select p.id from projects p where p.kee=:resourceKey and p.qualifier<>:lib)"; + " where m.snapshot_id=s.id and m.metric_id in (:metricIds) " + + " and (s.root_snapshot_id=:rootSnapshotId or s.id=:rootSnapshotId) " + + " and s.status=:status and s.project_id=(select p.id from projects p where p.kee=:resourceKey and p.qualifier<>:lib)"; return session.createNativeQuery(sql) - .setParameter("metricIds", metricByIds.keySet()) - .setParameter("rootSnapshotId", ObjectUtils.defaultIfNull(projectPastSnapshot.getRootId(), projectPastSnapshot.getId())) - .setParameter("resourceKey", resourceKey) - .setParameter("lib", Qualifiers.LIBRARY) - .setParameter("status", Snapshot.STATUS_PROCESSED) - .getResultList(); + .setParameter("metricIds", metricByIds.keySet()) + .setParameter("rootSnapshotId", ObjectUtils.defaultIfNull(projectPastSnapshot.getRootId(), projectPastSnapshot.getId())) + .setParameter("resourceKey", resourceKey) + .setParameter("lib", Qualifiers.LIBRARY) + .setParameter("status", Snapshot.STATUS_PROCESSED) + .getResultList(); } public static int getMetricId(Object[] row) { // can be BigDecimal on Oracle - return ((Number)row[0]).intValue(); + return ((Number) row[0]).intValue(); } public static Integer getCharacteristicId(Object[] row) { // can be BigDecimal on Oracle Number number = (Number) row[1]; - return number!=null ? number.intValue() : null; + return number != null ? number.intValue() : null; } public static Integer getRuleId(Object[] row) { // can be BigDecimal on Oracle Number number = (Number) row[2]; - return number!=null ? number.intValue() : null; + return number != null ? number.intValue() : null; } public static boolean hasValue(Object[] row) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java b/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java index 9ff30611eb9..7a7fb5a1886 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java +++ b/sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java @@ -29,7 +29,6 @@ import org.sonar.api.resources.Project; import org.sonar.core.config.ConfigurationUtils; import org.sonar.jpa.session.DatabaseSessionFactory; -import java.util.Iterator; import java.util.List; /** diff --git a/sonar-core/src/main/java/org/sonar/jpa/dialect/OracleSequenceGenerator.java b/sonar-core/src/main/java/org/sonar/jpa/dialect/OracleSequenceGenerator.java index b62af9d9b45..5450f27e6f4 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dialect/OracleSequenceGenerator.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dialect/OracleSequenceGenerator.java @@ -19,6 +19,7 @@ */ package org.sonar.jpa.dialect; +import org.apache.commons.lang.StringUtils; import org.hibernate.MappingException; import org.hibernate.dialect.Dialect; import org.hibernate.id.PersistentIdentifierGenerator; @@ -36,7 +37,7 @@ public class OracleSequenceGenerator extends SequenceGenerator { @Override public void configure(Type type, Properties params, Dialect dialect) - throws MappingException { + throws MappingException { String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE); @@ -46,7 +47,7 @@ public class OracleSequenceGenerator extends SequenceGenerator { sequenceNameBuilder.append(tableName); sequenceNameBuilder.append(SEQUENCE_NAME_SUFFIX); - params.setProperty(SEQUENCE, sequenceNameBuilder.toString().toUpperCase()); + params.setProperty(SEQUENCE, StringUtils.upperCase(sequenceNameBuilder.toString())); } super.configure(type, params, dialect); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Iso9126RulesCategories.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Iso9126RulesCategories.java index 70501b4afdd..7937fd9dab8 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Iso9126RulesCategories.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Iso9126RulesCategories.java @@ -32,15 +32,15 @@ public final class Iso9126RulesCategories { } public static final RulesCategory RELIABILITY = new RulesCategory("Reliability", - "The extent to which the project can be expected to perform its intended function with rescission. Some examples : are loop indexes range tested? Is input data checked for range errors ? Is divide-by-zero avoided ? Is exception handling provided ?"); + "The extent to which the project can be expected to perform its intended function with rescission. Some examples : are loop indexes range tested? Is input data checked for range errors ? Is divide-by-zero avoided ? Is exception handling provided ?"); public static final RulesCategory EFFICIENCY = new RulesCategory("Efficiency", - "The extent to which the project fulfills its purpose without waste of resources. This means resources in the sense of memory utilisation and processor speed."); + "The extent to which the project fulfills its purpose without waste of resources. This means resources in the sense of memory utilisation and processor speed."); public static final RulesCategory PORTABILITY = new RulesCategory("Portability", - "The extent to which the project can be operated easily and well on multiple computer configurations. Portability can mean both between different hardware setups and between different operating systems -- such as running on both Mac OS X and GNU/Linux."); + "The extent to which the project can be operated easily and well on multiple computer configurations. Portability can mean both between different hardware setups and between different operating systems -- such as running on both Mac OS X and GNU/Linux."); public static final RulesCategory USABILITY = new RulesCategory("Usability", - "The extent to which the project can be understood, learned, operated, attractive and compliant with usability regulations and guidelines. It commonly relies on naming conventions and formatting rules."); + "The extent to which the project can be understood, learned, operated, attractive and compliant with usability regulations and guidelines. It commonly relies on naming conventions and formatting rules."); public static final RulesCategory MAINTAINABILITY = new RulesCategory("Maintainability", - "The extent to which the project facilitates updating to satisfy new requirements. Thus the the project which is maintainable should be not complex."); + "The extent to which the project facilitates updating to satisfy new requirements. Thus the the project which is maintainable should be not complex."); public static final List<RulesCategory> ALL = Collections.unmodifiableList(Arrays.asList(RELIABILITY, EFFICIENCY, PORTABILITY, USABILITY, MAINTAINABILITY)); } diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java index 2621a63d1d9..955ceeca8bb 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java @@ -68,9 +68,8 @@ public class RulesBackup implements Backupable { } private List<Rule> getUserRules() { - List<Rule> rules = rulesDao.getRules(); List<Rule> userRules = Lists.newArrayList(); - for (Rule rule : rules) { + for (Rule rule : rulesDao.getRules()) { if (rule.getParent() != null) { userRules.add(rule); } diff --git a/sonar-server/src/main/java/org/sonar/server/platform/SonarHome.java b/sonar-server/src/main/java/org/sonar/server/platform/SonarHome.java index d8bda078883..d1bbc367527 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/SonarHome.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/SonarHome.java @@ -55,22 +55,22 @@ final class SonarHome { } static File locate() { - String home = System.getProperty(PROPERTY); - if (StringUtils.isBlank(home)) { - home = System.getenv(PROPERTY); - if (StringUtils.isBlank(home)) { - home = openWarProperties().getProperty(PROPERTY); + String value = System.getProperty(PROPERTY); + if (StringUtils.isBlank(value)) { + value = System.getenv(PROPERTY); + if (StringUtils.isBlank(value)) { + value = openWarProperties().getProperty(PROPERTY); } } - if (StringUtils.isBlank(home)) { - throw new IllegalStateException("Sonar home is not defined. " + + if (StringUtils.isBlank(value)) { + throw new IllegalStateException("Sonar value is not defined. " + "Please set the environment variable/system property " + PROPERTY + " or edit the file WEB-INF/classes/sonar-war.properties"); } - File dir = new File(home); + File dir = new File(value); if (!dir.isDirectory() || !dir.exists()) { - throw new IllegalStateException(PROPERTY + " is not valid: " + home + ". Please fix the environment variable/system property SONAR_HOME or " + + throw new IllegalStateException(PROPERTY + " is not valid: " + value + ". Please fix the environment variable/system property SONAR_HOME or " + "the file WEB-INF/classes/sonar-war.properties"); } return dir; diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index d1e062a7fa6..0514b55e8b7 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -34,12 +34,9 @@ import org.sonar.api.rules.RuleRepository; import org.sonar.api.utils.ValidationMessages; import org.sonar.api.web.*; import org.sonar.core.i18n.RuleI18nManager; -import org.sonar.jpa.dialect.Dialect; -import org.sonar.jpa.session.DatabaseConnector; import org.sonar.markdown.Markdown; import org.sonar.persistence.Database; import org.sonar.persistence.DatabaseMigrator; -import org.sonar.server.platform.ServerSettings; import org.sonar.server.configuration.Backup; import org.sonar.server.configuration.ProfilesManager; import org.sonar.server.filters.Filter; @@ -48,6 +45,7 @@ import org.sonar.server.filters.FilterResult; import org.sonar.server.notifications.reviews.ReviewsNotificationManager; import org.sonar.server.platform.Platform; import org.sonar.server.platform.ServerIdGenerator; +import org.sonar.server.platform.ServerSettings; import org.sonar.server.plugins.*; import org.sonar.server.rules.ProfilesConsole; import org.sonar.server.rules.RulesConsole; @@ -250,7 +248,7 @@ public final class JRubyFacade { public void ruleSeverityChanged(int parentProfileId, int activeRuleId, int oldSeverityId, int newSeverityId, String userName) { getProfilesManager().ruleSeverityChanged(parentProfileId, activeRuleId, RulePriority.values()[oldSeverityId], - RulePriority.values()[newSeverityId], userName); + RulePriority.values()[newSeverityId], userName); } public void ruleDeactivated(int parentProfileId, int deactivatedRuleId, String userName) { |