Skip to content

Commit

Permalink
Fix quality flaws
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Brandhof committed Feb 12, 2015
1 parent 9c9ed9f commit 1f52154
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 19 deletions.
Expand Up @@ -36,8 +36,8 @@
import org.sonar.server.db.migrations.SqlStatement; import org.sonar.server.db.migrations.SqlStatement;
import org.sonar.server.source.db.FileSourceDb; import org.sonar.server.source.db.FileSourceDb;


import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;

import java.sql.SQLException; import java.sql.SQLException;
import java.util.Iterator; import java.util.Iterator;


Expand Down Expand Up @@ -154,9 +154,9 @@ private byte[] toBinary(Long fileSourceId, @Nullable String data) {
} }


private static Iterable<Integer> splitIntegers(String s) { private static Iterable<Integer> splitIntegers(String s) {
return Iterables.transform(Splitter.on(',').split(s), new Function<String, Integer>() { return Iterables.transform(Splitter.on(',').omitEmptyStrings().trimResults().split(s), new Function<String, Integer>() {
@Override @Override
public Integer apply(String input) { public Integer apply(@Nonnull String input) {
return Integer.parseInt(input); return Integer.parseInt(input);
} }
}); });
Expand Down
Expand Up @@ -57,7 +57,7 @@ public void before() {


@Test @Test
public void find_by_key() { public void find_by_key() {
Component<?> component = mock(Component.class); Component component = mock(Component.class);
when(resourceDao.findByKey("struts")).thenReturn(component); when(resourceDao.findByKey("struts")).thenReturn(component);


assertThat(service.findByKey("struts")).isEqualTo(component); assertThat(service.findByKey("struts")).isEqualTo(component);
Expand Down
Expand Up @@ -240,7 +240,7 @@ private boolean isResource(File file) {
} }


public void clean() { public void clean() {
for (ClassRealm realm : (Collection<ClassRealm>) world.getRealms()) { for (ClassRealm realm : world.getRealms()) {
try { try {
world.disposeRealm(realm.getId()); world.disposeRealm(realm.getId());
} catch (Exception e) { } catch (Exception e) {
Expand Down
Expand Up @@ -90,7 +90,7 @@ private void hibernateHack(Rule rule) {
Hibernate.initialize(rule.getParams()); Hibernate.initialize(rule.getParams());
} }


protected final Rule doFindById(int ruleId) { private Rule doFindById(int ruleId) {
DatabaseSession session = sessionFactory.getSession(); DatabaseSession session = sessionFactory.getSession();
return session.getSingleResult( return session.getSingleResult(
session.createQuery("FROM " + Rule.class.getSimpleName() + " r WHERE r.id=:id and r.status<>:status") session.createQuery("FROM " + Rule.class.getSimpleName() + " r WHERE r.id=:id and r.status<>:status")
Expand Down
Expand Up @@ -345,7 +345,7 @@ public void should_find_component_by_key() {
setupData("fixture"); setupData("fixture");


assertThat(dao.findByKey("org.struts:struts")).isNotNull(); assertThat(dao.findByKey("org.struts:struts")).isNotNull();
Component<?> component = dao.findByKey("org.struts:struts-core:src/org/struts/RequestContext.java"); Component component = dao.findByKey("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(component).isNotNull(); assertThat(component).isNotNull();
assertThat(component.path()).isEqualTo("src/org/struts/RequestContext.java"); assertThat(component.path()).isEqualTo("src/org/struts/RequestContext.java");
assertThat(dao.findByKey("unknown")).isNull(); assertThat(dao.findByKey("unknown")).isNull();
Expand Down
Expand Up @@ -67,7 +67,7 @@ private void groupByKey(Collection checks) {
} }


@Override @Override
protected Object createCheck(ActiveRule activeRule) { public Object createCheck(ActiveRule activeRule) {
Object object = checksByKey.get(activeRule.getConfigKey()); Object object = checksByKey.get(activeRule.getConfigKey());
if (object != null) { if (object != null) {
return instantiate(activeRule, object); return instantiate(activeRule, object);
Expand Down
Expand Up @@ -34,22 +34,22 @@
*/ */
public class Tokens { public class Tokens {


private List<TokenEntry> tokens = new ArrayList<TokenEntry>(); private List<TokenEntry> entries = new ArrayList<>();


public void add(TokenEntry tokenEntry) { public void add(TokenEntry tokenEntry) {
this.tokens.add(tokenEntry); this.entries.add(tokenEntry);
} }


public Iterator<TokenEntry> iterator() { public Iterator<TokenEntry> iterator() {
return tokens.iterator(); return entries.iterator();
} }


public int size() { public int size() {
return tokens.size(); return entries.size();
} }


public List<TokenEntry> getTokens() { public List<TokenEntry> getTokens() {
return tokens; return entries;
} }


} }
Expand Up @@ -80,7 +80,7 @@ protected List<File> createElements() {
try { try {
List<File> files = Lists.newArrayList(); List<File> files = Lists.newArrayList();
if (pom.getCompileClasspathElements() != null) { if (pom.getCompileClasspathElements() != null) {
for (String classPathString : (List<String>) pom.getCompileClasspathElements()) { for (String classPathString : pom.getCompileClasspathElements()) {
files.add(new File(classPathString)); files.add(new File(classPathString));
} }
} }
Expand Down
Expand Up @@ -21,7 +21,7 @@


import javax.annotation.CheckForNull; import javax.annotation.CheckForNull;


public interface Component<C extends Component> { public interface Component {
String key(); String key();


/** /**
Expand Down
Expand Up @@ -19,7 +19,7 @@
*/ */
package org.sonar.api.component; package org.sonar.api.component;


public interface Module extends Component<Module> { public interface Module extends Component {
String getDescription(); String getDescription();


String getBranch(); String getBranch();
Expand Down
Expand Up @@ -19,6 +19,6 @@
*/ */
package org.sonar.api.component; package org.sonar.api.component;


public interface Perspective<C extends Component<C>> { public interface Perspective<C extends Component> {
C component(); C component();
} }
Expand Up @@ -19,5 +19,5 @@
*/ */
package org.sonar.api.component; package org.sonar.api.component;


public interface SourceFile extends Component<SourceFile> { public interface SourceFile extends Component {
} }
Expand Up @@ -133,7 +133,7 @@ public RulesProfile setVersion(int version) {
} }


/** /**
* @deprecated profile versioning is dropped in 4.4. Always returns -1. * @deprecated profile versioning is dropped in 4.4. Always returns null.
*/ */
@CheckForNull @CheckForNull
@Deprecated @Deprecated
Expand Down

0 comments on commit 1f52154

Please sign in to comment.