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() {
}
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());
}
public class DefaultDecoratorContext implements DecoratorContext {
+ private static final String SAVE_MEASURE_METHOD = "saveMeasure";
private SonarIndex index;
private Resource resource;
private boolean readOnly = false;
}
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;
}
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;
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) {
}
/*
- * (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();
}
/*
*
* @see java.util.ResourceBundle#handleGetObject(java.lang.String)
*/
-
@Override
protected Object handleGetObject(String key) {
for (ResourceBundle b : bundles) {
}
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();
+ }
+ }
}
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() {
}
@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() {
@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() {
@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() {
@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() {