Skip to content

Commit

Permalink
Added spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 committed Mar 1, 2023
1 parent 9d73adb commit 4c9d64d
Show file tree
Hide file tree
Showing 3 changed files with 253 additions and 89 deletions.
60 changes: 60 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

default_stages: [commit, push]
default_language_version:
# force all python hooks to run python3
python: python3
repos:
# Python API Hooks
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies: [
'flake8-docstrings>=1.6',
'flake8-black>=0.2',
]
- repo: https://github.com/pycqa/autoflake
rev: v1.4
hooks:
- id: autoflake
args: [
--remove-all-unused-imports,
--ignore-init-module-imports,
--in-place
]
- repo: local
hooks:
# Spotless Hooks
- id: spotless
name: spotless lint
entry: ./mvnw spotless:apply
language: script
pass_filenames: false
263 changes: 174 additions & 89 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.datasophon</groupId>
<artifactId>datasophon</artifactId>
<packaging>pom</packaging>
<version>1.1.0</version>
<packaging>pom</packaging>
<description>It is committed to rapidly implementing the deployment, management, monitoring and automatic operation
and maintenance of the big data cloud native platform, helping you quickly build a stable, efficient, elastic
and scalable big data cloud native platform.</description>
<modules>
<module>datasophon-api</module>
<module>datasophon-dao</module>
Expand All @@ -17,27 +19,29 @@
</modules>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring.version>5.1.19.RELEASE</spring.version>
<spring.boot.version>2.1.18.RELEASE</spring.boot.version>
<java.version>1.8</java.version>
<akka.version>2.4.20</akka.version>
<commons.httpclient>3.0.1</commons.httpclient>
<commons.lang>2.6</commons.lang>
<druid.version>1.1.14</druid.version>
<fastjson.version>1.2.83</fastjson.version>
<hutool.version>5.8.9</hutool.version>
<jackson.version>2.9.10</jackson.version>
<mybatis-plus.version>3.2.0</mybatis-plus.version>
<mybatis.spring.version>2.0.1</mybatis.spring.version>
<mysql.connector.version>5.1.34</mysql.connector.version>
<java.version>1.8</java.version>
<junit.version>4.12</junit.version>
<druid.version>1.1.14</druid.version>
<commons.lang>2.6</commons.lang>
<commons.httpclient>3.0.1</commons.httpclient>
<akka.version>2.4.20</akka.version>
<logback.version>1.2.3</logback.version>
<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
<maven-compiler-plugin.version>3.10.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
<hutool.version>5.8.9</hutool.version>
<mybatis-plus.version>3.2.0</mybatis-plus.version>
<mybatis.spring.version>2.0.1</mybatis.spring.version>
<mysql.connector.version>5.1.34</mysql.connector.version>
<org.apache.sshd.version>2.9.2</org.apache.sshd.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spotless.ratchetFrom>origin/dev</spotless.ratchetFrom>
<spotless.version>2.27.1</spotless.version>
<spring.boot.version>2.1.18.RELEASE</spring.boot.version>
<spring.version>5.1.19.RELEASE</spring.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -156,80 +160,161 @@
<version>${org.apache.sshd.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless.version}</version>
<configuration>
<!--
By default, only modified and uncommitted files are added.
If you need to add license header to all files,
comment the `<ratchetFrom>${spotless.ratchetFrom}</ratchetFrom>` and execute: `mvn spotless:apply`
-->
<ratchetFrom>${spotless.ratchetFrom}</ratchetFrom>
<java>
<googleJavaFormat>
<version>1.7</version>
<style>AOSP</style>
</googleJavaFormat>

<removeUnusedImports />
<importOrder>
<order>\#,com.datasophon,org.apache,java,javassist,javax,org,com,</order>
</importOrder>
<licenseHeader>
<file>style/license_header</file>
</licenseHeader>
<replaceRegex>
<name>Remove wildcard imports</name>
<searchRegex>import\s+[^\*\s]+\*;(\r\n|\r|\n)</searchRegex>
<replacement>$1</replacement>
</replaceRegex>
</java>
<pom>
<sortPom>
<encoding>UTF-8</encoding>
<nrOfIndentSpace>4</nrOfIndentSpace>
<keepBlankLines>true</keepBlankLines>
<indentBlankLines>false</indentBlankLines>
<indentSchemaLocation>true</indentSchemaLocation>
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
<sortModules>false</sortModules>
<sortExecutions>false</sortExecutions>
<predefinedSortOrder>custom_1</predefinedSortOrder>
<expandEmptyElements>false</expandEmptyElements>
<sortProperties>true</sortProperties>
</sortPom>
<replace>
<name>Leading blank line</name>
<search>project</search>
<replacement>project</replacement>
</replace>
</pom>
</configuration>
<executions>
<execution>
<id>spotless-check</id>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
</plugins>

<!-- <pluginManagement>-->
<!-- <plugins>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <version>${maven-compiler-plugin.version}</version>-->
<!-- <configuration>-->
<!-- <source>${java.version}</source>-->
<!-- <target>${java.version}</target>-->
<!-- <testSource>${java.version}</testSource>-->
<!-- <testTarget>${java.version}</testTarget>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-surefire-plugin</artifactId>-->
<!-- <version>${maven-surefire-plugin.version}</version>-->
<!-- </plugin>-->

<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-checkstyle-plugin</artifactId>-->
<!-- <version>${maven-checkstyle-plugin.version}</version>-->
<!-- <configuration>-->
<!-- <consoleOutput>true</consoleOutput>-->
<!-- <encoding>UTF-8</encoding>-->
<!-- <configLocation>style/checkstyle.xml</configLocation>-->
<!-- <suppressionsLocation>style/checkstyle-suppressions.xml</suppressionsLocation>-->
<!-- <failOnViolation>true</failOnViolation>-->
<!-- <includeTestSourceDirectory>true</includeTestSourceDirectory>-->
<!-- <sourceDirectories>-->
<!-- <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>-->
<!-- </sourceDirectories>-->
<!-- <excludes>**\/generated-sources\/</excludes>-->
<!-- </configuration>-->
<!-- <dependencies>-->
<!-- <dependency>-->
<!-- <groupId>com.puppycrawl.tools</groupId>-->
<!-- <artifactId>checkstyle</artifactId>-->
<!-- <version>8.14</version>-->
<!-- </dependency>-->
<!-- </dependencies>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <goals>-->
<!-- <goal>check</goal>-->
<!-- </goals>-->
<!-- <phase>compile</phase>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </pluginManagement>-->

<!-- <plugins>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <version>${maven-compiler-plugin.version}</version>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-surefire-plugin</artifactId>-->
<!-- <version>${maven-surefire-plugin.version}</version>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-checkstyle-plugin</artifactId>-->
<!-- <version>${maven-checkstyle-plugin.version}</version>-->
<!-- </plugin>-->
<!-- </plugins>-->
</build>

<!-- <build>-->
<!-- <pluginManagement>-->
<!-- <plugins>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <version>${maven-compiler-plugin.version}</version>-->
<!-- <configuration>-->
<!-- <source>${java.version}</source>-->
<!-- <target>${java.version}</target>-->
<!-- <testSource>${java.version}</testSource>-->
<!-- <testTarget>${java.version}</testTarget>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-surefire-plugin</artifactId>-->
<!-- <version>${maven-surefire-plugin.version}</version>-->
<!-- </plugin>-->
<url>https://datasophon.github.io/datasophon-website/</url>
<inceptionYear>2022</inceptionYear>

<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-checkstyle-plugin</artifactId>-->
<!-- <version>${maven-checkstyle-plugin.version}</version>-->
<!-- <configuration>-->
<!-- <consoleOutput>true</consoleOutput>-->
<!-- <encoding>UTF-8</encoding>-->
<!-- <configLocation>style/checkstyle.xml</configLocation>-->
<!-- <suppressionsLocation>style/checkstyle-suppressions.xml</suppressionsLocation>-->
<!-- <failOnViolation>true</failOnViolation>-->
<!-- <includeTestSourceDirectory>true</includeTestSourceDirectory>-->
<!-- <sourceDirectories>-->
<!-- <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>-->
<!-- </sourceDirectories>-->
<!-- <excludes>**\/generated-sources\/</excludes>-->
<!-- </configuration>-->
<!-- <dependencies>-->
<!-- <dependency>-->
<!-- <groupId>com.puppycrawl.tools</groupId>-->
<!-- <artifactId>checkstyle</artifactId>-->
<!-- <version>8.14</version>-->
<!-- </dependency>-->
<!-- </dependencies>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <goals>-->
<!-- <goal>check</goal>-->
<!-- </goals>-->
<!-- <phase>compile</phase>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </pluginManagement>-->
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<!-- <plugins>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <version>${maven-compiler-plugin.version}</version>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-surefire-plugin</artifactId>-->
<!-- <version>${maven-surefire-plugin.version}</version>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-checkstyle-plugin</artifactId>-->
<!-- <version>${maven-checkstyle-plugin.version}</version>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </build>-->
<scm>
<connection>git@github.com:datasophon/datasophon.git</connection>
<url>https://github.com/datasophon/datasophon</url>
</scm>

</project>
</project>
19 changes: 19 additions & 0 deletions style/license_header
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

0 comments on commit 4c9d64d

Please sign in to comment.