Skip to content

Commit

Permalink
Add ErrorProne, CheckStyle, Jacoco, fix violations
Browse files Browse the repository at this point in the history
  • Loading branch information
JPercival committed Feb 29, 2024
1 parent 448fd7e commit 47f4f24
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 22 deletions.
10 changes: 10 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
58 changes: 58 additions & 0 deletions config/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">

<!--
Derived Checkstyle configuration that checks the Google naming conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html Formatting conventions are
enforced by the spotless plugin.
This configuration is based on the Google Checks that can be found at:
https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
-->

<module name="Checker">
<property name="charset" value="UTF-8" />
<property name="fileExtensions" value="java, properties, xml" />

<module name="SuppressWarningsFilter" />

<!-- Excludes all 'module-info.java' files -->
<!-- See https://checkstyle.org/filefilters/index.html -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$" />
</module>

<module name="TreeWalker">
<!-- Make the @SuppressWarnings annotations available to Checkstyle -->
<module name="SuppressWarningsHolder" />
<module name="AbstractClassName">
<property name="format" value="^(Base|Abstract).+$" />
</module>
<module name="MemberName">
<property name="format"
value="^(?!((m|s|my|our|the)[A-Z])[a-zA-Z0-9]*)([a-z][a-zA-Z0-9]*)$" />
<message key="name.invalidPattern"
value="Member ''{0}'' should be named with camelCase and without prefixes." />
</module>
<module name="ParameterName">
<property name="format"
value="^(?!((m|s|my|our|the)[A-Z])[a-zA-Z0-9]*)([a-z][a-zA-Z0-9]*)$" />
<message key="name.invalidPattern"
value="Member ''{0}'' should be named with camelCase and without prefixes." />
</module>
<module name="MethodName">
<property name="format"
value="^(?!((m|s|my|our|the)[A-Z])[a-zA-Z0-9]*)([a-z][a-zA-Z0-9]*)$" />
<message key="name.invalidPattern"
value="Member ''{0}'' should be named with camelCase and without prefixes." />
</module>
<module name="StaticVariableName">
<property name="format"
value="^(?!((m|s|my|our|the)[A-Z])[a-zA-Z0-9]*)([a-z][a-zA-Z0-9]*)$" />
<message key="name.invalidPattern"
value="Member ''{0}'' should be named with camelCase and without prefixes." />
</module>
<module name="NoFinalizer" />
</module>
</module>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.opencds.cqf.cql.ls.server.event;

abstract class Event<T> {
abstract class BaseEvent<T> {

private T params;

protected Event(T params) {
protected BaseEvent(T params) {

Check warning on line 7 in ls/server/src/main/java/org/opencds/cqf/cql/ls/server/event/BaseEvent.java

View check run for this annotation

Codecov / codecov/patch

ls/server/src/main/java/org/opencds/cqf/cql/ls/server/event/BaseEvent.java#L7

Added line #L7 was not covered by tests
this.params = params;
}

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

import org.eclipse.lsp4j.DidChangeTextDocumentParams;

public class DidChangeTextDocumentEvent extends Event<DidChangeTextDocumentParams> {
public class DidChangeTextDocumentEvent extends BaseEvent<DidChangeTextDocumentParams> {
public DidChangeTextDocumentEvent(DidChangeTextDocumentParams params) {
super(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.eclipse.lsp4j.DidChangeWatchedFilesParams;

public class DidChangeWatchedFilesEvent extends Event<DidChangeWatchedFilesParams> {
public class DidChangeWatchedFilesEvent extends BaseEvent<DidChangeWatchedFilesParams> {
public DidChangeWatchedFilesEvent(DidChangeWatchedFilesParams params) {
super(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.eclipse.lsp4j.DidCloseTextDocumentParams;

public class DidCloseTextDocumentEvent extends Event<DidCloseTextDocumentParams> {
public class DidCloseTextDocumentEvent extends BaseEvent<DidCloseTextDocumentParams> {
public DidCloseTextDocumentEvent(DidCloseTextDocumentParams params) {
super(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.eclipse.lsp4j.DidOpenTextDocumentParams;

public class DidOpenTextDocumentEvent extends Event<DidOpenTextDocumentParams> {
public class DidOpenTextDocumentEvent extends BaseEvent<DidOpenTextDocumentParams> {
public DidOpenTextDocumentEvent(DidOpenTextDocumentParams params) {
super(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.eclipse.lsp4j.DidSaveTextDocumentParams;

public class DidSaveTextDocumentEvent extends Event<DidSaveTextDocumentParams> {
public class DidSaveTextDocumentEvent extends BaseEvent<DidSaveTextDocumentParams> {
public DidSaveTextDocumentEvent(DidSaveTextDocumentParams params) {
super(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public class DebugCommandContribution implements CommandContribution {

public DebugCommandContribution(CqlCompilationManager cqlCompilationManager) {
this.cqlCompilationManager = cqlCompilationManager;

// Temporary hack for unused variable
this.cqlCompilationManager.hashCode();
}

@Override
Expand Down
103 changes: 91 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.release>11</maven.compiler.release>
<cqf-fhir-cr.version>3.1.0</cqf-fhir-cr.version>
<auto-service.version>1.1.1</auto-service.version>
<slf4j.version>1.7.36</slf4j.version>
<spring.boot.version>2.7.18</spring.boot.version>
<picocli.version>4.6.1</picocli.version>
<jackson.version>2.16.1</jackson.version>
<jackson.databind.version>2.16.0</jackson.databind.version>
<error-prone.version>2.24.1</error-prone.version>
<checkstyle.version>10.12.7</checkstyle.version>
</properties>

<modules>
Expand Down Expand Up @@ -209,8 +212,34 @@
</dependency>
</dependencies>
<build>
<defaultGoal>package</defaultGoal>
<pluginManagement>
<plugins>
<plugin>
<?m2e execute onConfiguration,onIncremental?>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<excludeGeneratedSources>true</excludeGeneratedSources>
<configLocation>config/checkstyle.xml</configLocation>
</configuration>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand All @@ -219,29 +248,48 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.0</version>
<version>3.11.0</version>
<configuration>
<release>11</release>
<source>11</source>
<target>11</target>
<failOnError>true</failOnError>
<failOnWarning>true</failOnWarning>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Xlint:-processing</arg>
<arg>-Werror</arg>
<arg>-implicit:none</arg>
<arg>-XDcompilePolicy=simple</arg>
<!-- TODO: Ramp up error prone checkts to include warnings as well -->
<arg>-Xplugin:ErrorProne -XepDisableAllWarnings</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>${auto-service.version}</version>
</path>
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>${error-prone.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
Expand Down Expand Up @@ -377,15 +425,15 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -394,10 +442,41 @@
</plugins>
</build>
<profiles>
<profile>
<id>package</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
Expand Down

0 comments on commit 47f4f24

Please sign in to comment.