Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/_static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
cache: "maven"

- name: Check Code Style
run: mvn --update-snapshots --no-transfer-progress spotless:check
run: mvn --update-snapshots --no-transfer-progress spotless:check pmd:check
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.23.0</version>
<configuration>
<linkXRef>false</linkXRef>
<printFailingErrors>true</printFailingErrors>
<failurePriority>3</failurePriority>
<targetJdk>1.8</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/mindee/geometry/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public boolean equals(Object object) {
Point point = (Point) object;
return this.x.equals(point.x) && this.y.equals(point.y);
}

@Override
public int hashCode() {
return x.hashCode() + y.hashCode();
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/mindee/geometry/Polygon.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ public boolean equals(Object object) {
}
return true;
}

@Override
public int hashCode() {
return coordinates.hashCode();
}
}
8 changes: 4 additions & 4 deletions src/main/java/com/mindee/http/MindeeHttpApiV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public JobResponse reqPostInferenceEnqueue(
InferenceParameters options
) {
String url = this.mindeeSettings.getBaseUrl() + "/inferences/enqueue";
HttpPost post = buildHttpPost(url, options);
HttpPost post = buildHttpPost(url);

MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.EXTENDED);
Expand Down Expand Up @@ -101,7 +101,7 @@ public JobResponse reqPostInferenceEnqueue(
InferenceParameters options
) {
String url = this.mindeeSettings.getBaseUrl() + "/inferences/enqueue";
HttpPost post = buildHttpPost(url, options);
HttpPost post = buildHttpPost(url);

MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.EXTENDED);
Expand All @@ -112,7 +112,7 @@ public JobResponse reqPostInferenceEnqueue(

/**
* Executes an enqueue action, common to URL & local inputs.
*
*
* @param post HTTP Post object.
* @return a valid job response.
*/
Expand Down Expand Up @@ -253,7 +253,7 @@ private HttpEntity buildHttpBody(MultipartEntityBuilder builder, InferenceParame
return builder.build();
}

private HttpPost buildHttpPost(String url, InferenceParameters params) {
private HttpPost buildHttpPost(String url) {
HttpPost post;
try {
URIBuilder uriBuilder = new URIBuilder(url);
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/mindee/input/InputSourceUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ public static String[] splitNameStrict(String filename) throws MindeeException {
* Returns true if the file is a PDF.
*/
public static boolean isPdf(byte[] fileBytes) {
try (
PDDocument document = Loader
.loadPDF(new RandomAccessReadBuffer(new ByteArrayInputStream(fileBytes)))
) {
return true;
try {
Loader.loadPDF(new RandomAccessReadBuffer(new ByteArrayInputStream(fileBytes)));
} catch (IOException e) {
return false;
}
return true;
}

/**
Expand Down
Loading