Skip to content

Commit

Permalink
remove unnecessary final on variables or parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Manfred Hanke <[email protected]>
  • Loading branch information
hankem authored and codecholeric committed Nov 21, 2022
1 parent db567e6 commit 736ffb6
Show file tree
Hide file tree
Showing 153 changed files with 397 additions and 402 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class SlicesIsolationTest {
.ignoreDependency(UseCaseOneTwoController.class, UseCaseTwoController.class)
.ignoreDependency(nameMatching(".*controller\\.three.*"), alwaysTrue());

private static DescribedPredicate<Slice> containDescription(final String descriptionPart) {
private static DescribedPredicate<Slice> containDescription(String descriptionPart) {
return new DescribedPredicate<Slice>("contain description '%s'", descriptionPart) {
@Override
public boolean test(Slice input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class SlicesIsolationTest {
.ignoreDependency(UseCaseOneTwoController.class, UseCaseTwoController.class)
.ignoreDependency(nameMatching(".*controller\\.three.*"), alwaysTrue());

private static DescribedPredicate<Slice> containDescription(final String descriptionPart) {
private static DescribedPredicate<Slice> containDescription(String descriptionPart) {
return new DescribedPredicate<Slice>("contain description '%s'", descriptionPart) {
@Override
public boolean test(Slice input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final PersistentObject other = (PersistentObject) obj;
PersistentObject other = (PersistentObject) obj;
return Objects.equals(this.id, other.id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final OtherPersistentObject other = (OtherPersistentObject) obj;
OtherPersistentObject other = (OtherPersistentObject) obj;
return Objects.equals(this.id, other.id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void controllers_should_only_use_their_own_slice_with_custom_ignore() {
.check(classes);
}

private static DescribedPredicate<Slice> containDescription(final String descriptionPart) {
private static DescribedPredicate<Slice> containDescription(String descriptionPart) {
return new DescribedPredicate<Slice>("contain description '%s'", descriptionPart) {
@Override
public boolean test(Slice input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final NewConfigurationEvent other = (NewConfigurationEvent) obj;
NewConfigurationEvent other = (NewConfigurationEvent) obj;
return Objects.equals(this.properties, other.properties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ private static DescribedPredicate<JavaCall<?>> typeIsIllegallyResolvedViaReflect
return classIsResolvedViaReflection().and(not(explicitlyAllowedUsage));
}

private static DescribedPredicate<JavaAccess<?>> contextIsAnnotatedWith(final Class<? extends Annotation> annotationType) {
private static DescribedPredicate<JavaAccess<?>> contextIsAnnotatedWith(Class<? extends Annotation> annotationType) {
return origin(With.owner(withAnnotation(annotationType)));
}

private static DescribedPredicate<JavaClass> withAnnotation(final Class<? extends Annotation> annotationType) {
private static DescribedPredicate<JavaClass> withAnnotation(Class<? extends Annotation> annotationType) {
return new DescribedPredicate<JavaClass>("annotated with @" + annotationType.getName()) {
@Override
public boolean test(JavaClass input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1263,8 +1263,8 @@ Stream<DynamicTest> RestrictNumberOfClassesWithACertainPropertyTest() {

}

private static MessageAssertionChain.Link classesContaining(final Class<?>... classes) {
final String expectedLine = String.format("there is/are %d element(s) in %s", classes.length, formatNamesOf(classes));
private static MessageAssertionChain.Link classesContaining(Class<?>... classes) {
String expectedLine = String.format("there is/are %d element(s) in %s", classes.length, formatNamesOf(classes));
return new MessageAssertionChain.Link() {
@Override
public Result filterMatching(List<String> lines) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void evaluation_results_are_only_dispatched_to_enabled_extensions() {
assertThat(ExampleExtension.getEvaluatedRuleEvents()).isEmpty();
}

private static Condition<Object> containingEntry(final String propKey, final String propValue) {
private static Condition<Object> containingEntry(String propKey, String propValue) {
return new Condition<Object>(String.format("containing entry {%s=%s}", propKey, propValue)) {
@Override
public boolean matches(Object value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public CyclicErrorMatcher by(ExpectedRelation dependency) {

@Override
public MessageAssertionChain.Link.Result filterMatching(List<String> lines) {
final Result.Builder builder = new Result.Builder()
Result.Builder builder = new Result.Builder()
.containsText(cycleText());

for (String sliceName : details.asMap().keySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,39 +80,39 @@ Result evaluate(EvaluationResult evaluationResult) {

private Set<String> evaluateFieldAccesses(EvaluationResult result) {
Set<String> errorMessages = new HashSet<>();
final Set<ExpectedRelation> left = new HashSet<>(this.expectedFieldAccesses);
Set<ExpectedRelation> left = new HashSet<>(this.expectedFieldAccesses);
result.handleViolations((Collection<JavaFieldAccess> violatingObjects, String message) ->
errorMessages.addAll(removeExpectedAccesses(violatingObjects, left)));
return union(errorMessages, errorMessagesFrom(left));
}

private Set<String> evaluateMethodCalls(EvaluationResult result) {
Set<String> errorMessages = new HashSet<>();
final Set<ExpectedRelation> left = new HashSet<>(expectedMethodCalls);
Set<ExpectedRelation> left = new HashSet<>(expectedMethodCalls);
result.handleViolations((Collection<JavaMethodCall> violatingObjects, String message) ->
errorMessages.addAll(removeExpectedAccesses(violatingObjects, left)));
return union(errorMessages, errorMessagesFrom(left));
}

private Set<String> evaluateConstructorCalls(EvaluationResult result) {
Set<String> errorMessages = new HashSet<>();
final Set<ExpectedRelation> left = new HashSet<>(expectedConstructorCalls);
Set<ExpectedRelation> left = new HashSet<>(expectedConstructorCalls);
result.handleViolations((Collection<JavaConstructorCall> violatingObjects, String message) ->
errorMessages.addAll(removeExpectedAccesses(violatingObjects, left)));
return union(errorMessages, errorMessagesFrom(left));
}

private Set<String> evaluateCalls(EvaluationResult result) {
Set<String> errorMessages = new HashSet<>();
final Set<ExpectedRelation> left = new HashSet<>(Sets.union(expectedConstructorCalls, expectedMethodCalls));
Set<ExpectedRelation> left = new HashSet<>(Sets.union(expectedConstructorCalls, expectedMethodCalls));
result.handleViolations((Collection<JavaCall<?>> violatingObjects, String message) ->
errorMessages.addAll(removeExpectedAccesses(violatingObjects, left)));
return union(errorMessages, errorMessagesFrom(left));
}

private Set<String> evaluateAccesses(EvaluationResult result) {
Set<String> errorMessages = new HashSet<>();
final Set<ExpectedRelation> left = new HashSet<ExpectedRelation>() {
Set<ExpectedRelation> left = new HashSet<ExpectedRelation>() {
{
addAll(expectedConstructorCalls);
addAll(expectedMethodCalls);
Expand All @@ -126,7 +126,7 @@ private Set<String> evaluateAccesses(EvaluationResult result) {

private Set<String> evaluateDependencies(EvaluationResult result) {
Set<String> errorMessages = new HashSet<>();
final Set<ExpectedRelation> left = new HashSet<>(expectedDependencies);
Set<ExpectedRelation> left = new HashSet<>(expectedDependencies);
result.handleViolations((Collection<Dependency> violatingObjects, String message) ->
errorMessages.addAll(removeExpectedAccesses(violatingObjects, left)));
return union(errorMessages, errorMessagesFrom(left));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public String toString() {
return links.stream().map(Link::getDescription).collect(joining(lineSeparator()));
}

static Link matchesLine(final String pattern) {
final Pattern p = Pattern.compile(pattern);
static Link matchesLine(String pattern) {
Pattern p = Pattern.compile(pattern);
return new Link() {
@Override
public Result filterMatching(List<String> lines) {
Expand All @@ -61,7 +61,7 @@ public String getDescription() {
}

static Link containsLine(String text, Object... args) {
final String expectedLine = String.format(text, args);
String expectedLine = String.format(text, args);
return new Link() {
@Override
public Result filterMatching(List<String> lines) {
Expand All @@ -79,7 +79,7 @@ public String getDescription() {

static Link containsText(String text, Object... args) {
String expectedText = String.format(text, args);
final List<String> expectedLines = Splitter.on(lineSeparator()).splitToList(expectedText);
List<String> expectedLines = Splitter.on(lineSeparator()).splitToList(expectedText);
return new Link() {
@Override
public Result filterMatching(List<String> lines) {
Expand Down Expand Up @@ -115,10 +115,10 @@ private static String describeLines(List<String> lines) {
return "Lines were >>>>>>>>" + lineSeparator() + Joiner.on(lineSeparator()).join(lines) + lineSeparator() + "<<<<<<<<";
}

static Link containsConsecutiveLines(final List<String> expectedLines) {
static Link containsConsecutiveLines(List<String> expectedLines) {
checkArgument(!expectedLines.isEmpty(), "Asserting zero consecutive lines makes no sense");
final String linesDescription = Joiner.on(lineSeparator()).join(expectedLines);
final String description = "Message contains consecutive lines " + lineSeparator() + linesDescription;
String linesDescription = Joiner.on(lineSeparator()).join(expectedLines);
String description = "Message contains consecutive lines " + lineSeparator() + linesDescription;

return new Link() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static AnalyzeClasses checkAnnotation(Class<?> testClass) {

@Override
public Statement classBlock(RunNotifier notifier) {
final Statement statement = super.classBlock(notifier);
Statement statement = super.classBlock(notifier);
return new Statement() {
@Override
public void evaluate() throws Throwable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private Runnable verifyTestRan() {
}

// extractingResultOf(..) only looks for public methods
private Extractor<Object, Object> resultOf(final String methodName) {
private Extractor<Object, Object> resultOf(String methodName) {
return input -> {
Collection<Method> candidates = getAllMethods(input.getClass(), method -> method.getName().equals(methodName));
checkState(!candidates.isEmpty(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final FieldSelector other = (FieldSelector) obj;
FieldSelector other = (FieldSelector) obj;
return Objects.equals(this.clazz, other.clazz)
&& Objects.equals(this.field, other.field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final FieldSource other = (FieldSource) obj;
FieldSource other = (FieldSource) obj;
return Objects.equals(this.javaClass, other.javaClass)
&& Objects.equals(this.fieldName, other.fieldName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final LocationsKey other = (LocationsKey) obj;
LocationsKey other = (LocationsKey) obj;
return Objects.equals(this.importOptionTypes, other.importOptionTypes)
&& Objects.equals(this.locations, other.locations);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private static <T extends Throwable> void rethrowUnchecked(Throwable throwable)
throw (T) throwable;
}

static Predicate<AnnotatedElement> withAnnotation(final Class<? extends Annotation> annotationType) {
static Predicate<AnnotatedElement> withAnnotation(Class<? extends Annotation> annotationType) {
return input -> input.isAnnotationPresent(annotationType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void concurrent_access() throws Exception {
verifyNoMoreInteractions(classFileImporter);
}

private Runnable repeatGetClassesToAnalyze(final int times) {
private Runnable repeatGetClassesToAnalyze(int times) {
return () -> {
for (int j = 0; j < times; j++) {
cache.getClassesToAnalyzeFor(TEST_CLASSES.get(j % TEST_CLASSES.size()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private void verifyNumberOfImports(int number) {
verifyNoMoreInteractions(cacheClassFileImporter);
}

private static Condition<Iterable<? extends Location>> locationContaining(final String part) {
private static Condition<Iterable<? extends Location>> locationContaining(String part) {
return new Condition<Iterable<? extends Location>>() {
@Override
public boolean matches(Iterable<? extends Location> locations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void getAllFields_of_interface() {
field(OtherInterface.class, "OTHER_CONSTANT"));
}

private Predicate<Member> named(final String name) {
private Predicate<Member> named(String name) {
return input -> input.getName().equals(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

@PublicAPI(usage = INHERITANCE)
public abstract class ChainableFunction<F, T> implements Function<F, T> {
public <E> ChainableFunction<E, T> after(final Function<? super E, ? extends F> function) {
public <E> ChainableFunction<E, T> after(Function<? super E, ? extends F> function) {
return new ChainableFunction<E, T>() {
@Override
public T apply(E input) {
Expand All @@ -32,7 +32,7 @@ public T apply(E input) {
};
}

public <U> ChainableFunction<F, U> then(final Function<? super T, ? extends U> function) {
public <U> ChainableFunction<F, U> then(Function<? super T, ? extends U> function) {
return new ChainableFunction<F, U>() {
@Override
public U apply(F input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private From() {
}

@PublicAPI(usage = ACCESS)
public static <T> DescribedIterable<T> iterable(final Iterable<T> iterable, final String description) {
public static <T> DescribedIterable<T> iterable(Iterable<T> iterable, String description) {
return new DescribedIterable<T>() {
@Override
public String getDescription() {
Expand Down
Loading

0 comments on commit 736ffb6

Please sign in to comment.