Skip to content

Commit

Permalink
Add checkstyle
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Stejskal <[email protected]>
  • Loading branch information
Frawless committed Nov 27, 2023
1 parent 9dffd02 commit 4f60668
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 34 deletions.
131 changes: 131 additions & 0 deletions .checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">

<module name="Checker">

<property name="localeLanguage" value="en"/>

<module name="FileTabCharacter"/>

<!-- header -->
<module name="RegexpHeader">
<!--
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
-->
<property name="header" value="^\/\*$\n^\s\*\sCopyright\sSkodjob\sauthors\.$\n^\s\*\sLicense:\sApache\sLicense\s2\.0\s\(see\sthe\sfile\sLICENSE\sor\shttp:\/\/apache\.org\/licenses\/LICENSE-2\.0\.html\)\.$\n^\s\*\/$"/>
<property name="fileExtensions" value="java"/>
</module>

<module name="SuppressWarningsFilter" />
<module name="TreeWalker">
<!-- code cleanup -->
<module name="UnusedImports">
<property name="processJavadoc" value="true" />
</module>
<module name="RedundantImport"/>
<module name="IllegalImport" />
<module name="EqualsHashCode"/>
<module name="SimplifyBooleanExpression"/>
<module name="OneStatementPerLine"/>
<module name="UnnecessaryParentheses" />
<module name="SimplifyBooleanReturn"/>

<!-- style -->
<module name="DefaultComesLast"/>
<module name="EmptyStatement"/>
<module name="ArrayTypeStyle"/>
<module name="UpperEll"/>
<module name="LeftCurly"/>
<module name="RightCurly"/>
<module name="EmptyStatement"/>
<module name="ConstantName">
<property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)"/>
</module>
<module name="LocalVariableName"/>
<module name="LocalFinalVariableName"/>
<module name="MemberName"/>
<module name="ClassTypeParameterName">
<property name="format" value="^[A-Z][a-zA-Z0-9]*$$"/>
</module>
<module name="MethodTypeParameterName">
<property name="format" value="^[A-Z][a-zA-Z0-9]*$$"/>
</module>
<module name="InterfaceTypeParameterName">
<property name="format" value="^[A-Z][a-zA-Z0-9]*$$"/>
</module>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<module name="AvoidStarImport"/>

<!-- whitespace -->
<module name="GenericWhitespace"/>
<module name="NoWhitespaceBefore"/>
<module name="WhitespaceAfter" />
<module name="NoWhitespaceAfter"/>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
</module>
<module name="Indentation"/>
<module name="MethodParamPad"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>

<!-- locale-sensitive methods should specify locale -->
<module name="Regexp">
<property name="format" value="\.to(Lower|Upper)Case\(\)"/>
<property name="illegalPattern" value="true"/>
<property name="ignoreComments" value="true"/>
</module>

<!-- code quality -->
<module name="MethodLength"/>
<module name="ParameterNumber">
<!-- default is 8 -->
<property name="max" value="13"/>
</module>
<module name="ClassDataAbstractionCoupling">
<!-- default is 7 -->
<property name="max" value="20"/>
</module>
<module name="BooleanExpressionComplexity">
<!-- default is 3 -->
<property name="max" value="5"/>
</module>

<module name="ClassFanOutComplexity">
<!-- default is 20 -->
<property name="max" value="44"/>
</module>
<module name="CyclomaticComplexity">
<!-- default is 10-->
<property name="max" value="19"/>
</module>
<module name="JavaNCSS">
<!-- default is 50 -->
<property name="methodMaximum" value="100"/>
</module>
<module name="NPathComplexity">
<!-- default is 200 -->
<property name="max" value="5832"/>
</module>

<module name="IllegalToken">
<property name="tokens" value="LITERAL_ASSERT"/>
</module>

<!-- Make the @SuppressWarnings annotations available to Checkstyle -->
<module name="SuppressWarningsHolder" />
</module>

<!-- Filter out Checkstyle warnings that have been suppressed with the @SuppressWarnings annotation -->
<module name="SuppressWarningsFilter" />
</module>

37 changes: 36 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
<slf4j.version>2.0.9</slf4j.version>
<hamcrest.version>2.2</hamcrest.version>
<opedatahub-crds.version>1.0.6-SNAPSHOT</opedatahub-crds.version>
<checkstyle.version>10.12.5</checkstyle.version>
<maven.checkstyle.version>3.3.1</maven.checkstyle.version>
</properties>

<repositories>
Expand Down Expand Up @@ -204,6 +206,39 @@
</properties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven.checkstyle.version}</version>
<configuration>
<configLocation>.checkstyle/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>.checkstyle/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -240,4 +275,4 @@
</profile>
</profiles>

</project>
</project>
2 changes: 1 addition & 1 deletion src/main/java/io/odh/test/Environment.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Tealc authors.
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/io/odh/test/TestConstants.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/*
* Copyright Tealc authors.
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test;

public class TestConstants {
public static final String ODH_NAMESPACE = "opendatahub";

private TestConstants() {
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/odh/test/framework/ExecutionListener.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Tealc authors.
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.framework;
Expand All @@ -11,7 +11,7 @@
import org.slf4j.LoggerFactory;

public class ExecutionListener implements TestExecutionListener {
Logger LOGGER = LoggerFactory.getLogger(TestSeparator.class);
static final Logger LOGGER = LoggerFactory.getLogger(TestSeparator.class);

public void testPlanExecutionStarted(TestPlan testPlan) {
LOGGER.info("=======================================================================");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Tealc authors.
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.framework;
Expand All @@ -19,4 +19,4 @@ public boolean supportsParameter(ParameterContext parameterContext, ExtensionCon
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
return extensionContext;
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/odh/test/framework/TestSeparator.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Tealc authors.
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.framework;
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/io/odh/test/platform/KubeClient.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Tealc authors.
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.platform;
Expand Down Expand Up @@ -83,18 +83,18 @@ public KubeClient inNamespace(String namespace) {
}

private Config getConfig() {
if (Environment.KUBE_PASSWORD != null &&
Environment.KUBE_PASSWORD != null &&
Environment.KUBE_URL != null) {
if (Environment.KUBE_PASSWORD != null
&& Environment.KUBE_PASSWORD != null
&& Environment.KUBE_URL != null) {
return new ConfigBuilder()
.withUsername(Environment.KUBE_USERNAME)
.withPassword(Environment.KUBE_PASSWORD)
.withMasterUrl(Environment.KUBE_URL)
.withDisableHostnameVerification(true)
.withTrustCerts(true)
.build();
} else if (Environment.KUBE_URL != null &&
Environment.KUBE_TOKEN != null) {
} else if (Environment.KUBE_URL != null
&& Environment.KUBE_TOKEN != null) {
return new ConfigBuilder()
.withOauthToken(Environment.KUBE_TOKEN)
.withMasterUrl(Environment.KUBE_URL)
Expand Down Expand Up @@ -311,4 +311,3 @@ public MixedOperation<Notebook, KubernetesResourceList<Notebook>, Resource<Noteb
return client.resources(Notebook.class);
}
}

8 changes: 7 additions & 1 deletion src/main/java/io/odh/test/platform/KubeUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.platform;


import io.opendatahub.datasciencecluster.v1.datascienceclusterstatus.Conditions;

import java.util.List;
Expand All @@ -10,4 +13,7 @@ public class KubeUtils {
public static Conditions getDscConditionByType(List<Conditions> conditions, String type) {
return conditions.stream().filter(c -> c.getType().equals(type)).findFirst().orElseGet(null);
}

private KubeUtils() {
}
}
3 changes: 1 addition & 2 deletions src/test/java/io/odh/test/e2e/Abstract.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/*
* Copyright Tealc authors.
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.e2e;

import io.odh.test.platform.KubeClient;
import io.odh.test.TestConstants;
import io.odh.test.framework.TestSeparator;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Tealc authors.
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.e2e.continuous;
Expand Down Expand Up @@ -32,8 +32,8 @@
@Tag("continuous")
public class DataScienceClusterIT extends Abstract {

private final String DS_CLUSTER_NAME = "default";
private final String DS_DASHBOARD_CONFIG_NAME = "odh-dashboard-config";
private static final String DS_CLUSTER_NAME = "default";
private static final String DS_DASHBOARD_CONFIG_NAME = "odh-dashboard-config";
MixedOperation<DataScienceCluster, KubernetesResourceList<DataScienceCluster>, Resource<DataScienceCluster>> dataScienceProjectCli;
MixedOperation<OdhDashboardConfig, KubernetesResourceList<OdhDashboardConfig>, Resource<OdhDashboardConfig>> dashboardConfigCli;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Tealc authors.
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.e2e.continuous;
Expand All @@ -19,8 +19,8 @@
@Tag("continuous")
public class DataScienceProjectIT extends Abstract {

private final String DS_PROJECT_NAME = "test";
private final String DS_WORKBENCH_NAME = "test-workbench";
private static final String DS_PROJECT_NAME = "test";
private static final String DS_WORKBENCH_NAME = "test-workbench";
MixedOperation<Notebook, KubernetesResourceList<Notebook>, Resource<Notebook>> notebookCli;

@BeforeAll
Expand Down
12 changes: 3 additions & 9 deletions src/test/java/io/odh/test/e2e/standard/DataScienceClusterIT.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright Tealc authors.
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.e2e.standard;
Expand All @@ -8,9 +8,7 @@
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.odh.test.TestConstants;
import io.odh.test.e2e.Abstract;
import io.odh.test.platform.KubeUtils;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
import io.opendatahub.datasciencecluster.v1.DataScienceClusterBuilder;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.ComponentsBuilder;
Expand All @@ -22,9 +20,6 @@
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.DatasciencepipelinesBuilder;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Kserve;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.KserveBuilder;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Modelmeshserving;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Ray;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Trustyai;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Workbenches;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.WorkbenchesBuilder;
import org.junit.jupiter.api.AfterAll;
Expand All @@ -33,13 +28,12 @@
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

@Tag("standard")
public class DataScienceClusterIT extends Abstract {

private final String DS_PROJECT_NAME = "test-dsp";
private final String DS_PROJECT_NAMESPACE = "test-ns-ds";
private static final String DS_PROJECT_NAME = "test-dsp";
private static final String DS_PROJECT_NAMESPACE = "test-ns-ds";
MixedOperation<DataScienceCluster, KubernetesResourceList<DataScienceCluster>, Resource<DataScienceCluster>> cli;

@BeforeAll
Expand Down
Loading

0 comments on commit 4f60668

Please sign in to comment.