Skip to content

Commit

Permalink
Quality flaws
Browse files Browse the repository at this point in the history
- do not declare multiple variables on same line
- fix imports
Simon Brandhof committed Jun 29, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fcf0d15 commit 501289c
Showing 107 changed files with 655 additions and 329 deletions.
Original file line number Diff line number Diff line change
@@ -142,7 +142,8 @@ public void start_then_stop_gracefully() throws Exception {
@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 void start_then_stop_sequence_of_commands() throws Exception {
@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 void stop_all_processes_if_monitor_shutdowns() throws Exception {
@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 void stop_all_processes_if_one_shutdowns() throws Exception {
@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();
Original file line number Diff line number Diff line change
@@ -71,7 +71,9 @@ Settings build() {

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);
Original file line number Diff line number Diff line change
@@ -86,7 +86,9 @@ public void test_default_hosts() throws Exception {

@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());
Original file line number Diff line number Diff line change
@@ -147,8 +147,11 @@ private void benchmarkQuery(String label, IssueQuery query) {
}

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);
Original file line number Diff line number Diff line change
@@ -20,19 +20,27 @@

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;
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;

/**
Original file line number Diff line number Diff line change
@@ -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 @@ protected BasicStroke getDashedStroke() {

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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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 @@ private void configureColors(String colors) {

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]);
}
}
Original file line number Diff line number Diff line change
@@ -23,7 +23,9 @@
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;
Original file line number Diff line number Diff line change
@@ -35,7 +35,8 @@ public BaseDataChange(Database db) {

@Override
public final void execute() throws SQLException {
Connection readConnection = null, writeConnection = null;
Connection readConnection = null;
Connection writeConnection = null;
try {
readConnection = openConnection();

Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -38,7 +38,8 @@ public static interface Handler {
}

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);

Original file line number Diff line number Diff line change
@@ -178,7 +178,9 @@ private void convert(List<Map<String, Object>> rows, Long[] violationIds) throws
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;
Original file line number Diff line number Diff line change
@@ -96,8 +96,10 @@ public ActiveRule read(Select.Row row) throws SQLException {
}

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 @@ private static class RuleParam {
}

private static class ActiveRule {
final Long id, profileId;
final Long id;
final Long profileId;

ActiveRule(@Nullable Long id, @Nullable Long profileId) {
this.id = id;
Original file line number Diff line number Diff line change
@@ -170,7 +170,8 @@ public int compare(@Nullable Block b1,

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;
Original file line number Diff line number Diff line change
@@ -34,7 +34,9 @@
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;

Original file line number Diff line number Diff line change
@@ -175,7 +175,9 @@ public void build() {
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) {
Original file line number Diff line number Diff line change
@@ -83,7 +83,9 @@ public String toString() {
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";
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -24,7 +24,8 @@

public class IssueChangelogDiffFormat {

private String oldValue, newValue;
private String oldValue;
private String newValue;

public IssueChangelogDiffFormat(@Nullable String oldValue, @Nullable String newValue) {
this.oldValue = oldValue;
Original file line number Diff line number Diff line change
@@ -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.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) {
Original file line number Diff line number Diff line change
@@ -21,10 +21,11 @@

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;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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() {
Loading

0 comments on commit 501289c

Please sign in to comment.