- do not declare multiple variables on same line - fix importstags/5.2-RC1
@@ -142,7 +142,8 @@ public class MonitorTest { | |||
@Test | |||
public void start_then_stop_sequence_of_commands() throws Exception { | |||
monitor = newDefaultMonitor(); | |||
HttpProcessClient p1 = new HttpProcessClient("p1"), p2 = new HttpProcessClient("p2"); | |||
HttpProcessClient p1 = new HttpProcessClient("p1"); | |||
HttpProcessClient p2 = new HttpProcessClient("p2"); | |||
monitor.start(Arrays.asList(p1.newCommand(), p2.newCommand())); | |||
// start p2 when p1 is fully started (ready) | |||
@@ -163,7 +164,8 @@ public class MonitorTest { | |||
@Test | |||
public void stop_all_processes_if_monitor_shutdowns() throws Exception { | |||
monitor = newDefaultMonitor(); | |||
HttpProcessClient p1 = new HttpProcessClient("p1"), p2 = new HttpProcessClient("p2"); | |||
HttpProcessClient p1 = new HttpProcessClient("p1"); | |||
HttpProcessClient p2 = new HttpProcessClient("p2"); | |||
monitor.start(Arrays.asList(p1.newCommand(), p2.newCommand())); | |||
assertThat(p1.isReady()).isTrue(); | |||
assertThat(p2.isReady()).isTrue(); | |||
@@ -179,7 +181,8 @@ public class MonitorTest { | |||
@Test | |||
public void stop_all_processes_if_one_shutdowns() throws Exception { | |||
monitor = newDefaultMonitor(); | |||
HttpProcessClient p1 = new HttpProcessClient("p1"), p2 = new HttpProcessClient("p2"); | |||
HttpProcessClient p1 = new HttpProcessClient("p1"); | |||
HttpProcessClient p2 = new HttpProcessClient("p2"); | |||
monitor.start(Arrays.asList(p1.newCommand(), p2.newCommand())); | |||
assertThat(p1.isReady()).isTrue(); | |||
assertThat(p2.isReady()).isTrue(); | |||
@@ -197,7 +200,8 @@ public class MonitorTest { | |||
@Test | |||
public void stop_all_processes_if_one_fails_to_start() throws Exception { | |||
monitor = newDefaultMonitor(); | |||
HttpProcessClient p1 = new HttpProcessClient("p1"), p2 = new HttpProcessClient("p2", -1); | |||
HttpProcessClient p1 = new HttpProcessClient("p1"); | |||
HttpProcessClient p2 = new HttpProcessClient("p2", -1); | |||
try { | |||
monitor.start(Arrays.asList(p1.newCommand(), p2.newCommand())); | |||
fail(); |
@@ -71,7 +71,9 @@ class SearchSettings { | |||
private void configureFileSystem(ImmutableSettings.Builder builder) { | |||
File homeDir = props.nonNullValueAsFile(ProcessProperties.PATH_HOME); | |||
File dataDir, workDir, logDir; | |||
File dataDir; | |||
File workDir; | |||
File logDir; | |||
// data dir | |||
String dataPath = props.value(ProcessProperties.PATH_DATA); |
@@ -86,7 +86,9 @@ public class SearchSettingsTest { | |||
@Test | |||
public void override_dirs() throws Exception { | |||
File dataDir = temp.newFolder(), logDir = temp.newFolder(), tempDir = temp.newFolder(); | |||
File dataDir = temp.newFolder(); | |||
File logDir = temp.newFolder(); | |||
File tempDir = temp.newFolder(); | |||
Props props = minProps(); | |||
props.set(ProcessProperties.PATH_DATA, dataDir.getAbsolutePath()); | |||
props.set(ProcessProperties.PATH_LOGS, logDir.getAbsolutePath()); |
@@ -147,8 +147,11 @@ public class IssueIndexBenchmarkTest { | |||
} | |||
private static class IssueIterator implements Iterator<IssueDoc> { | |||
private final int nbProjects, nbFilesPerProject, nbIssuesPerFile; | |||
private int currentProject = 0, currentFile = 0; | |||
private final int nbProjects; | |||
private final int nbFilesPerProject; | |||
private final int nbIssuesPerFile; | |||
private int currentProject = 0; | |||
private int currentFile = 0; | |||
private AtomicLong count = new AtomicLong(0L); | |||
private final Iterator<String> users = cycleIterator("guy", 200); | |||
private Iterator<String> rules = cycleIterator("squid:rule", 1000); |
@@ -20,6 +20,12 @@ | |||
package org.sonar.server.benchmark; | |||
import java.util.Arrays; | |||
import java.util.Date; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Timer; | |||
import java.util.concurrent.atomic.AtomicLong; | |||
import org.apache.commons.io.FileUtils; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
@@ -27,12 +33,14 @@ import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.server.es.EsClient; | |||
import org.sonar.server.source.db.FileSourceDb; | |||
import org.sonar.server.source.index.*; | |||
import org.sonar.server.source.index.FileSourcesUpdaterHelper; | |||
import org.sonar.server.source.index.SourceLineDoc; | |||
import org.sonar.server.source.index.SourceLineIndex; | |||
import org.sonar.server.source.index.SourceLineIndexDefinition; | |||
import org.sonar.server.source.index.SourceLineIndexer; | |||
import org.sonar.server.source.index.SourceLineResultSetIterator; | |||
import org.sonar.server.tester.ServerTester; | |||
import java.util.*; | |||
import java.util.concurrent.atomic.AtomicLong; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
/** |
@@ -19,7 +19,10 @@ | |||
*/ | |||
package org.sonar.server.charts.deprecated; | |||
import java.awt.*; | |||
import java.awt.BasicStroke; | |||
import java.awt.Color; | |||
import java.awt.Font; | |||
import java.awt.Transparency; | |||
import java.awt.image.BufferedImage; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.IOException; | |||
@@ -135,8 +138,8 @@ public abstract class BaseChart { | |||
protected BasicStroke getDashedStroke(float width) { | |||
return new BasicStroke(width, | |||
BasicStroke.CAP_BUTT, | |||
BasicStroke.JOIN_MITER, | |||
10.0f, new float[] { 5.0f }, 0.0f); | |||
BasicStroke.CAP_BUTT, | |||
BasicStroke.JOIN_MITER, | |||
10.0f, new float[] {5.0f}, 0.0f); | |||
} | |||
} |
@@ -19,7 +19,8 @@ | |||
*/ | |||
package org.sonar.server.charts.deprecated; | |||
import java.awt.*; | |||
import java.awt.Color; | |||
import java.awt.Font; | |||
import java.util.Map; | |||
import java.util.StringTokenizer; | |||
import org.jfree.chart.JFreeChart; |
@@ -19,7 +19,7 @@ | |||
*/ | |||
package org.sonar.server.charts.deprecated; | |||
import java.awt.*; | |||
import java.awt.Color; | |||
import java.awt.image.BufferedImage; | |||
import java.io.IOException; | |||
import java.util.Map; | |||
@@ -91,7 +91,7 @@ public class PieChart extends BaseChartWeb implements DeprecatedChart { | |||
private void configureDefaultColors() { | |||
PiePlot plot = (PiePlot) jfreechart.getPlot(); | |||
for (int i=0 ; i<COLORS.length ; i++) { | |||
for (int i = 0; i < COLORS.length; i++) { | |||
plot.setSectionPaint(Integer.toString(i), COLORS[i]); | |||
} | |||
} |
@@ -23,7 +23,9 @@ import org.sonar.api.web.AbstractRubyTemplate; | |||
import org.sonar.api.web.RubyRailsWidget; | |||
public abstract class CoreWidget extends AbstractRubyTemplate implements RubyRailsWidget { | |||
private String id, title, templatePath; | |||
private String id; | |||
private String title; | |||
private String templatePath; | |||
protected CoreWidget(String id, String title, String templatePath) { | |||
this.id = id; |
@@ -35,7 +35,8 @@ public abstract class BaseDataChange implements DataChange, MigrationStep { | |||
@Override | |||
public final void execute() throws SQLException { | |||
Connection readConnection = null, writeConnection = null; | |||
Connection readConnection = null; | |||
Connection writeConnection = null; | |||
try { | |||
readConnection = openConnection(); | |||
@@ -28,7 +28,8 @@ public interface DataChange { | |||
class Context { | |||
private final Database db; | |||
private final Connection readConnection, writeConnection; | |||
private final Connection readConnection; | |||
private final Connection writeConnection; | |||
public Context(Database db, Connection readConnection, Connection writeConnection) { | |||
this.db = db; |
@@ -38,7 +38,8 @@ public class MassUpdate { | |||
} | |||
private final Database db; | |||
private final Connection readConnection, writeConnection; | |||
private final Connection readConnection; | |||
private final Connection writeConnection; | |||
private final AtomicLong counter = new AtomicLong(0L); | |||
private final ProgressLogger progress = ProgressLogger.create(getClass(), counter); | |||
@@ -178,7 +178,9 @@ class ViolationConverter implements Callable<Object> { | |||
continue; | |||
} | |||
String issueKey = Uuids.create(); | |||
String status, severity, reporter = null; | |||
String status; | |||
String severity; | |||
String reporter = null; | |||
boolean manualSeverity; | |||
Object createdAt = Objects.firstNonNull(row.get(CREATED_AT), ONE_YEAR_AGO); | |||
Object updatedAt; |
@@ -96,8 +96,10 @@ public class AddMissingRuleParameterDefaultValuesMigrationStep extends BaseDataC | |||
} | |||
private static class RuleParam { | |||
final Long id, ruleId; | |||
final String defaultValue, name; | |||
final Long id; | |||
final Long ruleId; | |||
final String defaultValue; | |||
final String name; | |||
RuleParam(@Nullable Long id, @Nullable Long ruleId, @Nullable String name, @Nullable String defaultValue) { | |||
this.id = id; | |||
@@ -108,7 +110,8 @@ public class AddMissingRuleParameterDefaultValuesMigrationStep extends BaseDataC | |||
} | |||
private static class ActiveRule { | |||
final Long id, profileId; | |||
final Long id; | |||
final Long profileId; | |||
ActiveRule(@Nullable Long id, @Nullable Long profileId) { | |||
this.id = id; |
@@ -170,7 +170,8 @@ public class DuplicationsParser { | |||
public static class Duplication { | |||
private final ComponentDto file; | |||
private final Integer from, size; | |||
private final Integer from; | |||
private final Integer size; | |||
Duplication(@Nullable ComponentDto file, Integer from, Integer size) { | |||
this.file = file; |
@@ -34,7 +34,9 @@ import java.util.concurrent.TimeUnit; | |||
public abstract class BaseIndexer implements Startable { | |||
private final ThreadPoolExecutor executor; | |||
private final String indexName, typeName, dateFieldName; | |||
private final String indexName; | |||
private final String typeName; | |||
private final String dateFieldName; | |||
protected final EsClient esClient; | |||
private volatile long lastUpdatedAt = -1L; | |||
@@ -175,7 +175,9 @@ public class NewIndex { | |||
public static class StringFieldBuilder { | |||
private final NewIndexType indexType; | |||
private final String fieldName; | |||
private boolean docValues = false, disableSearch = false, hasAnalyzedField = false; | |||
private boolean docValues = false; | |||
private boolean disableSearch = false; | |||
private boolean hasAnalyzedField = false; | |||
private SortedMap<String, Object> subFields = Maps.newTreeMap(); | |||
private StringFieldBuilder(NewIndexType indexType, String fieldName) { |
@@ -83,7 +83,9 @@ public class ProxyBulkRequestBuilder extends BulkRequestBuilder { | |||
Multiset<BulkRequestKey> groupedRequests = LinkedHashMultiset.create(); | |||
for (int i = 0; i < request.requests().size(); i++) { | |||
ActionRequest<?> item = request.requests().get(i); | |||
String requestType, index, docType; | |||
String requestType; | |||
String index; | |||
String docType; | |||
if (item instanceof IndexRequest) { | |||
IndexRequest request = (IndexRequest) item; | |||
requestType = "index"; |
@@ -20,10 +20,10 @@ | |||
package org.sonar.server.event; | |||
import com.google.common.collect.Multimap; | |||
import org.sonar.api.notifications.*; | |||
import java.util.Collection; | |||
import java.util.Map; | |||
import org.sonar.api.notifications.Notification; | |||
import org.sonar.api.notifications.NotificationChannel; | |||
import org.sonar.server.notification.NotificationDispatcher; | |||
import org.sonar.server.notification.NotificationDispatcherMetadata; | |||
import org.sonar.server.notification.NotificationManager; |
@@ -24,7 +24,8 @@ import javax.annotation.Nullable; | |||
public class IssueChangelogDiffFormat { | |||
private String oldValue, newValue; | |||
private String oldValue; | |||
private String newValue; | |||
public IssueChangelogDiffFormat(@Nullable String oldValue, @Nullable String newValue) { | |||
this.oldValue = oldValue; |
@@ -20,6 +20,13 @@ | |||
package org.sonar.server.issue.index; | |||
import com.google.common.collect.Maps; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.Map; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.lang.BooleanUtils; | |||
import org.sonar.api.issue.Issue; | |||
import org.sonar.api.issue.IssueComment; | |||
@@ -29,11 +36,6 @@ import org.sonar.api.utils.Duration; | |||
import org.sonar.api.utils.KeyValueFormat; | |||
import org.sonar.server.search.BaseDoc; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.util.*; | |||
public class IssueDoc extends BaseDoc implements Issue { | |||
public IssueDoc(Map<String, Object> fields) { |
@@ -21,10 +21,11 @@ package org.sonar.server.issue.notification; | |||
import com.google.common.base.Objects; | |||
import com.google.common.collect.Multimap; | |||
import org.sonar.api.notifications.*; | |||
import javax.annotation.Nullable; | |||
import java.util.Collection; | |||
import org.sonar.api.notifications.Notification; | |||
import org.sonar.api.notifications.NotificationChannel; | |||
import org.sonar.server.notification.NotificationDispatcher; | |||
import org.sonar.server.notification.NotificationDispatcherMetadata; | |||
import org.sonar.server.notification.NotificationManager; |
@@ -20,10 +20,10 @@ | |||
package org.sonar.server.issue.notification; | |||
import com.google.common.collect.Multimap; | |||
import org.sonar.api.notifications.*; | |||
import java.util.Collection; | |||
import java.util.Map; | |||
import org.sonar.api.notifications.Notification; | |||
import org.sonar.api.notifications.NotificationChannel; | |||
import org.sonar.server.notification.NotificationDispatcher; | |||
import org.sonar.server.notification.NotificationDispatcherMetadata; | |||
import org.sonar.server.notification.NotificationManager; |
@@ -46,7 +46,8 @@ public class MeasureFilter { | |||
private List<String> resourceQualifiers = Collections.emptyList(); | |||
private String resourceKey = null; | |||
private String resourceName = null; | |||
private Date fromDate = null, toDate = null; | |||
private Date fromDate = null; | |||
private Date toDate = null; | |||
private boolean userFavourites = false; | |||
// conditions on measures |
@@ -48,7 +48,8 @@ public class DefaultServerFileSystem implements ServerFileSystem, Startable { | |||
private static final Logger LOGGER = Loggers.get(DefaultServerFileSystem.class); | |||
private final Server server; | |||
private final File homeDir, tempDir; | |||
private final File homeDir; | |||
private final File tempDir; | |||
public DefaultServerFileSystem(Settings settings, Server server) { | |||
this.server = server; |
@@ -33,7 +33,8 @@ public class BulkChangeResult { | |||
private final QualityProfileDto profile; | |||
private final Errors errors = new Errors(); | |||
private int succeeded = 0, failed = 0; | |||
private int succeeded = 0; | |||
private int failed = 0; | |||
private final List<ActiveRuleChange> changes = Lists.newArrayList(); | |||
public BulkChangeResult() { |
@@ -110,7 +110,8 @@ public class QProfileBackuper { | |||
*/ | |||
public BulkChangeResult restore(Reader reader, @Nullable QProfileName toProfileName) { | |||
try { | |||
String profileLang = null, profileName = null; | |||
String profileLang = null; | |||
String profileName = null; | |||
List<RuleActivation> ruleActivations = Lists.newArrayList(); | |||
SMInputFactory inputFactory = initStax(); | |||
SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader); | |||
@@ -146,7 +147,9 @@ public class QProfileBackuper { | |||
List<RuleKey> duplicatedKeys = Lists.newArrayList(); | |||
while (rulesCursor.getNext() != null) { | |||
SMInputCursor ruleCursor = rulesCursor.childElementCursor(); | |||
String repositoryKey = null, key = null, severity = null; | |||
String repositoryKey = null; | |||
String key = null; | |||
String severity = null; | |||
Map<String, String> parameters = Maps.newHashMap(); | |||
while (ruleCursor.getNext() != null) { | |||
String nodeName = ruleCursor.getLocalName(); |
@@ -22,7 +22,8 @@ package org.sonar.server.qualityprofile; | |||
import javax.annotation.Nullable; | |||
public class QProfileName { | |||
private final String lang, name; | |||
private final String lang; | |||
private final String name; | |||
public QProfileName(String lang, String name) { | |||
this.lang = lang; |
@@ -43,8 +43,10 @@ class RuleActivatorContext { | |||
private RuleDto rule; | |||
private final Map<String, RuleParamDto> ruleParams = Maps.newHashMap(); | |||
private QualityProfileDto profile; | |||
private ActiveRuleDto activeRule, parentActiveRule; | |||
private final Map<String, ActiveRuleParamDto> activeRuleParams = Maps.newHashMap(), parentActiveRuleParams = Maps.newHashMap(); | |||
private ActiveRuleDto activeRule; | |||
private ActiveRuleDto parentActiveRule; | |||
private final Map<String, ActiveRuleParamDto> activeRuleParams = Maps.newHashMap(); | |||
private final Map<String, ActiveRuleParamDto> parentActiveRuleParams = Maps.newHashMap(); | |||
RuleActivatorContext() { | |||
} |
@@ -22,7 +22,8 @@ package org.sonar.server.qualityprofile.ws; | |||
import org.elasticsearch.action.search.SearchResponse; | |||
import org.elasticsearch.search.SearchHit; | |||
import org.sonar.api.resources.Languages; | |||
import org.sonar.api.server.ws.*; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService.NewAction; | |||
import org.sonar.api.server.ws.WebService.NewController; | |||
import org.sonar.api.server.ws.WebService.Param; |
@@ -34,11 +34,16 @@ public class NewRule { | |||
private String ruleKey; | |||
private RuleKey templateKey; | |||
private String name, htmlDescription, markdownDescription, severity; | |||
private String name; | |||
private String htmlDescription; | |||
private String markdownDescription; | |||
private String severity; | |||
private RuleStatus status; | |||
private final Map<String, String> parameters = Maps.newHashMap(); | |||
private boolean isCustom, isManual, preventReactivation = false; | |||
private boolean isCustom; | |||
private boolean isManual; | |||
private boolean preventReactivation = false; | |||
private NewRule() { | |||
// No direct call to constructor |
@@ -45,7 +45,9 @@ import java.util.SortedSet; | |||
public class RuleRepositories { | |||
public static class Repository implements Comparable<Repository> { | |||
private final String key, name, language; | |||
private final String key; | |||
private final String name; | |||
private final String language; | |||
private Repository(RulesDefinition.Repository repoDef) { | |||
this.key = repoDef.key(); |
@@ -37,15 +37,25 @@ public class RuleUpdate { | |||
private final RuleKey ruleKey; | |||
private boolean changeTags = false, changeMarkdownNote = false, changeDebtSubCharacteristic = false, changeDebtRemediationFunction = false, | |||
changeName = false, changeDescription = false, changeSeverity = false, changeStatus = false, changeParameters = false; | |||
private boolean isCustomRule, isManual; | |||
private boolean changeTags = false; | |||
private boolean changeMarkdownNote = false; | |||
private boolean changeDebtSubCharacteristic = false; | |||
private boolean changeDebtRemediationFunction = false; | |||
private boolean changeName = false; | |||
private boolean changeDescription = false; | |||
private boolean changeSeverity = false; | |||
private boolean changeStatus = false; | |||
private boolean changeParameters = false; | |||
private boolean isCustomRule; | |||
private boolean isManual; | |||
private Set<String> tags; | |||
private String markdownNote; | |||
private String debtSubCharacteristicKey; | |||
private DebtRemediationFunction debtRemediationFunction; | |||
private String name, markdownDescription, severity; | |||
private String name; | |||
private String markdownDescription; | |||
private String severity; | |||
private RuleStatus status; | |||
private final Map<String, String> parameters = Maps.newHashMap(); | |||
@@ -25,6 +25,16 @@ import com.google.common.base.Preconditions; | |||
import com.google.common.base.Predicate; | |||
import com.google.common.collect.Collections2; | |||
import com.google.common.collect.ImmutableList; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.HashMap; | |||
import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.collections.CollectionUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.elasticsearch.action.search.SearchRequestBuilder; | |||
@@ -32,7 +42,15 @@ import org.elasticsearch.action.search.SearchResponse; | |||
import org.elasticsearch.action.search.SearchScrollRequestBuilder; | |||
import org.elasticsearch.action.search.SearchType; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.elasticsearch.index.query.*; | |||
import org.elasticsearch.index.query.BoolFilterBuilder; | |||
import org.elasticsearch.index.query.BoolQueryBuilder; | |||
import org.elasticsearch.index.query.FilterBuilder; | |||
import org.elasticsearch.index.query.FilterBuilders; | |||
import org.elasticsearch.index.query.HasParentFilterBuilder; | |||
import org.elasticsearch.index.query.MatchQueryBuilder; | |||
import org.elasticsearch.index.query.QueryBuilder; | |||
import org.elasticsearch.index.query.QueryBuilders; | |||
import org.elasticsearch.index.query.SimpleQueryStringBuilder; | |||
import org.elasticsearch.search.SearchHit; | |||
import org.elasticsearch.search.aggregations.AggregationBuilder; | |||
import org.elasticsearch.search.aggregations.AggregationBuilders; | |||
@@ -49,12 +67,13 @@ import org.sonar.api.server.debt.DebtCharacteristic; | |||
import org.sonar.core.rule.RuleDto; | |||
import org.sonar.server.qualityprofile.index.ActiveRuleNormalizer; | |||
import org.sonar.server.rule.Rule; | |||
import org.sonar.server.search.*; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.util.*; | |||
import org.sonar.server.search.BaseIndex; | |||
import org.sonar.server.search.IndexDefinition; | |||
import org.sonar.server.search.IndexField; | |||
import org.sonar.server.search.QueryContext; | |||
import org.sonar.server.search.Result; | |||
import org.sonar.server.search.SearchClient; | |||
import org.sonar.server.search.StickyFacetBuilder; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
@@ -428,14 +447,14 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { | |||
/* | |||
* Since this facet concerns 2 fields, we're using an aggregation structure like this: | |||
* global aggregation | |||
* |- sub-aggregation on characteristics: filter | |||
* | |- classic sub-aggregation with top-n terms, excluding NONE | |||
* | |- classic sub-aggregation with selected terms | |||
* | |- terms aggregation on "NONE" | |||
* | |- missing aggregation | |||
* |- sub-aggregation on sub-characteristics: filter, excluding NONE | |||
* |- classic sub-aggregation with top-n terms | |||
* |- classic sub-aggregation with selected terms | |||
* |- sub-aggregation on characteristics: filter | |||
* | |- classic sub-aggregation with top-n terms, excluding NONE | |||
* | |- classic sub-aggregation with selected terms | |||
* | |- terms aggregation on "NONE" | |||
* | |- missing aggregation | |||
* |- sub-aggregation on sub-characteristics: filter, excluding NONE | |||
* |- classic sub-aggregation with top-n terms | |||
* |- classic sub-aggregation with selected terms | |||
*/ | |||
int characsSize = 10; | |||
int subCharacsSize = 300; | |||
@@ -454,8 +473,8 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { | |||
.size(characsSize)) | |||
.subAggregation( | |||
AggregationBuilders.terms(FACET_DEBT_CHARACTERISTICS + "__chars_none").field(RuleNormalizer.RuleField.CHARACTERISTIC.field()) | |||
.include(DebtCharacteristic.NONE) | |||
.size(characsSize)) | |||
.include(DebtCharacteristic.NONE) | |||
.size(characsSize)) | |||
.subAggregation( | |||
AggregationBuilders.missing(FACET_DEBT_CHARACTERISTICS + "__chars_missing").field(RuleNormalizer.RuleField.CHARACTERISTIC.field())); | |||
AggregationBuilder debtSubChar = AggregationBuilders.filter(FACET_DEBT_CHARACTERISTICS + "__subchars") |
@@ -20,15 +20,17 @@ | |||
package org.sonar.server.search; | |||
import com.google.common.base.Preconditions; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Map; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.lang.builder.ReflectionToStringBuilder; | |||
import org.elasticsearch.action.search.SearchResponse; | |||
import org.elasticsearch.search.SearchHit; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.util.*; | |||
public class Result<K> { | |||
private final List<K> hits; |
@@ -54,7 +54,17 @@ import org.picocontainer.Startable; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.process.LoopbackAddress; | |||
import org.sonar.process.ProcessProperties; | |||
import org.sonar.server.es.request.*; | |||
import org.sonar.server.es.request.ProxyBulkRequestBuilder; | |||
import org.sonar.server.es.request.ProxyCountRequestBuilder; | |||
import org.sonar.server.es.request.ProxyCreateIndexRequestBuilder; | |||
import org.sonar.server.es.request.ProxyDeleteRequestBuilder; | |||
import org.sonar.server.es.request.ProxyGetRequestBuilder; | |||
import org.sonar.server.es.request.ProxyIndicesExistsRequestBuilder; | |||
import org.sonar.server.es.request.ProxyMultiGetRequestBuilder; | |||
import org.sonar.server.es.request.ProxyPutMappingRequestBuilder; | |||
import org.sonar.server.es.request.ProxyRefreshRequestBuilder; | |||
import org.sonar.server.es.request.ProxySearchRequestBuilder; | |||
import org.sonar.server.es.request.ProxySearchScrollRequestBuilder; | |||
/** | |||
* ElasticSearch Node used to connect to index. |
@@ -21,22 +21,26 @@ package org.sonar.server.startup; | |||
import com.google.common.collect.Lists; | |||
import com.google.common.collect.Ordering; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.Map.Entry; | |||
import org.picocontainer.Startable; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.api.utils.log.Profiler; | |||
import org.sonar.api.web.Dashboard; | |||
import org.sonar.api.web.DashboardTemplate; | |||
import org.sonar.core.dashboard.*; | |||
import org.sonar.core.dashboard.ActiveDashboardDao; | |||
import org.sonar.core.dashboard.ActiveDashboardDto; | |||
import org.sonar.core.dashboard.DashboardDao; | |||
import org.sonar.core.dashboard.DashboardDto; | |||
import org.sonar.core.dashboard.WidgetDto; | |||
import org.sonar.core.dashboard.WidgetPropertyDto; | |||
import org.sonar.core.template.LoadedTemplateDao; | |||
import org.sonar.core.template.LoadedTemplateDto; | |||
import org.sonar.server.issue.filter.RegisterIssueFilters; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.Map.Entry; | |||
/** | |||
* @since 2.13 | |||
*/ |
@@ -37,7 +37,10 @@ public class UpdateUser { | |||
private String password; | |||
private String passwordConfirmation; | |||
boolean isNameChanged, isEmailChanged, isScmAccountsChanged, isPasswordChanged; | |||
boolean isNameChanged; | |||
boolean isEmailChanged; | |||
boolean isScmAccountsChanged; | |||
boolean isPasswordChanged; | |||
private UpdateUser(String login) { | |||
// No direct call to this constructor |
@@ -19,8 +19,13 @@ | |||
*/ | |||
package org.sonar.server.user; | |||
import javax.servlet.*; | |||
import java.io.IOException; | |||
import javax.servlet.Filter; | |||
import javax.servlet.FilterChain; | |||
import javax.servlet.FilterConfig; | |||
import javax.servlet.ServletException; | |||
import javax.servlet.ServletRequest; | |||
import javax.servlet.ServletResponse; | |||
import org.sonar.api.utils.log.Loggers; | |||
import org.sonar.server.platform.Platform; | |||
@@ -40,7 +40,10 @@ public class DumbComponent implements Component { | |||
private final Type type; | |||
private final int ref; | |||
private final String uuid, key, name, version; | |||
private final String uuid; | |||
private final String key; | |||
private final String name; | |||
private final String version; | |||
private final FileAttributes fileAttributes; | |||
private final List<Component> children; | |||
@@ -127,7 +130,10 @@ public class DumbComponent implements Component { | |||
public static final class Builder { | |||
private final Type type; | |||
private final int ref; | |||
private String uuid, key, name, version; | |||
private String uuid; | |||
private String key; | |||
private String name; | |||
private String version; | |||
private FileAttributes fileAttributes; | |||
private final List<Component> children = new ArrayList<>(); | |||
@@ -20,7 +20,11 @@ | |||
package org.sonar.server.computation.step; | |||
import org.junit.*; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.issue.Issue; | |||
import org.sonar.api.issue.internal.DefaultIssue; | |||
@@ -87,18 +91,18 @@ public class PersistIssuesStepTest extends BaseStepTest { | |||
dbTester.prepareDbUnit(getClass(), "insert_new_issue.xml"); | |||
issueCache.newAppender().append(new DefaultIssue() | |||
.setKey("ISSUE") | |||
.setRuleKey(RuleKey.of("xoo", "S01")) | |||
.setComponentUuid("COMPONENT") | |||
.setProjectUuid("PROJECT") | |||
.setSeverity(Severity.BLOCKER) | |||
.setStatus(Issue.STATUS_OPEN) | |||
.setNew(true) | |||
).close(); | |||
.setKey("ISSUE") | |||
.setRuleKey(RuleKey.of("xoo", "S01")) | |||
.setComponentUuid("COMPONENT") | |||
.setProjectUuid("PROJECT") | |||
.setSeverity(Severity.BLOCKER) | |||
.setStatus(Issue.STATUS_OPEN) | |||
.setNew(true) | |||
).close(); | |||
step.execute(); | |||
dbTester.assertDbUnit(getClass(), "insert_new_issue-result.xml", new String[]{"id"}, "issues"); | |||
dbTester.assertDbUnit(getClass(), "insert_new_issue-result.xml", new String[] {"id"}, "issues"); | |||
} | |||
@Test | |||
@@ -106,16 +110,16 @@ public class PersistIssuesStepTest extends BaseStepTest { | |||
dbTester.prepareDbUnit(getClass(), "shared.xml"); | |||
issueCache.newAppender().append(new DefaultIssue() | |||
.setKey("ISSUE") | |||
.setRuleKey(RuleKey.of("xoo", "S01")) | |||
.setComponentUuid("COMPONENT") | |||
.setProjectUuid("PROJECT") | |||
.setSeverity(Severity.BLOCKER) | |||
.setStatus(Issue.STATUS_CLOSED) | |||
.setResolution(Issue.RESOLUTION_FIXED) | |||
.setNew(false) | |||
.setChanged(true) | |||
).close(); | |||
.setKey("ISSUE") | |||
.setRuleKey(RuleKey.of("xoo", "S01")) | |||
.setComponentUuid("COMPONENT") | |||
.setProjectUuid("PROJECT") | |||
.setSeverity(Severity.BLOCKER) | |||
.setStatus(Issue.STATUS_CLOSED) | |||
.setResolution(Issue.RESOLUTION_FIXED) | |||
.setNew(false) | |||
.setChanged(true) | |||
).close(); | |||
step.execute(); | |||
@@ -127,27 +131,27 @@ public class PersistIssuesStepTest extends BaseStepTest { | |||
dbTester.prepareDbUnit(getClass(), "shared.xml"); | |||
issueCache.newAppender().append(new DefaultIssue() | |||
.setKey("ISSUE") | |||
.setRuleKey(RuleKey.of("xoo", "S01")) | |||
.setComponentUuid("COMPONENT") | |||
.setProjectUuid("PROJECT") | |||
.setSeverity(Severity.BLOCKER) | |||
.setStatus(Issue.STATUS_CLOSED) | |||
.setResolution(Issue.RESOLUTION_FIXED) | |||
.setNew(false) | |||
.setChanged(true) | |||
.addComment(new DefaultIssueComment() | |||
.setKey("COMMENT") | |||
.setIssueKey("ISSUE") | |||
.setUserLogin("john") | |||
.setMarkdownText("Some text") | |||
.setNew(true) | |||
) | |||
).close(); | |||
.setKey("ISSUE") | |||
.setRuleKey(RuleKey.of("xoo", "S01")) | |||
.setComponentUuid("COMPONENT") | |||
.setProjectUuid("PROJECT") | |||
.setSeverity(Severity.BLOCKER) | |||
.setStatus(Issue.STATUS_CLOSED) | |||
.setResolution(Issue.RESOLUTION_FIXED) | |||
.setNew(false) | |||
.setChanged(true) | |||
.addComment(new DefaultIssueComment() | |||
.setKey("COMMENT") | |||
.setIssueKey("ISSUE") | |||
.setUserLogin("john") | |||
.setMarkdownText("Some text") | |||
.setNew(true) | |||
) | |||
).close(); | |||
step.execute(); | |||
dbTester.assertDbUnit(getClass(), "add_comment-result.xml", new String[]{"id", "created_at", "updated_at"}, "issue_changes"); | |||
dbTester.assertDbUnit(getClass(), "add_comment-result.xml", new String[] {"id", "created_at", "updated_at"}, "issue_changes"); | |||
} | |||
@Test | |||
@@ -155,25 +159,25 @@ public class PersistIssuesStepTest extends BaseStepTest { | |||
dbTester.prepareDbUnit(getClass(), "shared.xml"); | |||
issueCache.newAppender().append(new DefaultIssue() | |||
.setKey("ISSUE") | |||
.setRuleKey(RuleKey.of("xoo", "S01")) | |||
.setComponentUuid("COMPONENT") | |||
.setProjectUuid("PROJECT") | |||
.setSeverity(Severity.BLOCKER) | |||
.setStatus(Issue.STATUS_CLOSED) | |||
.setResolution(Issue.RESOLUTION_FIXED) | |||
.setNew(false) | |||
.setChanged(true) | |||
.setCurrentChange(new FieldDiffs() | |||
.setIssueKey("ISSUE") | |||
.setUserLogin("john") | |||
.setDiff("technicalDebt", null, 1L) | |||
) | |||
).close(); | |||
.setKey("ISSUE") | |||
.setRuleKey(RuleKey.of("xoo", "S01")) | |||
.setComponentUuid("COMPONENT") | |||
.setProjectUuid("PROJECT") | |||
.setSeverity(Severity.BLOCKER) | |||
.setStatus(Issue.STATUS_CLOSED) | |||
.setResolution(Issue.RESOLUTION_FIXED) | |||
.setNew(false) | |||
.setChanged(true) | |||
.setCurrentChange(new FieldDiffs() | |||
.setIssueKey("ISSUE") | |||
.setUserLogin("john") | |||
.setDiff("technicalDebt", null, 1L) | |||
) | |||
).close(); | |||
step.execute(); | |||
dbTester.assertDbUnit(getClass(), "add_change-result.xml", new String[]{"id", "created_at", "updated_at"}, "issue_changes"); | |||
dbTester.assertDbUnit(getClass(), "add_change-result.xml", new String[] {"id", "created_at", "updated_at"}, "issue_changes"); | |||
} | |||
} |
@@ -20,7 +20,11 @@ | |||
package org.sonar.server.db.migrations; | |||
import org.junit.Test; | |||
import org.sonar.core.persistence.dialect.*; | |||
import org.sonar.core.persistence.dialect.H2; | |||
import org.sonar.core.persistence.dialect.MsSql; | |||
import org.sonar.core.persistence.dialect.MySql; | |||
import org.sonar.core.persistence.dialect.Oracle; | |||
import org.sonar.core.persistence.dialect.PostgreSql; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown; |
@@ -36,7 +36,8 @@ import java.util.Properties; | |||
public class EsServerHolder { | |||
private static EsServerHolder HOLDER = null; | |||
private final String clusterName, nodeName; | |||
private final String clusterName; | |||
private final String nodeName; | |||
private final int port; | |||
private final String hostName; | |||
private final File homeDir; |
@@ -26,7 +26,8 @@ import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.mockito.Mock; | |||
import org.mockito.runners.MockitoJUnitRunner; | |||
import org.sonar.api.notifications.*; | |||
import org.sonar.api.notifications.Notification; | |||
import org.sonar.api.notifications.NotificationChannel; | |||
import org.sonar.server.notification.NotificationDispatcher; | |||
import org.sonar.server.notification.NotificationDispatcherMetadata; | |||
import org.sonar.server.notification.NotificationManager; |
@@ -19,24 +19,32 @@ | |||
*/ | |||
package org.sonar.server.permission; | |||
import java.util.List; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import org.mockito.ArgumentCaptor; | |||
import org.mockito.Mock; | |||
import org.mockito.runners.MockitoJUnitRunner; | |||
import org.sonar.core.permission.*; | |||
import org.sonar.core.permission.GroupWithPermission; | |||
import org.sonar.core.permission.GroupWithPermissionDto; | |||
import org.sonar.core.permission.PermissionDao; | |||
import org.sonar.core.permission.PermissionQuery; | |||
import org.sonar.core.permission.PermissionTemplateDao; | |||
import org.sonar.core.permission.PermissionTemplateDto; | |||
import org.sonar.core.permission.UserWithPermissionDto; | |||
import org.sonar.core.resource.ResourceDao; | |||
import org.sonar.core.resource.ResourceDto; | |||
import org.sonar.core.resource.ResourceQuery; | |||
import org.sonar.server.exceptions.NotFoundException; | |||
import java.util.List; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.junit.Assert.fail; | |||
import static org.mockito.Matchers.*; | |||
import static org.mockito.Matchers.any; | |||
import static org.mockito.Matchers.anyInt; | |||
import static org.mockito.Matchers.anyLong; | |||
import static org.mockito.Matchers.anyString; | |||
import static org.mockito.Mockito.verify; | |||
import static org.mockito.Mockito.when; | |||
@@ -64,7 +72,7 @@ public class PermissionFinderTest { | |||
public void find_users() { | |||
when(permissionDao.selectUsers(any(PermissionQuery.class), anyLong(), anyInt(), anyInt())).thenReturn( | |||
newArrayList(new UserWithPermissionDto().setName("user1").setPermission("user")) | |||
); | |||
); | |||
UserWithPermissionQueryResult result = finder.findUsersWithPermission(PermissionQuery.builder().permission("user").build()); | |||
assertThat(result.users()).hasSize(1); | |||
@@ -101,7 +109,7 @@ public class PermissionFinderTest { | |||
new UserWithPermissionDto().setName("user1").setPermission("user"), | |||
new UserWithPermissionDto().setName("user2").setPermission("user"), | |||
new UserWithPermissionDto().setName("user3").setPermission("user")) | |||
); | |||
); | |||
UserWithPermissionQueryResult result = finder.findUsersWithPermission(PermissionQuery.builder().permission("user").pageIndex(1).pageSize(2).build()); | |||
ArgumentCaptor<Integer> argumentOffset = ArgumentCaptor.forClass(Integer.class); | |||
@@ -120,7 +128,7 @@ public class PermissionFinderTest { | |||
new UserWithPermissionDto().setName("user2").setPermission("user"), | |||
new UserWithPermissionDto().setName("user4").setPermission("user"), | |||
new UserWithPermissionDto().setName("user3").setPermission("user")) | |||
); | |||
); | |||
UserWithPermissionQueryResult result = finder.findUsersWithPermission(PermissionQuery.builder().permission("user").pageIndex(1).pageSize(10).build()); | |||
ArgumentCaptor<Integer> argumentOffset = ArgumentCaptor.forClass(Integer.class); | |||
@@ -136,7 +144,7 @@ public class PermissionFinderTest { | |||
public void find_groups() { | |||
when(permissionDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( | |||
newArrayList(new GroupWithPermissionDto().setName("users").setPermission("user")) | |||
); | |||
); | |||
GroupWithPermissionQueryResult result = finder.findGroupsWithPermission( | |||
PermissionQuery.builder().permission("user").membership(PermissionQuery.IN).build()); | |||
@@ -152,7 +160,7 @@ public class PermissionFinderTest { | |||
new GroupWithPermissionDto().setName("Users").setPermission(null), | |||
new GroupWithPermissionDto().setName("Reviewers").setPermission(null), | |||
new GroupWithPermissionDto().setName("Other").setPermission(null) | |||
)); | |||
)); | |||
GroupWithPermissionQueryResult result = finder.findGroupsWithPermission( | |||
PermissionQuery.builder() | |||
@@ -183,7 +191,7 @@ public class PermissionFinderTest { | |||
new GroupWithPermissionDto().setName("Users").setPermission(null), | |||
new GroupWithPermissionDto().setName("Reviewers").setPermission(null), | |||
new GroupWithPermissionDto().setName("Other").setPermission(null) | |||
)); | |||
)); | |||
assertThat(finder.findGroupsWithPermission( | |||
PermissionQuery.builder().permission("user").membership(PermissionQuery.IN).build()).groups()).hasSize(2); | |||
@@ -197,9 +205,9 @@ public class PermissionFinderTest { | |||
public void find_groups_with_added_anyone_group() { | |||
when(permissionDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( | |||
newArrayList(new GroupWithPermissionDto().setName("users").setPermission("user")) | |||
); | |||
); | |||
GroupWithPermissionQueryResult result = finder.findGroupsWithPermission( PermissionQuery.builder().permission("user") | |||
GroupWithPermissionQueryResult result = finder.findGroupsWithPermission(PermissionQuery.builder().permission("user") | |||
.pageIndex(1).membership(PermissionQuery.ANY).build()); | |||
assertThat(result.groups()).hasSize(2); | |||
GroupWithPermission first = result.groups().get(0); | |||
@@ -211,7 +219,7 @@ public class PermissionFinderTest { | |||
public void find_groups_without_adding_anyone_group_when_search_text_do_not_matched() { | |||
when(permissionDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( | |||
newArrayList(new GroupWithPermissionDto().setName("users").setPermission("user")) | |||
); | |||
); | |||
GroupWithPermissionQueryResult result = finder.findGroupsWithPermission(PermissionQuery.builder().permission("user").search("other") | |||
.pageIndex(1).membership(PermissionQuery.ANY).build()); | |||
@@ -223,7 +231,7 @@ public class PermissionFinderTest { | |||
public void find_groups_with_added_anyone_group_when_search_text_matched() { | |||
when(permissionDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( | |||
newArrayList(new GroupWithPermissionDto().setName("MyAnyGroup").setPermission("user")) | |||
); | |||
); | |||
GroupWithPermissionQueryResult result = finder.findGroupsWithPermission(PermissionQuery.builder().permission("user").search("any") | |||
.pageIndex(1).membership(PermissionQuery.ANY).build()); | |||
@@ -234,22 +242,21 @@ public class PermissionFinderTest { | |||
public void find_groups_without_adding_anyone_group_when_out_membership_selected() { | |||
when(permissionDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( | |||
newArrayList(new GroupWithPermissionDto().setName("users").setPermission("user")) | |||
); | |||
); | |||
GroupWithPermissionQueryResult result = finder.findGroupsWithPermission( PermissionQuery.builder().permission("user") | |||
GroupWithPermissionQueryResult result = finder.findGroupsWithPermission(PermissionQuery.builder().permission("user") | |||
.pageIndex(1).membership(PermissionQuery.OUT).build()); | |||
// Anyone group should not be added | |||
assertThat(result.groups()).hasSize(1); | |||
} | |||
@Test | |||
public void find_users_from_permission_template() { | |||
when(permissionTemplateDao.selectTemplateByKey(anyString())).thenReturn(new PermissionTemplateDto().setId(1L).setKee("my_template")); | |||
when(permissionTemplateDao.selectUsers(any(PermissionQuery.class), anyLong(), anyInt(), anyInt())).thenReturn( | |||
newArrayList(new UserWithPermissionDto().setName("user1").setPermission("user")) | |||
); | |||
); | |||
UserWithPermissionQueryResult result = finder.findUsersWithPermissionTemplate(PermissionQuery.builder().permission("user").template("my_template").build()); | |||
assertThat(result.users()).hasSize(1); | |||
@@ -274,7 +281,7 @@ public class PermissionFinderTest { | |||
when(permissionTemplateDao.selectGroups(any(PermissionQuery.class), anyLong())).thenReturn( | |||
newArrayList(new GroupWithPermissionDto().setName("users").setPermission("user")) | |||
); | |||
); | |||
GroupWithPermissionQueryResult result = finder.findGroupsWithPermissionTemplate( | |||
PermissionQuery.builder().permission("user").template("my_template").membership(PermissionQuery.OUT).build()); |
@@ -20,6 +20,7 @@ | |||
package org.sonar.server.qualityprofile; | |||
import java.util.Map; | |||
import org.junit.After; | |||
import org.junit.Test; | |||
import org.sonar.api.profiles.ProfileDefinition; | |||
@@ -33,7 +34,11 @@ import org.sonar.api.server.rule.RuleParamType; | |||
import org.sonar.api.server.rule.RulesDefinition; | |||
import org.sonar.api.utils.ValidationMessages; | |||
import org.sonar.core.persistence.DbSession; | |||
import org.sonar.core.qualityprofile.db.*; | |||
import org.sonar.core.qualityprofile.db.ActiveRuleDto; | |||
import org.sonar.core.qualityprofile.db.ActiveRuleKey; | |||
import org.sonar.core.qualityprofile.db.ActiveRuleParamDto; | |||
import org.sonar.core.qualityprofile.db.QualityProfileDao; | |||
import org.sonar.core.qualityprofile.db.QualityProfileDto; | |||
import org.sonar.core.template.LoadedTemplateDto; | |||
import org.sonar.server.db.DbClient; | |||
import org.sonar.server.platform.Platform; | |||
@@ -41,8 +46,6 @@ import org.sonar.server.qualityprofile.db.ActiveRuleDao; | |||
import org.sonar.server.qualityprofile.index.ActiveRuleIndex; | |||
import org.sonar.server.tester.ServerTester; | |||
import java.util.Map; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -61,7 +61,8 @@ public class DeleteActionTest { | |||
private ComponentDao componentDao; | |||
private Language xoo1, xoo2; | |||
private Language xoo1; | |||
private Language xoo2; | |||
private WsTester tester; | |||
@@ -20,6 +20,8 @@ | |||
package org.sonar.server.qualityprofile.ws; | |||
import com.google.common.collect.Sets; | |||
import java.io.IOException; | |||
import java.io.Writer; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
@@ -40,16 +42,18 @@ import org.sonar.core.qualityprofile.db.QualityProfileDto; | |||
import org.sonar.server.db.DbClient; | |||
import org.sonar.server.exceptions.NotFoundException; | |||
import org.sonar.server.language.LanguageTesting; | |||
import org.sonar.server.qualityprofile.*; | |||
import org.sonar.server.qualityprofile.ActiveRule; | |||
import org.sonar.server.qualityprofile.QProfileBackuper; | |||
import org.sonar.server.qualityprofile.QProfileExporters; | |||
import org.sonar.server.qualityprofile.QProfileFactory; | |||
import org.sonar.server.qualityprofile.QProfileLoader; | |||
import org.sonar.server.qualityprofile.QProfileTesting; | |||
import org.sonar.server.qualityprofile.index.ActiveRuleIndex; | |||
import org.sonar.server.search.IndexClient; | |||
import org.sonar.server.tester.UserSessionRule; | |||
import org.sonar.server.ws.WsTester; | |||
import org.sonar.server.ws.WsTester.Result; | |||
import java.io.IOException; | |||
import java.io.Writer; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.doAnswer; | |||
import static org.mockito.Mockito.mock; |
@@ -64,9 +64,13 @@ public class ProjectsActionTest { | |||
private DbSession session; | |||
private QualityProfileDto xooP1, xooP2; | |||
private QualityProfileDto xooP1; | |||
private QualityProfileDto xooP2; | |||
private ComponentDto project1, project2, project3, project4; | |||
private ComponentDto project1; | |||
private ComponentDto project2; | |||
private ComponentDto project3; | |||
private ComponentDto project4; | |||
private Long userId = 42L; | |||
@@ -48,7 +48,8 @@ public class QProfilesWsTest { | |||
WebService.Controller controller; | |||
String xoo1Key = "xoo1", xoo2Key = "xoo2"; | |||
String xoo1Key = "xoo1"; | |||
String xoo2Key = "xoo2"; | |||
@Before | |||
public void setUp() { |
@@ -51,7 +51,8 @@ public class RenameActionTest { | |||
private QualityProfileDao qualityProfileDao; | |||
private String xoo1Key = "xoo1", xoo2Key = "xoo2"; | |||
private String xoo1Key = "xoo1"; | |||
private String xoo2Key = "xoo2"; | |||
private WsTester tester; | |||
@@ -52,7 +52,8 @@ public class SearchActionTest { | |||
private QualityProfileDao qualityProfileDao; | |||
private Language xoo1, xoo2; | |||
private Language xoo1; | |||
private Language xoo2; | |||
private WsTester tester; | |||
@@ -54,7 +54,8 @@ public class SetDefaultActionTest { | |||
private QualityProfileDao qualityProfileDao; | |||
private String xoo1Key = "xoo1", xoo2Key = "xoo2"; | |||
private String xoo1Key = "xoo1"; | |||
private String xoo2Key = "xoo2"; | |||
private WsTester tester; | |||
@@ -68,7 +68,8 @@ public class RuleUpdaterMediumTest { | |||
DbSession dbSession; | |||
BaseIndex<Rule, RuleDto, RuleKey> ruleIndex = tester.get(RuleIndex.class); | |||
RuleUpdater updater = tester.get(RuleUpdater.class); | |||
int softReliabilityId, hardReliabilityId; | |||
int softReliabilityId; | |||
int hardReliabilityId; | |||
@Before | |||
public void before() { |
@@ -72,7 +72,8 @@ public class RulesWsMediumTest { | |||
RulesWs ws; | |||
RuleDao ruleDao; | |||
DbSession session; | |||
int softReliabilityId, hardReliabilityId; | |||
int softReliabilityId; | |||
int hardReliabilityId; | |||
@Before | |||
public void setUp() { |
@@ -20,13 +20,24 @@ | |||
package org.sonar.server.tester; | |||
import com.google.common.collect.Maps; | |||
import javax.servlet.*; | |||
import javax.servlet.descriptor.JspConfigDescriptor; | |||
import java.io.InputStream; | |||
import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import java.util.*; | |||
import java.util.Collections; | |||
import java.util.Enumeration; | |||
import java.util.EventListener; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import javax.servlet.Filter; | |||
import javax.servlet.FilterRegistration; | |||
import javax.servlet.RequestDispatcher; | |||
import javax.servlet.Servlet; | |||
import javax.servlet.ServletContext; | |||
import javax.servlet.ServletException; | |||
import javax.servlet.ServletRegistration; | |||
import javax.servlet.SessionCookieConfig; | |||
import javax.servlet.SessionTrackingMode; | |||
import javax.servlet.descriptor.JspConfigDescriptor; | |||
/** | |||
* A dummy implementation of {@link ServletContext} which only implements the attribute related methods. All other |
@@ -20,14 +20,20 @@ | |||
package org.sonar.server.tester; | |||
import com.google.common.collect.ImmutableSet; | |||
import org.junit.Test; | |||
import javax.servlet.*; | |||
import java.io.IOException; | |||
import java.util.Collections; | |||
import java.util.Enumeration; | |||
import java.util.EventListener; | |||
import javax.servlet.Filter; | |||
import javax.servlet.FilterChain; | |||
import javax.servlet.FilterConfig; | |||
import javax.servlet.Servlet; | |||
import javax.servlet.ServletConfig; | |||
import javax.servlet.ServletException; | |||
import javax.servlet.ServletRequest; | |||
import javax.servlet.ServletResponse; | |||
import javax.servlet.SessionTrackingMode; | |||
import org.junit.Test; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -23,11 +23,21 @@ package org.sonar.server.user; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.mockito.ArgumentCaptor; | |||
import org.sonar.core.user.*; | |||
import org.sonar.core.user.GroupMembership; | |||
import org.sonar.core.user.GroupMembershipDao; | |||
import org.sonar.core.user.GroupMembershipDto; | |||
import org.sonar.core.user.GroupMembershipQuery; | |||
import org.sonar.core.user.UserDao; | |||
import org.sonar.core.user.UserDto; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.*; | |||
import static org.mockito.Mockito.anyInt; | |||
import static org.mockito.Mockito.anyLong; | |||
import static org.mockito.Mockito.eq; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.verify; | |||
import static org.mockito.Mockito.when; | |||
public class GroupMembershipFinderTest { | |||
@@ -46,7 +56,7 @@ public class GroupMembershipFinderTest { | |||
GroupMembershipQuery query = GroupMembershipQuery.builder().login("arthur").build(); | |||
when(groupMembershipDao.selectGroups(eq(query), anyLong(), anyInt(), anyInt())).thenReturn( | |||
newArrayList(new GroupMembershipDto().setId(1L).setName("users").setDescription("Users group").setUserId(100L)) | |||
); | |||
); | |||
GroupMembershipFinder.Membership result = finder.find(query); | |||
assertThat(result.groups()).hasSize(1); | |||
@@ -79,7 +89,7 @@ public class GroupMembershipFinderTest { | |||
new GroupMembershipDto().setId(1L).setName("group1"), | |||
new GroupMembershipDto().setId(2L).setName("group2"), | |||
new GroupMembershipDto().setId(3L).setName("group3")) | |||
); | |||
); | |||
GroupMembershipFinder.Membership result = finder.find(query); | |||
ArgumentCaptor<Integer> argumentOffset = ArgumentCaptor.forClass(Integer.class); | |||
@@ -99,7 +109,7 @@ public class GroupMembershipFinderTest { | |||
new GroupMembershipDto().setId(2L).setName("group2"), | |||
new GroupMembershipDto().setId(3L).setName("group3"), | |||
new GroupMembershipDto().setId(4L).setName("group4")) | |||
); | |||
); | |||
GroupMembershipFinder.Membership result = finder.find(query); | |||
ArgumentCaptor<Integer> argumentOffset = ArgumentCaptor.forClass(Integer.class); |
@@ -206,7 +206,8 @@ public class CloseableIteratorTest { | |||
} | |||
static class RemovableCloseableIterator extends CloseableIterator { | |||
boolean isClosed = false, isRemoved = false; | |||
boolean isClosed = false; | |||
boolean isRemoved = false; | |||
@Override | |||
protected Object doNext() { |
@@ -40,7 +40,10 @@ public class PropsBuilderTest { | |||
@Rule | |||
public TemporaryFolder temp = new TemporaryFolder(); | |||
File homeDir, dataDir, webDir, logsDir; | |||
File homeDir; | |||
File dataDir; | |||
File webDir; | |||
File logsDir; | |||
JdbcSettings jdbcSettings = mock(JdbcSettings.class); | |||
@Before |
@@ -26,8 +26,13 @@ import java.util.HashMap; | |||
import java.util.Map; | |||
public class ActiveRule { | |||
private final String repositoryKey, ruleKey, templateRuleKey; | |||
private final String name, severity, internalKey, language; | |||
private final String repositoryKey; | |||
private final String ruleKey; | |||
private final String templateRuleKey; | |||
private final String name; | |||
private final String severity; | |||
private final String internalKey; | |||
private final String language; | |||
private final Map<String, String> params = new HashMap<>(); | |||
public ActiveRule(String repositoryKey, String ruleKey, @Nullable String templateRuleKey, String name, @Nullable String severity, |
@@ -19,12 +19,15 @@ | |||
*/ | |||
package org.sonar.batch.protocol.input; | |||
import org.sonar.batch.protocol.GsonHelper; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Date; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.util.*; | |||
import org.sonar.batch.protocol.GsonHelper; | |||
/** | |||
* Container for all project data going from server to batch. |
@@ -23,7 +23,9 @@ import java.util.Date; | |||
public class QProfile { | |||
private final String key, name, language; | |||
private final String key; | |||
private final String name; | |||
private final String language; | |||
private final Date rulesUpdatedAt; | |||
public QProfile(String key, String name, String language, Date rulesUpdatedAt) { |
@@ -48,7 +48,8 @@ public class BatchPluginPredicate implements Predicate<String> { | |||
private static final String PROPERTY_IS_DEPRECATED_MSG = "Property {0} is deprecated. Please use {1} instead."; | |||
private static final Joiner COMMA_JOINER = Joiner.on(", "); | |||
private final Set<String> whites = newHashSet(), blacks = newHashSet(); | |||
private final Set<String> whites = newHashSet(); | |||
private final Set<String> blacks = newHashSet(); | |||
private final DefaultAnalysisMode mode; | |||
public BatchPluginPredicate(Settings settings, DefaultAnalysisMode mode) { |
@@ -38,7 +38,8 @@ import static org.sonar.api.utils.DateUtils.longToDate; | |||
public class PastSnapshot { | |||
private int index; | |||
private String mode, modeParameter; | |||
private String mode; | |||
private String modeParameter; | |||
private Snapshot projectSnapshot; | |||
private Date targetDate = null; | |||
@@ -19,13 +19,17 @@ | |||
*/ | |||
package org.sonar.batch.profiling; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Comparator; | |||
import java.util.LinkedHashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.api.utils.TimeUtils; | |||
import javax.annotation.Nullable; | |||
import java.util.*; | |||
public abstract class AbstractTimeProfiling { | |||
private final long startTime; |
@@ -20,14 +20,15 @@ | |||
package org.sonar.batch.profiling; | |||
import com.google.common.collect.Maps; | |||
import java.util.HashMap; | |||
import java.util.LinkedHashMap; | |||
import java.util.Map; | |||
import java.util.Map.Entry; | |||
import java.util.Properties; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.api.utils.System2; | |||
import javax.annotation.Nullable; | |||
import java.util.*; | |||
import java.util.Map.Entry; | |||
public class ModuleProfiling extends AbstractTimeProfiling { | |||
private Map<Phase, PhaseProfiling> profilingPerPhase = new HashMap<>(); |
@@ -21,12 +21,28 @@ package org.sonar.batch.profiling; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.Lists; | |||
import java.io.File; | |||
import java.io.FileOutputStream; | |||
import java.util.HashMap; | |||
import java.util.IdentityHashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Properties; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.batch.Decorator; | |||
import org.sonar.api.batch.events.*; | |||
import org.sonar.api.batch.events.DecoratorExecutionHandler; | |||
import org.sonar.api.batch.events.DecoratorsPhaseHandler; | |||
import org.sonar.api.batch.events.InitializerExecutionHandler; | |||
import org.sonar.api.batch.events.InitializersPhaseHandler; | |||
import org.sonar.api.batch.events.PostJobExecutionHandler; | |||
import org.sonar.api.batch.events.PostJobsPhaseHandler; | |||
import org.sonar.api.batch.events.ProjectAnalysisHandler; | |||
import org.sonar.api.batch.events.SensorExecutionHandler; | |||
import org.sonar.api.batch.events.SensorsPhaseHandler; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.api.utils.TimeUtils; | |||
@@ -36,12 +52,6 @@ import org.sonar.batch.phases.event.PersisterExecutionHandler; | |||
import org.sonar.batch.phases.event.PersistersPhaseHandler; | |||
import org.sonar.batch.util.BatchUtils; | |||
import javax.annotation.Nullable; | |||
import java.io.File; | |||
import java.io.FileOutputStream; | |||
import java.util.*; | |||
import static org.sonar.batch.profiling.AbstractTimeProfiling.sortByDescendingTotalTime; | |||
import static org.sonar.batch.profiling.AbstractTimeProfiling.truncate; | |||
@@ -24,7 +24,8 @@ import java.util.Collection; | |||
public final class Language { | |||
private final String key, name; | |||
private final String key; | |||
private final String name; | |||
private final String[] fileSuffixes; | |||
public Language(String key, String name, String... fileSuffixes) { |
@@ -25,7 +25,9 @@ import java.util.Date; | |||
public class QProfile { | |||
private String key, name, language; | |||
private String key; | |||
private String name; | |||
private String language; | |||
private Date rulesUpdatedAt; | |||
public String getKey() { |
@@ -438,7 +438,8 @@ public class ProjectReactorBuilder { | |||
@VisibleForTesting | |||
protected static File[] getLibraries(File baseDir, String pattern) { | |||
final int i = Math.max(pattern.lastIndexOf('/'), pattern.lastIndexOf('\\')); | |||
final String dirPath, filePattern; | |||
final String dirPath; | |||
final String filePattern; | |||
if (i == -1) { | |||
dirPath = "."; | |||
filePattern = pattern; |
@@ -37,7 +37,9 @@ import java.util.List; | |||
@BatchSide | |||
public class ModuleFileSystemInitializer { | |||
private File baseDir, workingDir, buildDir; | |||
private File baseDir; | |||
private File workingDir; | |||
private File buildDir; | |||
private List<File> sourceDirsOrFiles = Lists.newArrayList(); | |||
private List<File> testDirsOrFiles = Lists.newArrayList(); | |||
private List<File> binaryDirs = Lists.newArrayList(); |
@@ -21,18 +21,22 @@ package org.sonar.batch.scan.filesystem; | |||
import com.google.common.collect.Iterables; | |||
import com.google.common.collect.Lists; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.CharEncoding; | |||
import org.sonar.api.batch.fs.FilePredicate; | |||
import org.sonar.api.resources.*; | |||
import org.sonar.api.scan.filesystem.PathResolver; | |||
import org.sonar.api.utils.SonarException; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.nio.charset.Charset; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import org.apache.commons.io.FileUtils; | |||
import org.apache.commons.lang.CharEncoding; | |||
import org.sonar.api.batch.fs.FilePredicate; | |||
import org.sonar.api.resources.InputFile; | |||
import org.sonar.api.resources.Java; | |||
import org.sonar.api.resources.Language; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.api.resources.ProjectFileSystem; | |||
import org.sonar.api.resources.Resource; | |||
import org.sonar.api.scan.filesystem.PathResolver; | |||
import org.sonar.api.utils.SonarException; | |||
/** | |||
* Adapter for keeping the backward-compatibility of the deprecated component {@link org.sonar.api.resources.ProjectFileSystem} |
@@ -61,7 +61,8 @@ public class BatchExtensionDictionnaryTest { | |||
@Test | |||
public void testGetFilteredExtensionWithExtensionMatcher() { | |||
final Sensor sensor1 = new FakeSensor(), sensor2 = new FakeSensor(); | |||
final Sensor sensor1 = new FakeSensor(); | |||
final Sensor sensor2 = new FakeSensor(); | |||
BatchExtensionDictionnary selector = newSelector(sensor1, sensor2); | |||
Collection<Sensor> sensors = selector.select(Sensor.class, null, true, new ExtensionMatcher() { | |||
@@ -77,7 +78,8 @@ public class BatchExtensionDictionnaryTest { | |||
@Test | |||
public void testGetFilteredExtensions() { | |||
Sensor sensor1 = new FakeSensor(), sensor2 = new FakeSensor(); | |||
Sensor sensor1 = new FakeSensor(); | |||
Sensor sensor2 = new FakeSensor(); | |||
Decorator decorator = mock(Decorator.class); | |||
BatchExtensionDictionnary selector = newSelector(sensor1, sensor2, decorator); |
@@ -31,7 +31,8 @@ import java.util.List; | |||
public class Transition { | |||
private final String key; | |||
private final String from, to; | |||
private final String from; | |||
private final String to; | |||
private final Condition[] conditions; | |||
private final Function[] functions; | |||
private final boolean automatic; | |||
@@ -125,7 +126,8 @@ public class Transition { | |||
public static class TransitionBuilder { | |||
private final String key; | |||
private String from, to; | |||
private String from; | |||
private String to; | |||
private List<Condition> conditions = Lists.newArrayList(); | |||
private List<Function> functions = Lists.newArrayList(); | |||
private boolean automatic = false; |
@@ -19,10 +19,13 @@ | |||
*/ | |||
package org.sonar.core.persistence.migration.v45; | |||
import org.apache.ibatis.annotations.*; | |||
import java.util.Date; | |||
import java.util.List; | |||
import org.apache.ibatis.annotations.Insert; | |||
import org.apache.ibatis.annotations.Options; | |||
import org.apache.ibatis.annotations.Param; | |||
import org.apache.ibatis.annotations.Result; | |||
import org.apache.ibatis.annotations.Select; | |||
public interface Migration45Mapper { | |||
@@ -20,10 +20,13 @@ | |||
package org.sonar.core.persistence.migration.v50; | |||
import org.apache.ibatis.annotations.*; | |||
import org.apache.ibatis.mapping.ResultSetType; | |||
import java.util.List; | |||
import org.apache.ibatis.annotations.Options; | |||
import org.apache.ibatis.annotations.Param; | |||
import org.apache.ibatis.annotations.Result; | |||
import org.apache.ibatis.annotations.Select; | |||
import org.apache.ibatis.annotations.Update; | |||
import org.apache.ibatis.mapping.ResultSetType; | |||
public interface Migration50Mapper { | |||
@@ -41,7 +41,8 @@ import org.sonar.api.utils.log.Profiler; | |||
public class ComponentContainer { | |||
// no need for multiple children | |||
ComponentContainer parent, child; | |||
ComponentContainer parent; | |||
ComponentContainer child; | |||
MutablePicoContainer pico; | |||
PropertyDefinitions propertyDefinitions; | |||
ComponentKeys componentKeys; |
@@ -21,12 +21,14 @@ package org.sonar.core.qualitygate.db; | |||
import com.google.common.collect.ImmutableList; | |||
import com.google.common.collect.ImmutableMap; | |||
import org.sonar.api.measures.Metric.ValueType; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.Map; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.util.*; | |||
import org.sonar.api.measures.Metric.ValueType; | |||
/** | |||
* @since 4.3 | |||
@@ -46,39 +48,39 @@ public class QualityGateConditionDto { | |||
OPERATOR_GREATER_THAN, | |||
OPERATOR_EQUALS, | |||
OPERATOR_NOT_EQUALS | |||
); | |||
); | |||
private static final List<String> NUMERIC_OPERATORS = ImmutableList.of( | |||
OPERATOR_LESS_THAN, | |||
OPERATOR_GREATER_THAN, | |||
OPERATOR_EQUALS, | |||
OPERATOR_NOT_EQUALS | |||
); | |||
OPERATOR_LESS_THAN, | |||
OPERATOR_GREATER_THAN, | |||
OPERATOR_EQUALS, | |||
OPERATOR_NOT_EQUALS | |||
); | |||
private static final List<String> STRING_OPERATORS = ImmutableList.of( | |||
OPERATOR_EQUALS, | |||
OPERATOR_NOT_EQUALS, | |||
OPERATOR_LESS_THAN, | |||
OPERATOR_GREATER_THAN | |||
); | |||
OPERATOR_EQUALS, | |||
OPERATOR_NOT_EQUALS, | |||
OPERATOR_LESS_THAN, | |||
OPERATOR_GREATER_THAN | |||
); | |||
private static final List<String> LEVEL_OPERATORS = ImmutableList.of( | |||
OPERATOR_EQUALS, | |||
OPERATOR_NOT_EQUALS | |||
); | |||
); | |||
private static final List<String> BOOLEAN_OPERATORS = ImmutableList.of( | |||
OPERATOR_EQUALS | |||
); | |||
); | |||
private static final Map<ValueType, List<String>> OPERATORS_BY_TYPE = ImmutableMap.<ValueType, List<String>>builder() | |||
.put(ValueType.BOOL, BOOLEAN_OPERATORS) | |||
.put(ValueType.LEVEL, LEVEL_OPERATORS) | |||
.put(ValueType.STRING, STRING_OPERATORS) | |||
.put(ValueType.INT, NUMERIC_OPERATORS) | |||
.put(ValueType.FLOAT, NUMERIC_OPERATORS) | |||
.put(ValueType.PERCENT, NUMERIC_OPERATORS) | |||
.put(ValueType.MILLISEC, NUMERIC_OPERATORS) | |||
.put(ValueType.RATING, NUMERIC_OPERATORS) | |||
.put(ValueType.WORK_DUR, NUMERIC_OPERATORS) | |||
.build(); | |||
.put(ValueType.BOOL, BOOLEAN_OPERATORS) | |||
.put(ValueType.LEVEL, LEVEL_OPERATORS) | |||
.put(ValueType.STRING, STRING_OPERATORS) | |||
.put(ValueType.INT, NUMERIC_OPERATORS) | |||
.put(ValueType.FLOAT, NUMERIC_OPERATORS) | |||
.put(ValueType.PERCENT, NUMERIC_OPERATORS) | |||
.put(ValueType.MILLISEC, NUMERIC_OPERATORS) | |||
.put(ValueType.RATING, NUMERIC_OPERATORS) | |||
.put(ValueType.WORK_DUR, NUMERIC_OPERATORS) | |||
.build(); | |||
private long id; | |||
@@ -19,6 +19,13 @@ | |||
*/ | |||
package org.sonar.core.rule; | |||
import java.util.Arrays; | |||
import java.util.Date; | |||
import java.util.HashSet; | |||
import java.util.Set; | |||
import java.util.TreeSet; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.apache.commons.lang.builder.EqualsBuilder; | |||
import org.apache.commons.lang.builder.HashCodeBuilder; | |||
@@ -28,11 +35,6 @@ import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.rule.RuleStatus; | |||
import org.sonar.core.persistence.Dto; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.util.*; | |||
public class RuleDto extends Dto<RuleKey> { | |||
public static final Integer DISABLED_CHARACTERISTIC_ID = -1; |
@@ -31,7 +31,9 @@ import javax.annotation.Nullable; | |||
* @since 3.6 | |||
*/ | |||
public class DefaultUser implements User { | |||
private String login, name, email; | |||
private String login; | |||
private String name; | |||
private String email; | |||
private boolean active; | |||
@Override |
@@ -37,7 +37,7 @@ import javax.net.ssl.X509TrustManager; | |||
*/ | |||
class HttpsTrust { | |||
static HttpsTrust INSTANCE = new HttpsTrust(new Ssl()); | |||
static final HttpsTrust INSTANCE = new HttpsTrust(new Ssl()); | |||
static class Ssl { | |||
SSLSocketFactory newFactory(TrustManager... managers) throws NoSuchAlgorithmException, KeyManagementException { |
@@ -21,14 +21,17 @@ package org.sonar.jpa.session; | |||
import com.google.common.annotations.VisibleForTesting; | |||
import com.google.common.collect.Maps; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.database.DatabaseSession; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import javax.persistence.EntityManager; | |||
import javax.persistence.NonUniqueResultException; | |||
import javax.persistence.PersistenceException; | |||
import javax.persistence.Query; | |||
import java.util.*; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.database.DatabaseSession; | |||
public class JpaDatabaseSession extends DatabaseSession { | |||
@@ -239,7 +242,7 @@ public class JpaDatabaseSession extends DatabaseSession { | |||
} catch (NonUniqueResultException ex) { | |||
NonUniqueResultException e = new NonUniqueResultException("Expected single result for entitiy " + entityClass.getSimpleName() | |||
+ " with criterias : " + StringUtils.join(criterias, ",")); | |||
+ " with criterias : " + StringUtils.join(criterias, ",")); | |||
throw (NonUniqueResultException) e.initCause(ex); | |||
} | |||
} |
@@ -322,7 +322,8 @@ public class ComponentContainerTest { | |||
} | |||
public static class StartableComponent { | |||
public boolean started = false, stopped = false; | |||
public boolean started = false; | |||
public boolean stopped = false; | |||
public void start() { | |||
started = true; | |||
@@ -377,7 +378,9 @@ public class ComponentContainerTest { | |||
} | |||
public static class StartableCloseableComponent implements AutoCloseable { | |||
public boolean isClosed = false, isStopped = false, isClosedAfterStop = false; | |||
public boolean isClosed = false; | |||
public boolean isStopped = false; | |||
public boolean isClosedAfterStop = false; | |||
public void stop() { | |||
isStopped = true; |
@@ -112,7 +112,9 @@ public class PluginLoaderTest { | |||
*/ | |||
@Test | |||
public void test_plugins_sharing_the_same_classloader() throws Exception { | |||
File baseJarFile = temp.newFile(), extensionJar1 = temp.newFile(), extensionJar2 = temp.newFile(); | |||
File baseJarFile = temp.newFile(); | |||
File extensionJar1 = temp.newFile(); | |||
File extensionJar2 = temp.newFile(); | |||
PluginInfo base = new PluginInfo("foo") | |||
.setJarFile(baseJarFile) | |||
.setMainClass("org.foo.FooPlugin") |
@@ -34,7 +34,8 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
public class AuthorizationDaoTest extends AbstractDaoTestCase { | |||
private static final int USER = 100; | |||
private static final Long PROJECT_ID = 300L, PROJECT_ID_WITHOUT_SNAPSHOT = 400L; | |||
private static final Long PROJECT_ID = 300L; | |||
private static final Long PROJECT_ID_WITHOUT_SNAPSHOT = 400L; | |||
private static final String PROJECT = "pj-w-snapshot"; | |||
private static final String PROJECT_WIHOUT_SNAPSHOT = "pj-wo-snapshot"; | |||
@@ -55,7 +55,8 @@ public final class ContainsInComparator implements Comparator<ClonePart> { | |||
} | |||
}; | |||
private final int l1, l2; | |||
private final int l1; | |||
private final int l2; | |||
/** | |||
* Constructs new comparator for two parts with lengths {@code l1} and {@code l2} respectively. |
@@ -45,7 +45,8 @@ public final class Node { | |||
*/ | |||
int depth; | |||
int startSize, endSize; | |||
int startSize; | |||
int endSize; | |||
public Node(Node node, Node suffixNode) { | |||
this(node.suffixTree, suffixNode); |
@@ -34,7 +34,8 @@ public class FileCache { | |||
/** Maximum loop count when creating temp directories. */ | |||
private static final int TEMP_DIR_ATTEMPTS = 10000; | |||
private final File dir, tmpDir; | |||
private final File dir; | |||
private final File tmpDir; | |||
private final FileHashes hashes; | |||
private final Logger logger; | |||
@@ -19,17 +19,19 @@ | |||
*/ | |||
package org.sonar.api.batch.bootstrap; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Map.Entry; | |||
import java.util.Properties; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.lang.ObjectUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.CoreProperties; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.io.File; | |||
import java.util.*; | |||
import java.util.Map.Entry; | |||
/** | |||
* Defines project metadata (key, name, source directories, ...). It's generally used by the | |||
* {@link org.sonar.api.batch.bootstrap.ProjectBuilder extension point} and must not be used |
@@ -31,7 +31,10 @@ import java.util.Map; | |||
public class DefaultActiveRule implements ActiveRule { | |||
private final RuleKey ruleKey; | |||
private final String name; | |||
private final String severity, internalKey, language, templateRuleKey; | |||
private final String severity; | |||
private final String internalKey; | |||
private final String language; | |||
private final String templateRuleKey; | |||
private final Map<String, String> params; | |||
DefaultActiveRule(NewActiveRule newActiveRule) { |
@@ -36,7 +36,9 @@ public class NewActiveRule { | |||
String name; | |||
String severity = Severity.defaultSeverity(); | |||
Map<String, String> params = new HashMap<>(); | |||
String internalKey, language, templateRuleKey; | |||
String internalKey; | |||
String language; | |||
String templateRuleKey; | |||
private final ActiveRulesBuilder builder; | |||
NewActiveRule(ActiveRulesBuilder builder, RuleKey ruleKey) { |
@@ -37,7 +37,9 @@ public class DefaultCoverage extends DefaultStorable implements NewCoverage { | |||
private DefaultInputFile inputFile; | |||
private CoverageType type; | |||
private int totalCoveredLines = 0, totalConditions = 0, totalCoveredConditions = 0; | |||
private int totalCoveredLines = 0; | |||
private int totalConditions = 0; | |||
private int totalCoveredConditions = 0; | |||
private SortedMap<Integer, Integer> hitsByLine = Maps.newTreeMap(); | |||
private SortedMap<Integer, Integer> conditionsByLine = Maps.newTreeMap(); | |||
private SortedMap<Integer, Integer> coveredConditionsByLine = Maps.newTreeMap(); |
@@ -20,11 +20,15 @@ | |||
package org.sonar.api.measures; | |||
import com.google.common.collect.Maps; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import java.util.SortedMap; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.utils.KeyValueFormat; | |||
import java.util.*; | |||
/** | |||
* @since 2.7 | |||
* @deprecated since 5.2 use {@link SensorContext#newCoverage()} |
@@ -120,7 +120,8 @@ public class XMLProfileParser { | |||
while (rulesCursor.getNext() != null) { | |||
SMInputCursor ruleCursor = rulesCursor.childElementCursor(); | |||
String repositoryKey = null, key = null; | |||
String repositoryKey = null; | |||
String key = null; | |||
RulePriority priority = null; | |||
parameters.clear(); | |||
@@ -32,7 +32,8 @@ import java.io.Serializable; | |||
public class RuleKey implements Serializable { | |||
public static final String MANUAL_REPOSITORY_KEY = "manual"; | |||
private final String repository, rule; | |||
private final String repository; | |||
private final String rule; | |||
protected RuleKey(String repositoryKey, String ruleKey) { | |||
this.repository = repositoryKey; |
@@ -33,7 +33,8 @@ import javax.annotation.Nullable; | |||
*/ | |||
class DefaultDebtRemediationFunctions implements RulesDefinition.DebtRemediationFunctions { | |||
private final String repoKey, key; | |||
private final String repoKey; | |||
private final String key; | |||
DefaultDebtRemediationFunctions(String repoKey, String key) { | |||
this.repoKey = repoKey; |
@@ -505,7 +505,9 @@ public interface RulesDefinition { | |||
@Immutable | |||
class RepositoryImpl implements Repository { | |||
private final String key, language, name; | |||
private final String key; | |||
private final String language; | |||
private final String name; | |||
private final Map<String, Rule> rulesByKey; | |||
private RepositoryImpl(NewRepositoryImpl newRepository) { | |||
@@ -576,8 +578,13 @@ public interface RulesDefinition { | |||
} | |||
class NewRule { | |||
private final String repoKey, key; | |||
private String name, htmlDescription, markdownDescription, internalKey, severity = Severity.MAJOR; | |||
private final String repoKey; | |||
private final String key; | |||
private String name; | |||
private String htmlDescription; | |||
private String markdownDescription; | |||
private String internalKey; | |||
private String severity = Severity.MAJOR; | |||
private boolean template; | |||
private RuleStatus status = RuleStatus.defaultStatus(); | |||
private String debtSubCharacteristic; | |||
@@ -787,7 +794,13 @@ public interface RulesDefinition { | |||
@Immutable | |||
class Rule { | |||
private final Repository repository; | |||
private final String repoKey, key, name, htmlDescription, markdownDescription, internalKey, severity; | |||
private final String repoKey; | |||
private final String key; | |||
private final String name; | |||
private final String htmlDescription; | |||
private final String markdownDescription; | |||
private final String internalKey; | |||
private final String severity; | |||
private final boolean template; | |||
private final String debtSubCharacteristic; | |||
private final DebtRemediationFunction debtRemediationFunction; | |||
@@ -915,7 +928,9 @@ public interface RulesDefinition { | |||
class NewParam { | |||
private final String key; | |||
private String name, description, defaultValue; | |||
private String name; | |||
private String description; | |||
private String defaultValue; | |||
private RuleParamType type = RuleParamType.STRING; | |||
private NewParam(String key) { | |||
@@ -956,7 +971,10 @@ public interface RulesDefinition { | |||
@Immutable | |||
class Param { | |||
private final String key, name, description, defaultValue; | |||
private final String key; | |||
private final String name; | |||
private final String description; | |||
private final String defaultValue; | |||
private final RuleParamType type; | |||
private Param(NewParam newParam) { |
@@ -123,7 +123,12 @@ public class RulesDefinitionXmlLoader { | |||
} | |||
private void processRule(RulesDefinition.NewRepository repo, SMInputCursor ruleC) throws XMLStreamException { | |||
String key = null, name = null, description = null, internalKey = null, severity = Severity.defaultSeverity(), status = null; | |||
String key = null; | |||
String name = null; | |||
String description = null; | |||
String internalKey = null; | |||
String severity = Severity.defaultSeverity(); | |||
String status = null; | |||
Cardinality cardinality = Cardinality.SINGLE; | |||
List<ParamStruct> params = new ArrayList<>(); | |||
List<String> tags = new ArrayList<>(); | |||
@@ -197,7 +202,9 @@ public class RulesDefinitionXmlLoader { | |||
} | |||
private static class ParamStruct { | |||
String key, description, defaultValue; | |||
String key; | |||
String description; | |||
String defaultValue; | |||
RuleParamType type = RuleParamType.STRING; | |||
} | |||