Browse Source

Fix some quality flaws

tags/3.7.1-RC1-
Simon Brandhof 10 years ago
parent
commit
9fe28c5e6f

+ 1
- 1
sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java View File

@@ -182,6 +182,6 @@ public class DefaultSensorContext implements SensorContext {
}

private Resource resourceOrProject(Resource resource) {
return (resource != null ? resource : project);
return resource!=null ? resource : project;
}
}

+ 1
- 1
sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsExecutor.java View File

@@ -61,7 +61,7 @@ public class DecoratorsExecutor implements BatchComponent {
DecoratorContext decorateResource(Resource resource, Collection<Decorator> decorators, boolean executeDecorators) {
List<DecoratorContext> childrenContexts = Lists.newArrayList();
for (Resource child : index.getChildren(resource)) {
boolean isModule = (child instanceof Project);
boolean isModule = child instanceof Project;
DefaultDecoratorContext childContext = (DefaultDecoratorContext) decorateResource(child, decorators, !isModule);
childrenContexts.add(childContext.setReadOnly(true));
}

+ 2
- 2
sonar-batch/src/main/java/org/sonar/batch/phases/UpdateStatusJob.java View File

@@ -74,7 +74,7 @@ public class UpdateStatusJob implements BatchComponent {

private void enableCurrentSnapshot() {
Snapshot previousLastSnapshot = resourcePersister.getLastSnapshot(snapshot, false);
boolean isLast = (previousLastSnapshot == null || previousLastSnapshot.getCreatedAt().before(snapshot.getCreatedAt()));
boolean isLast = previousLastSnapshot == null || previousLastSnapshot.getCreatedAt().before(snapshot.getCreatedAt());
setFlags(snapshot, isLast, Snapshot.STATUS_PROCESSED);
logSuccess(LoggerFactory.getLogger(getClass()));
}
@@ -113,7 +113,7 @@ public class UpdateStatusJob implements BatchComponent {
query.setParameter("last", last);
query.setParameter("rootId", snapshot.getId());
query.setParameter("path", snapshot.getPath() + snapshot.getId() + ".%");
query.setParameter("pathRootId", (snapshot.getRootId() == null ? snapshot.getId() : snapshot.getRootId()));
query.setParameter("pathRootId", snapshot.getRootId()==null ? snapshot.getId() : snapshot.getRootId());
query.executeUpdate();
session.commit();


+ 2
- 2
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DeprecatedFileSystemAdapter.java View File

@@ -176,7 +176,7 @@ public class DeprecatedFileSystemAdapter implements ProjectFileSystem {

public File getFileFromBuildDirectory(String filename) {
File file = new File(getBuildDir(), filename);
return (file.exists() ? file : null);
return file.exists() ? file : null;
}

public Resource toResource(File file) {
@@ -187,7 +187,7 @@ public class DeprecatedFileSystemAdapter implements ProjectFileSystem {
if (relativePath == null) {
return null;
}
return (file.isFile() ? new org.sonar.api.resources.File(relativePath.path()) : new org.sonar.api.resources.Directory(relativePath.path()));
return file.isFile() ? new org.sonar.api.resources.File(relativePath.path()) : new org.sonar.api.resources.Directory(relativePath.path());
}

public List<InputFile> mainFiles(String... langs) {

+ 1
- 1
sonar-colorizer/src/main/java/org/sonar/colorizer/CodeColorizer.java View File

@@ -39,7 +39,7 @@ public class CodeColorizer {
}

public String toHtml(Reader code, HtmlOptions options) {
HtmlOptions opts = (options == null ? HtmlOptions.DEFAULT : options);
HtmlOptions opts = options == null ? HtmlOptions.DEFAULT : options;
return new HtmlRenderer(opts).render(code, tokenizers);
}


+ 1
- 1
sonar-colorizer/src/main/java/org/sonar/colorizer/LiteralTokenizer.java View File

@@ -63,7 +63,7 @@ public class LiteralTokenizer extends Tokenizer {

public boolean match(int endFlag) {
literalValue.append((char) endFlag);
return (code.lastChar() == firstChar && evenNumberOfBackSlashBeforeDelimiter() && literalValue.length() > 1);
return code.lastChar()==firstChar && evenNumberOfBackSlashBeforeDelimiter() && literalValue.length()>1;
}

private boolean evenNumberOfBackSlashBeforeDelimiter() {

+ 1
- 1
sonar-core/src/main/java/org/sonar/core/component/ScanGraph.java View File

@@ -55,7 +55,7 @@ public class ScanGraph extends BeanGraph implements BatchComponent {

public ComponentVertex getComponent(String key) {
Vertex vertex = GraphUtil.single(getUnderlyingGraph().getVertices("key", key));
return (vertex != null ? wrapComponent(vertex) : null);
return vertex != null ? wrapComponent(vertex) : null;
}

public ComponentVertex addComponent(Resource resource, @Nullable Snapshot snapshot) {

+ 1
- 1
sonar-core/src/main/java/org/sonar/core/dashboard/ActiveDashboardDao.java View File

@@ -48,7 +48,7 @@ public class ActiveDashboardDao implements BatchComponent, ServerComponent {
ActiveDashboardMapper mapper = session.getMapper(ActiveDashboardMapper.class);
try {
Integer max = mapper.selectMaxOrderIndexForNullUser();
return (max != null ? max.intValue() : 0);
return max != null ? max.intValue() : 0;
} finally {
session.close();
}

+ 0
- 4
sonar-core/src/main/java/org/sonar/core/plugins/RemotePlugin.java View File

@@ -88,10 +88,6 @@ public class RemotePlugin {
return files;
}

public String getPluginFilename() {
return (!files.isEmpty() ? files.get(0).getFilename() : null);
}

@Override
public boolean equals(Object o) {
if (this == o) {

+ 1
- 1
sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java View File

@@ -71,7 +71,7 @@ public class MeasuresDao extends BaseDao {
return CollectionUtils.select(getMetricsByName().values(), new Predicate() {
public boolean evaluate(Object o) {
Metric m = (Metric) o;
return (m.getEnabled() && m.getOrigin() != Metric.Origin.JAV);
return m.getEnabled() && m.getOrigin() != Metric.Origin.JAV;
}
});
}

+ 1
- 1
sonar-duplications/src/main/java/org/sonar/duplications/block/ByteArray.java View File

@@ -96,7 +96,7 @@ public final class ByteArray {
public String toHexString() {
StringBuilder hex = new StringBuilder(2 * bytes.length);
for (byte b : bytes) {
hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F)));
hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt(b & 0x0F));
}
return hex.toString();
}

+ 1
- 1
sonar-plugin-api/src/main/java/org/sonar/api/measures/CountDistributionBuilder.java View File

@@ -106,7 +106,7 @@ public class CountDistributionBuilder implements MeasureBuilder {
Map<String, String> map = KeyValueFormat.parse(measure.getData());
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
int value = (StringUtils.isBlank(entry.getValue()) ? 0 : Integer.parseInt(entry.getValue()));
int value = StringUtils.isBlank(entry.getValue()) ? 0 : Integer.parseInt(entry.getValue());
if (NumberUtils.isNumber(key)) {
add(NumberUtils.toInt(key), value);
} else {

+ 1
- 1
sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasureUtils.java View File

@@ -87,7 +87,7 @@ public final class MeasureUtils {
if (measure != null) {
result = measure.getVariation(periodIndex);
}
return (result != null ? result : defaultValue);
return result != null ? result : defaultValue;
}

public static Long getVariationAsLong(Measure measure, int periodIndex) {

+ 1
- 1
sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java View File

@@ -92,7 +92,7 @@ public class ServerExtensionInstaller {
}

static boolean isType(Object extension, Class<? extends Extension> extensionClass) {
Class clazz = (extension instanceof Class ? (Class) extension : extension.getClass());
Class clazz = extension instanceof Class ? (Class) extension : extension.getClass();
return extensionClass.isAssignableFrom(clazz);
}
}

Loading…
Cancel
Save