Skip to content

Commit

Permalink
run error-prone on examples + eliminate unnecessary temp (#183)
Browse files Browse the repository at this point in the history
* run error-prone on examples + eliminate unnecessary temp

* fix curl

* use https
  • Loading branch information
danielnorberg committed Oct 20, 2021
1 parent 7bec81c commit f8d0a88
Show file tree
Hide file tree
Showing 37 changed files with 101 additions and 58 deletions.
103 changes: 86 additions & 17 deletions example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,96 @@
<maven.compiler.release>8</maven.compiler.release>
</properties>
</profile>
<profile>
<id>jdk16-</id>
<activation>
<jdk>(,17)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
<encoding>UTF-8</encoding>
<compilerArgs>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
<arg>-Xlint:all</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.9.0</version>
</path>
<path>
<groupId>io.norberg</groupId>
<artifactId>auto-matter</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jdk17+</id>
<activation>
<jdk>[17,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
<encoding>UTF-8</encoding>
<fork>true</fork>
<compilerArgs>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
<arg>-Xlint:all</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.9.0</version>
</path>
<path>
<groupId>io.norberg</groupId>
<artifactId>auto-matter</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</profile>

</profiles>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerArgs>
<compilerArg>-Xlint:all</compilerArg>
<compilerArg>-Xlint:-processing</compilerArg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand All @@ -60,12 +135,6 @@
</build>

<dependencies>
<dependency>
<groupId>io.norberg</groupId>
<artifactId>auto-matter</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.norberg</groupId>
<artifactId>auto-matter-jackson</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jackson-it.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -e

function lookup_jackson_versions0() {
curl -v -s 'http://search.maven.org/solrsearch/select?q=g:%22com.fasterxml.jackson.core%22+AND+a:%22jackson-databind%22&core=gav&rows=1000&wt=json' |
curl -v -L -s 'https://search.maven.org/solrsearch/select?q=g:%22com.fasterxml.jackson.core%22+AND+a:%22jackson-databind%22&core=gav&rows=1000&wt=json' |
jq -r '[.response.docs | .[].v |
{p: split("."), v:.} |
{major:.p[0] | tonumber, minor: .p[1] | tonumber, v:.v} |
Expand Down
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
</plugins>
</build>
</profile>
<profile>

</profile>
</profiles>

<modules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static javax.lang.model.element.Modifier.STATIC;
import static javax.lang.model.type.TypeKind.ARRAY;
import static javax.lang.model.type.TypeKind.DECLARED;
import static javax.lang.model.type.TypeKind.DOUBLE;
import static javax.tools.Diagnostic.Kind.ERROR;

import com.google.auto.service.AutoService;
Expand Down Expand Up @@ -1180,8 +1181,16 @@ private MethodSpec valueHashCode(final Descriptor d) throws AutoMatterProcessorE
.addAnnotation(Override.class)
.addModifiers(PUBLIC)
.returns(TypeName.INT)
.addStatement("int result = 1")
.addStatement("long temp");
.addStatement("int result = 1");

boolean needsTemp =
d.fields().stream()
.map(ExecutableElement::getReturnType)
.map(TypeMirror::getKind)
.anyMatch(DOUBLE::equals);
if (needsTemp) {
hashcode.addStatement("long temp");
}

for (ExecutableElement field : d.fields()) {
final String name = "this." + fieldName(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.strings != null ? this.strings.hashCode() : 0);
result = 31 * result + (this.integers != null ? this.integers.hashCode() : 0);
result = 31 * result + (this.sortedIntegers != null ? this.sortedIntegers.hashCode() : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.strings != null ? this.strings.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;

result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foos != null ? this.foos.hashCode() : 0);
result = 31 * result + (this.bars != null ? this.bars.hashCode() : 0);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
result = 31 * result + (this.bar != null ? this.bar.hashCode() : 0);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
result = 31 * result + (this.bar != null ? this.bar.hashCode() : 0);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.field1 != null ? this.field1.hashCode() : 0);
result = 31 * result + (this.field2 != null ? this.field2.hashCode() : 0);
result = 31 * result + (this.field3 != null ? this.field3.hashCode() : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.baz2 != null ? this.baz2.hashCode() : 0);
result = 31 * result + (this.baz3 != null ? this.baz3.hashCode() : 0);
result = 31 * result + (this.mapBaz != null ? this.mapBaz.hashCode() : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.thing != null ? this.thing.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
result = 31 * result + (this.bar != null ? this.bar.hashCode() : 0);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
result = 31 * result + (this.bar != null ? this.bar.hashCode() : 0);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.strings != null ? this.strings.hashCode() : 0);
result = 31 * result + (this.integers != null ? this.integers.hashCode() : 0);
result = 31 * result + (this.numbers != null ? this.numbers.hashCode() : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;

result = 31 * result + (this.nullableFoo != null ? this.nullableFoo.hashCode() : 0);
result = 31 * result + (this.customNullableBar != null ? this.customNullableBar.hashCode() : 0);
result = 31 * result + (this.nonNullQuux != null ? this.nonNullQuux.hashCode() : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;

result = 31 * result + (this.baz != null ? this.baz.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;

result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;

result = 31 * result + (this.userName != null ? this.userName.hashCode() : 0);
result = 31 * result + (this.password != null ? this.password.hashCode() : 0);
result = 31 * result + (this.token != null ? this.token.hashCode() : 0);
Expand Down
1 change: 0 additions & 1 deletion processor/src/test/resources/expected/TopLevelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foo != null ? this.foo.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + (this.foos != null ? this.foos.hashCode() : 0);
result = 31 * result + (this.oneParameterizedBar != null ? this.oneParameterizedBar.hashCode() : 0);
result = 31 * result + (this.oneIntegerBar != null ? this.oneIntegerBar.hashCode() : 0);
Expand Down

0 comments on commit f8d0a88

Please sign in to comment.