fix: liniting rules

pull/1/head
Richard Attermeyer 2023-11-03 23:54:08 +01:00
parent 4a896aaf00
commit ee76007f00
23 changed files with 645 additions and 108 deletions

6
.idea/jpa-buddy.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JpaBuddyIdeaProjectConfig">
<option name="renamerInitialized" value="true" />
</component>
</project>

8
.idea/misc.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="19" project-jdk-type="JavaSDK" />
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
</project>

406
.markdownlint.yaml Normal file
View File

@ -0,0 +1,406 @@
# Example markdownlint configuration with all properties set to their default value
## Default state for all rules
default: true
### Path to configuration file to extend
extends: null
## MD001/heading-increment/header-increment - Heading levels should only increment by one level at a time
MD001: true
## MD002/first-heading-h1/first-header-h1 - First heading should be a top-level heading
MD002:
## Heading level
level: 1
## MD003/heading-style/header-style - Heading style
MD003:
## Heading style
style: "consistent"
## MD004/ul-style - Unordered list style
MD004:
## unorderer List style
style: "consistent"
## MD005/list-indent - Inconsistent indentation for list items at the same level
MD005: true
## MD006/ul-start-left - Consider starting bulleted lists at the beginning of the line
MD006: true
## MD007/ul-indent - Unordered list indentation
MD007:
## Spaces for indent
indent: 2
## Whether to indent the first level of the list
start_indented: false
## Spaces for first level indent (when start_indented is set)
start_indent: 2
## MD009/no-trailing-spaces - Trailing spaces
MD009:
## Spaces for line break
br_spaces: 2
## Allow spaces for empty lines in list items
list_item_empty_lines: false
## Include unnecessary breaks
strict: false
## MD010/no-hard-tabs - Hard tabs
MD010:
## Include code blocks
code_blocks: true
## Fenced code languages to ignore
ignore_code_languages: []
## Number of spaces for each hard tab
spaces_per_tab: 1
## MD011/no-reversed-links - Reversed link syntax
MD011: true
## MD012/no-multiple-blanks - Multiple consecutive blank lines
MD012:
## Consecutive blank lines
maximum: 1
## MD013/line-length - Line length
MD013: false
## # Number of characters
## line_length: 140
## # Number of characters for headings
## heading_line_length: 120
## # Number of characters for code blocks
## code_block_line_length: 140
## # Include code blocks
## code_blocks: true
## # Include tables
## tables: true
## # Include headings
## headings: true
## # Strict length checking
## strict: false
## # Stern length checking
## stern: false
## MD014/commands-show-output - Dollar signs used before commands without showing output
MD014: true
## MD018/no-missing-space-atx - No space after hash on atx style heading
MD018: true
## MD019/no-multiple-space-atx - Multiple spaces after hash on atx style heading
MD019: true
## MD020/no-missing-space-closed-atx - No space inside hashes on closed atx style heading
MD020: true
## MD021/no-multiple-space-closed-atx - Multiple spaces inside hashes on closed atx style heading
MD021: true
## MD022/blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines
MD022:
## Blank lines above heading
lines_above: 1
## Blank lines below heading
lines_below: 1
## MD023/heading-start-left/header-start-left - Headings must start at the beginning of the line
MD023: true
## MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
MD024:
## allow different nesting
allow_different_nesting: false
## Only check sibling headings
siblings_only: false
## MD025/single-title/single-h1 - Multiple top-level headings in the same document
MD025:
## only one top-level heading in same document
level: 1
## RegExp for matching title in front matter
front_matter_title: "^\\s*title\\s*[:=]"
## MD026/no-trailing-punctuation - Trailing punctuation in heading
MD026:
## Punctuation characters
punctuation: ".,;:!。,;:!"
## MD027/no-multiple-space-blockquote - Multiple spaces after blockquote symbol
MD027: true
## MD028/no-blanks-blockquote - Blank line inside blockquote
MD028: true
## MD029/ol-prefix - Ordered list item prefix
MD029:
## List style
style: "one_or_ordered"
## MD030/list-marker-space - Spaces after list markers
MD030:
## Spaces for single-line unordered list items
ul_single: 1
## Spaces for single-line ordered list items
ol_single: 1
## Spaces for multi-line unordered list items
ul_multi: 1
## Spaces for multi-line ordered list items
ol_multi: 1
## MD031/blanks-around-fences - Fenced code blocks should be surrounded by blank lines
MD031:
## Include list items
list_items: true
## MD032/blanks-around-lists - Lists should be surrounded by blank lines
MD032: true
## MD033/no-inline-html - Inline HTML
MD033:
## Allowed elements
allowed_elements: []
## MD034/no-bare-urls - Bare URL used
MD034: true
## MD035/hr-style - Horizontal rule style
MD035:
## Horizontal rule style
style: "consistent"
## MD036/no-emphasis-as-heading/no-emphasis-as-header - Emphasis used instead of a heading
MD036:
## No Punctuation characters
punctuation: ".,;:!?。,;:!?"
## MD037/no-space-in-emphasis - Spaces inside emphasis markers
MD037: true
## MD038/no-space-in-code - Spaces inside code span elements
MD038: true
## MD039/no-space-in-links - Spaces inside link text
MD039: true
## MD040/fenced-code-language - Fenced code blocks should have a language specified
MD040:
## List of languages
allowed_languages: []
## Require language only
language_only: false
## MD041/first-line-heading/first-line-h1 - First line in a file should be a top-level heading
MD041:
## Heading level of first line should be top-level
level: 1
## RegExp for front matter title
front_matter_title: "^\\s*title\\s*[:=]"
## MD042/no-empty-links - No empty links
MD042: true
## MD043/required-headings/required-headers - Required heading structure
MD043: false
## MD044/proper-names - Proper names should have the correct capitalization
MD044:
## List of proper names
names: []
## Proper names in code blocks
code_blocks: true
## Include HTML elements
html_elements: true
## MD045/no-alt-text - Images should have alternate text (alt text)
MD045: true
## MD046/code-block-style - Code block style
MD046:
## Block style
style: "consistent"
## MD047/single-trailing-newline - Files should end with a single newline character
MD047: true
## MD048/code-fence-style - Code fence style
MD048:
## Code fence style
style: "consistent"
## MD049/emphasis-style - Emphasis style should be consistent
MD049:
## Emphasis style
style: "consistent"
## MD050/strong-style - Strong style should be consistent
MD050:
## Strong style
style: "consistent"
## MD051/link-fragments - Link fragments should be valid
MD051: true
## MD052/reference-links-images - Reference links and images should use a label that is defined
MD052:
## Include shortcut syntax
shortcut_syntax: false
## MD053/link-image-reference-definitions - Link and image reference definitions should be needed
MD053:
## Ignored definitions
ignored_definitions:
- "//"

69
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,69 @@
---
minimum_pre_commit_version: "3.2.0"
# התיקיות והקבצים שצריך להתעלם מהם
exclude: "^vscode/|^example/"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
stages: [commit]
- id: trailing-whitespace
args: ["--markdown-linebreak-ext=md"]
stages: [commit]
- id: forbid-new-submodules
stages: [commit]
- id: sort-simple-yaml
stages: [commit]
- id: check-xml
stages: [commit]
- id: check-added-large-files
args: ["--maxkb=128"]
stages: [commit]
- id: check-byte-order-marker
stages: [commit]
- id: check-case-conflict
stages: [commit]
- id: check-docstring-first
stages: [commit]
- id: check-executables-have-shebangs
stages: [commit]
- id: check-merge-conflict
stages: [commit]
- id: check-symlinks
stages: [commit]
- id: debug-statements
stages: [commit]
- id: detect-aws-credentials
args: ["--allow-missing-credentials"]
stages: [commit]
- id: detect-private-key
stages: [commit]
- id: mixed-line-ending
args: ["--fix=lf"]
stages: [commit]
- id: trailing-whitespace
exclude: \.preseed$
# DISC: ShellScripts
#
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
- id: shellcheck
# DISC: Yaml Files
#
- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
hooks:
- id: yamllint
files: \.(yaml|yml)$
stages: [commit]
- repo: https://github.com/igorshubovych/markdownlint-cli.git
rev: v0.37.0
hooks:
- id: markdownlint
...

44
.woodpecker.yml Normal file
View File

@ -0,0 +1,44 @@
---
clone:
git:
image: woodpeckerci/plugin-git
settings:
skip_verify: true
steps:
"lint:precommit":
group: lint
image: dchevallier/pre-commit:latest
commands:
- pre-commit install
- pre-commit run --all-files
"lint:style":
group: lint
image: maven:3.9.4-eclipse-temurin-17
commands:
- mvn spotless:check
"lint:credentials":
group: lint
image: ghcr.io/gitleaks/gitleaks:latest
commands:
- export HOME=/home/gitleaks
- gitleaks detect
"lint:commitlint":
group: lint
image: node:lts-slim
commands:
- npm install --save-dev conventional-changelog-conventionalcommits @commitlint/config-conventional commitlint@latest
- echo "$CI_COMMIT_MESSAGE"x | npx commitlint
when:
- branch: [main, dev]
- event: push
"lint:hadolint":
group: lint
image: ghcr.io/hadolint/hadolint:latest-debian
commands:
- hadolint --version
- hadolint Dockerfile
"build:java":
group: build
image: gradle:8.4.0-jdk17-alpine
commands:
- ./gradlew build

9
.yamllint.yml Normal file
View File

@ -0,0 +1,9 @@
---
extends: default
ignore: |
frontend/pnpm-lock.yaml
rules:
line-length: false

View File

@ -2,16 +2,14 @@
* This file was generated by the Gradle 'init' task.
*/
plugins {
id("com.opitzconsulting.demo.ci.java-application-conventions")
}
plugins { id("com.opitzconsulting.demo.ci.java-application-conventions") }
dependencies {
implementation("org.apache.commons:commons-text")
implementation(project(":utilities"))
implementation("org.apache.commons:commons-text")
implementation(project(":utilities"))
}
application {
// Define the main class for the application.
mainClass.set("com.opitzconsulting.demo.ci.app.App")
// Define the main class for the application.
mainClass.set("com.opitzconsulting.demo.ci.app.App")
}

View File

@ -1,14 +1,14 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
// <editor-fold defaultstate="collapsed" desc="Preamble">
/* SPDX-License-Identifier: MIT */
/* (C) Copyright \2023 OPITZ CONSULTING Deutschland GmbH */
// </editor-fold>
package com.opitzconsulting.demo.ci.app;
import com.opitzconsulting.demo.ci.list.LinkedList;
import static com.opitzconsulting.demo.ci.app.MessageUtils.getMessage;
import static com.opitzconsulting.demo.ci.utilities.StringUtils.join;
import static com.opitzconsulting.demo.ci.utilities.StringUtils.split;
import static com.opitzconsulting.demo.ci.app.MessageUtils.getMessage;
import com.opitzconsulting.demo.ci.list.LinkedList;
import org.apache.commons.text.WordUtils;
public class App {

View File

@ -1,6 +1,7 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
// <editor-fold defaultstate="collapsed" desc="Preamble">
/* SPDX-License-Identifier: MIT */
/* (C) Copyright \2023 OPITZ CONSULTING Deutschland GmbH */
// </editor-fold>
package com.opitzconsulting.demo.ci.app;
class MessageUtils {

View File

@ -1,14 +1,16 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
// <editor-fold defaultstate="collapsed" desc="Preamble">
/* SPDX-License-Identifier: MIT */
/* (C) Copyright \2023 OPITZ CONSULTING Deutschland GmbH */
// </editor-fold>
package com.opitzconsulting.demo.ci.app;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class MessageUtilsTest {
@Test void testGetMessage() {
@Test
void testGetMessage() {
assertEquals("Hello World!", MessageUtils.getMessage());
}
}

View File

@ -1,28 +1,19 @@
plugins {
id("com.diffplug.spotless") version "6.22.0"
}
plugins { id("com.diffplug.spotless") version "6.22.0" }
repositories {
mavenCentral()
}
repositories { mavenCentral() }
spotless {
encoding("UTF-8")
java {
target("**/*.java")
toggleOffOn("formatter:off", "formatter:on") // same as intellij
licenseHeader("""
//<editor-fold defaultstate="collapsed" desc="Preamble">
/* SPDX-License-Identifier: MIT */
/* (C) Copyright \${'$'}YEAR OPITZ CONSULTING Deutschland GmbH */
//</editor-fold>
""".trimIndent()) //
targetExclude("build/generated/**", "build/generated-async-api/**")
palantirJavaFormat() // Intellij Plugin available
}
kotlin {
target("**/*.kt", "**/*.kts")
// by default the target is every ".kt" and ".kts` file in the java sourcesets
ktfmt() // intellij plugin available
}
encoding("UTF-8")
java {
target("**/*.java")
toggleOffOn("formatter:off", "formatter:on") // same as intellij
targetExclude("build/generated/**", "build/generated-async-api/**")
palantirJavaFormat() // Intellij Plugin available
}
kotlin {
target("**/*.kt", "**/*.kts")
targetExclude("buildSrc/build/generated-sources/**/*.kt")
// by default the target is every ".kt" and ".kts` file in the java sourcesets
ktfmt() // intellij plugin available
}
}

View File

@ -3,11 +3,12 @@
*/
plugins {
// Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build.
`kotlin-dsl`
// Support convention plugins written in Kotlin. Convention plugins are build scripts in
// 'src/main' that automatically become available as plugins in the main build.
`kotlin-dsl`
}
repositories {
// Use the plugin portal to apply community plugins in convention plugins.
gradlePluginPortal()
// Use the plugin portal to apply community plugins in convention plugins.
gradlePluginPortal()
}

View File

@ -3,9 +3,10 @@
*/
plugins {
// Apply the common convention plugin for shared build configuration between library and application projects.
id("com.opitzconsulting.demo.ci.java-common-conventions")
// Apply the common convention plugin for shared build configuration between library and
// application projects.
id("com.opitzconsulting.demo.ci.java-common-conventions")
// Apply the application plugin to add support for building a CLI application in Java.
application
// Apply the application plugin to add support for building a CLI application in Java.
application
}

View File

@ -3,35 +3,31 @@
*/
plugins {
// Apply the java Plugin to add support for Java.
java
// Apply the java Plugin to add support for Java.
java
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
constraints {
// Define dependency versions as constraints
implementation("org.apache.commons:commons-text:1.10.0")
}
constraints {
// Define dependency versions as constraints
implementation("org.apache.commons:commons-text:1.10.0")
}
// Use JUnit Jupiter for testing.
testImplementation("org.junit.jupiter:junit-jupiter:5.9.3")
// Use JUnit Jupiter for testing.
testImplementation("org.junit.jupiter:junit-jupiter:5.9.3")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } }
tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

View File

@ -3,9 +3,10 @@
*/
plugins {
// Apply the common convention plugin for shared build configuration between library and application projects.
id("com.opitzconsulting.demo.ci.java-common-conventions")
// Apply the common convention plugin for shared build configuration between library and
// application projects.
id("com.opitzconsulting.demo.ci.java-common-conventions")
// Apply the java-library plugin for API and implementation separation.
`java-library`
// Apply the java-library plugin for API and implementation separation.
`java-library`
}

View File

@ -2,6 +2,4 @@
* This file was generated by the Gradle 'init' task.
*/
plugins {
id("com.opitzconsulting.demo.ci.java-library-conventions")
}
plugins { id("com.opitzconsulting.demo.ci.java-library-conventions") }

View File

@ -1,6 +1,7 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
// <editor-fold defaultstate="collapsed" desc="Preamble">
/* SPDX-License-Identifier: MIT */
/* (C) Copyright \2023 OPITZ CONSULTING Deutschland GmbH */
// </editor-fold>
package com.opitzconsulting.demo.ci.list;
public class LinkedList {

View File

@ -1,19 +1,22 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
// <editor-fold defaultstate="collapsed" desc="Preamble">
/* SPDX-License-Identifier: MIT */
/* (C) Copyright \2023 OPITZ CONSULTING Deutschland GmbH */
// </editor-fold>
package com.opitzconsulting.demo.ci.list;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class LinkedListTest {
@Test void testConstructor() {
@Test
void testConstructor() {
LinkedList list = new LinkedList();
assertEquals(0, list.size());
}
@Test void testAdd() {
@Test
void testAdd() {
LinkedList list = new LinkedList();
list.add("one");
@ -25,7 +28,8 @@ class LinkedListTest {
assertEquals("two", list.get(1));
}
@Test void testRemove() {
@Test
void testRemove() {
LinkedList list = new LinkedList();
list.add("one");
@ -39,7 +43,8 @@ class LinkedListTest {
assertEquals(0, list.size());
}
@Test public void testRemoveMissing() {
@Test
public void testRemoveMissing() {
LinkedList list = new LinkedList();
list.add("one");

View File

@ -6,9 +6,10 @@
*/
plugins {
// Apply the foojay-resolver plugin to allow automatic download of JDKs
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
// Apply the foojay-resolver plugin to allow automatic download of JDKs
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
}
rootProject.name = "ci-demo"
include("app", "list", "utilities")

View File

@ -2,10 +2,6 @@
* This file was generated by the Gradle 'init' task.
*/
plugins {
id("com.opitzconsulting.demo.ci.java-library-conventions")
}
plugins { id("com.opitzconsulting.demo.ci.java-library-conventions") }
dependencies {
api(project(":list"))
}
dependencies { api(project(":list")) }

View File

@ -1,6 +1,7 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
// <editor-fold defaultstate="collapsed" desc="Preamble">
/* SPDX-License-Identifier: MIT */
/* (C) Copyright \2023 OPITZ CONSULTING Deutschland GmbH */
// </editor-fold>
package com.opitzconsulting.demo.ci.utilities;
import com.opitzconsulting.demo.ci.list.LinkedList;

View File

@ -1,6 +1,7 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
// <editor-fold defaultstate="collapsed" desc="Preamble">
/* SPDX-License-Identifier: MIT */
/* (C) Copyright \2023 OPITZ CONSULTING Deutschland GmbH */
// </editor-fold>
package com.opitzconsulting.demo.ci.utilities;
import com.opitzconsulting.demo.ci.list.LinkedList;

View File

@ -1,6 +1,7 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
// <editor-fold defaultstate="collapsed" desc="Preamble">
/* SPDX-License-Identifier: MIT */
/* (C) Copyright \2023 OPITZ CONSULTING Deutschland GmbH */
// </editor-fold>
package com.opitzconsulting.demo.ci.utilities;
import com.opitzconsulting.demo.ci.list.LinkedList;