aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-application/src/main/java/org/sonar/application/StartServer.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/DryRunDatabase.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/LocalizedMessages.java56
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java13
6 files changed, 42 insertions, 45 deletions
diff --git a/sonar-application/src/main/java/org/sonar/application/StartServer.java b/sonar-application/src/main/java/org/sonar/application/StartServer.java
index 1614befcbdc..3e4b563c4e8 100644
--- a/sonar-application/src/main/java/org/sonar/application/StartServer.java
+++ b/sonar-application/src/main/java/org/sonar/application/StartServer.java
@@ -30,6 +30,7 @@ public final class StartServer {
private static final String DEFAULT_WEB_HOST = "0.0.0.0";
private static final int DEFAULT_WEB_PORT = 9000;
private static final String DEFAULT_WEB_CONTEXT = "/";
+ private static final String PROPERTIES_FILE_PATH = "/conf/sonar.properties";
private StartServer() {
}
@@ -64,12 +65,12 @@ public final class StartServer {
private static Properties getConfiguration() throws IOException {
Properties properties = new Properties();
- properties.load(StartServer.class.getResourceAsStream("/conf/sonar.properties"));
+ properties.load(StartServer.class.getResourceAsStream(PROPERTIES_FILE_PATH));
return properties;
}
private static void configureHome() throws URISyntaxException {
- File confFile = new File(StartServer.class.getResource("/conf/sonar.properties").toURI());
+ File confFile = new File(StartServer.class.getResource(PROPERTIES_FILE_PATH).toURI());
System.setProperty("SONAR_HOME" /* see constant org.sonar.server.platform.SonarHome.PROPERTY */,
confFile.getParentFile().getParentFile().getAbsolutePath());
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java
index 9613b62d94a..ada9ecacf7f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java
@@ -40,6 +40,7 @@ import org.sonar.api.violations.ViolationQuery;
public class DefaultDecoratorContext implements DecoratorContext {
+ private static final String SAVE_MEASURE_METHOD = "saveMeasure";
private SonarIndex index;
private Resource resource;
private boolean readOnly = false;
@@ -107,13 +108,13 @@ public class DefaultDecoratorContext implements DecoratorContext {
}
public DecoratorContext saveMeasure(Measure measure) {
- checkReadOnly("saveMeasure");
+ checkReadOnly(SAVE_MEASURE_METHOD);
index.addMeasure(resource, measure);
return this;
}
public DecoratorContext saveMeasure(Metric metric, Double value) {
- checkReadOnly("saveMeasure");
+ checkReadOnly(SAVE_MEASURE_METHOD);
index.addMeasure(resource, new Measure(metric, value));
return this;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DryRunDatabase.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DryRunDatabase.java
index 4eca672f807..e8076a73bb9 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DryRunDatabase.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DryRunDatabase.java
@@ -44,7 +44,7 @@ public class DryRunDatabase implements BatchComponent {
private static final String DRIVER = "org.h2.Driver";
private static final String URL = "jdbc:h2:";
private static final String USER = "sonar";
- private static final String PASSWORD = "sonar";
+ private static final String PASSWORD = USER;
private static final int DEFAULT_DRY_RUN_READ_TIMEOUT_SEC = 60;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java
index 35c888403b5..2806ef43f23 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java
@@ -136,10 +136,8 @@ public final class MeasuresFilters {
return new MetricFilter<Collection<RuleMeasure>>(metric) {
private boolean apply(Measure measure) {
- return measure instanceof RuleMeasure
- && metric.equals(measure.getMetric())
- && measure.getPersonId() == null
- && ((RuleMeasure) measure).getRule() != null;
+ return measure instanceof RuleMeasure && metric.equals(measure.getMetric())
+ && measure.getPersonId() == null && ((RuleMeasure) measure).getRule() != null;
}
public Collection<RuleMeasure> filter(Collection<Measure> measures) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/LocalizedMessages.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/LocalizedMessages.java
index d2f62876334..3a14965bd7a 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/LocalizedMessages.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/LocalizedMessages.java
@@ -73,35 +73,13 @@ public class LocalizedMessages extends ResourceBundle {
}
/*
- * (non-Javadoc)
- *
- * @see java.util.ResourceBundle#getKeys()
- */
-
+ * (non-Javadoc)
+ *
+ * @see java.util.ResourceBundle#getKeys()
+ */
@Override
public Enumeration<String> getKeys() {
- return new Enumeration<String>() {
- private Set<String> keys = new HashSet<String>();
-
- // Set iterator to simulate enumeration
- private Iterator<String> i;
-
- // Constructor
- {
- for (ResourceBundle b : bundles) {
- keys.addAll(Lists.newArrayList(Iterators.forEnumeration(b.getKeys())));
- }
- i = keys.iterator();
- }
-
- public boolean hasMoreElements() {
- return i.hasNext();
- }
-
- public String nextElement() {
- return i.next();
- }
- };
+ return new KeyEnumeration();
}
/*
@@ -109,7 +87,6 @@ public class LocalizedMessages extends ResourceBundle {
*
* @see java.util.ResourceBundle#handleGetObject(java.lang.String)
*/
-
@Override
protected Object handleGetObject(String key) {
for (ResourceBundle b : bundles) {
@@ -121,4 +98,27 @@ public class LocalizedMessages extends ResourceBundle {
}
throw new MissingResourceException(null, null, key);
}
+
+ private class KeyEnumeration implements Enumeration<String> {
+ private Set<String> keys = new HashSet<String>();
+
+ // Set iterator to simulate enumeration
+ private Iterator<String> i;
+
+ // Constructor
+ {
+ for (ResourceBundle b : bundles) {
+ keys.addAll(Lists.newArrayList(Iterators.forEnumeration(b.getKeys())));
+ }
+ i = keys.iterator();
+ }
+
+ public boolean hasMoreElements() {
+ return i.hasNext();
+ }
+
+ public String nextElement() {
+ return i.next();
+ }
+ }
}
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java b/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java
index 4aa9d3e3f59..f2f25d9c307 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java
+++ b/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java
@@ -29,6 +29,7 @@ import org.sonar.api.web.*;
public final class DefaultPages {
private static final View[] PAGES = {new SourceTab(), new CoverageTab(), new IssuesTab(), new DuplicationsTab()};
+ private static final String NOT_APPLICABLE = "browse/index";
private DefaultPages() {
}
@@ -44,8 +45,7 @@ public final class DefaultPages {
@UserRole(UserRole.CODEVIEWER)
private static final class SourceTab implements RubyRailsPage {
public String getTemplate() {
- // not used, hardcoded in BrowseController
- return "browse/index";
+ return NOT_APPLICABLE;
}
public String getId() {
@@ -83,8 +83,7 @@ public final class DefaultPages {
@UserRole(UserRole.CODEVIEWER)
private static final class CoverageTab implements RubyRailsPage {
public String getTemplate() {
- // not used, hardcoded in BrowseController
- return "browse/index";
+ return NOT_APPLICABLE;
}
public String getId() {
@@ -110,8 +109,7 @@ public final class DefaultPages {
@UserRole(UserRole.CODEVIEWER)
private static final class IssuesTab implements RubyRailsPage {
public String getTemplate() {
- // not used, hardcoded in BrowseController
- return "browse/index";
+ return NOT_APPLICABLE;
}
public String getId() {
@@ -129,8 +127,7 @@ public final class DefaultPages {
@UserRole(UserRole.CODEVIEWER)
private static final class DuplicationsTab implements RubyRailsPage {
public String getTemplate() {
- // not used, hardcoded in BrowseController
- return "browse/index";
+ return NOT_APPLICABLE;
}
public String getId() {