diff --git a/.checkstyle.xml b/.checkstyle.xml index 60160219..2d861eef 100644 --- a/.checkstyle.xml +++ b/.checkstyle.xml @@ -1,19 +1,18 @@ + "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> - + @@ -147,7 +146,7 @@ - + diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index a7915032..00000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,39 +0,0 @@ -version: '2' # required to adjust maintainability checks - -plugins: - checkstyle: - enabled: true - channel: 'checkstyle-10-7-0' - config: - file: '.checkstyle.xml' - -checks: - # We disable all the following CodeClimate checks: Checkstyle already checks for these things and has the advantage - # that the Checkstyle config can also be used in one's IDE. - argument-count: - enabled: false - complex-logic: - enabled: false - file-lines: - enabled: false - method-complexity: - enabled: false - method-count: - enabled: false - method-lines: - enabled: false - nested-control-flow: - enabled: false - return-statements: - enabled: false - - # No Checkstyle equivalent, but it keeps reporting false positives because of similar constructors and imports - similar-code: - enabled: false - # No Checkstyle equivalent, so enabled as long as it's not full of false positives - identical-code: - enabled: true - -exclude_patterns: - # Don't check test scope - - 'src/test/java/**' diff --git a/.config/yamllint.yml b/.config/yamllint.yml new file mode 100644 index 00000000..51cce04c --- /dev/null +++ b/.config/yamllint.yml @@ -0,0 +1,8 @@ +rules: + line-length: + max: 120 + + # GitHub Actions use 'on' as key in their config, which hits the "truthy" check. Disable it. + # https://github.com/adrienverge/yamllint/issues/430 + truthy: + check-keys: false diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml new file mode 100644 index 00000000..e8522abf --- /dev/null +++ b/.github/workflows/mega-linter.yml @@ -0,0 +1,192 @@ +# MegaLinter GitHub Action configuration file +# More info at https://megalinter.io +--- +name: MegaLinter + +# Trigger mega-linter at every push. Action will also be visible from +# Pull Requests to master +on: + # Comment this line to trigger action only on pull-requests + # (not recommended if you don't pay for GH Actions) + push: + + pull_request: + branches: + - master + +# Permissions. Depending on config, contents: write, issues: write and pull-requests: write should be added +permissions: + contents: read + pull-requests: write + +# Comment env block if you do not want to apply fixes +env: + # Apply linter fixes configuration + # + # When active, APPLY_FIXES must also be defined as environment variable + # (in github/workflows/mega-linter.yml or other CI tool) + APPLY_FIXES: none + + # Decide which event triggers application of fixes in a commit or a PR + # (pull_request, push, all) + APPLY_FIXES_EVENT: pull_request + + # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) + # or posted in a PR (pull_request) + APPLY_FIXES_MODE: commit + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + megalinter: + name: MegaLinter + runs-on: ubuntu-latest + + steps: + # Git Checkout + - name: Checkout Code + uses: actions/checkout@v4 + with: + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + + # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to + # improve performance + fetch-depth: 0 + + # MegaLinter + - name: MegaLinter + + # You can override MegaLinter flavor used to have faster performances + # More info at https://megalinter.io/latest/flavors/ + uses: oxsecurity/megalinter/flavors/java@v8 + + id: ml + + # All available variables are described in documentation + # https://megalinter.io/latest/config-file/ + env: + # Validates all source when push on master, else just the git diff with + # master. Override with true if you always want to lint all sources + # + # To validate the entire codebase, set to: + # VALIDATE_ALL_CODEBASE: true + # + # To validate only diff with master, set to: + # VALIDATE_ALL_CODEBASE: >- + # ${{ + # github.event_name == 'push' && + # github.ref == 'refs/heads/master' + # }} + VALIDATE_ALL_CODEBASE: true + + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Uncomment to use ApiReporter (Grafana) + # API_REPORTER: true + # API_REPORTER_URL: ${{ secrets.API_REPORTER_URL }} + # API_REPORTER_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_BASIC_AUTH_USERNAME }} + # API_REPORTER_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_BASIC_AUTH_PASSWORD }} + # API_REPORTER_METRICS_URL: ${{ secrets.API_REPORTER_METRICS_URL }} + # API_REPORTER_METRICS_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_USERNAME }} + # API_REPORTER_METRICS_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_PASSWORD }} + # API_REPORTER_DEBUG: false + + # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF + # .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY + + # Upload MegaLinter artifacts + - name: Archive production artifacts + uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: MegaLinter reports + include-hidden-files: "true" + path: | + megalinter-reports + mega-linter.log + + # Create pull request if applicable + # (for now works only on PR from same repository, not from forks) + - name: Create Pull Request with applied fixes + uses: peter-evans/create-pull-request@v6 + id: cpr + if: >- + steps.ml.outputs.has_updated_sources == 1 && + ( + env.APPLY_FIXES_EVENT == 'all' || + env.APPLY_FIXES_EVENT == github.event_name + ) && + env.APPLY_FIXES_MODE == 'pull_request' && + ( + github.event_name == 'push' || + github.event.pull_request.head.repo.full_name == github.repository + ) && + !contains(github.event.head_commit.message, 'skip fix') + with: + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + commit-message: "[MegaLinter] Apply linters automatic fixes" + title: "[MegaLinter] Apply linters automatic fixes" + labels: bot + + - name: Create PR output + if: >- + steps.ml.outputs.has_updated_sources == 1 && + ( + env.APPLY_FIXES_EVENT == 'all' || + env.APPLY_FIXES_EVENT == github.event_name + ) && + env.APPLY_FIXES_MODE == 'pull_request' && + ( + github.event_name == 'push' || + github.event.pull_request.head.repo.full_name == github.repository + ) && + !contains(github.event.head_commit.message, 'skip fix') + run: | + echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}" + + # Push new commit if applicable + # (for now works only on PR from same repository, not from forks) + - name: Prepare commit + if: >- + steps.ml.outputs.has_updated_sources == 1 && + ( + env.APPLY_FIXES_EVENT == 'all' || + env.APPLY_FIXES_EVENT == github.event_name + ) && + env.APPLY_FIXES_MODE == 'commit' && + github.ref != 'refs/heads/master' && + ( + github.event_name == 'push' || + github.event.pull_request.head.repo.full_name == github.repository + ) && + !contains(github.event.head_commit.message, 'skip fix') + run: sudo chown -Rc $UID .git/ + + - name: Commit and push applied linter fixes + uses: stefanzweifel/git-auto-commit-action@v5 + if: >- + steps.ml.outputs.has_updated_sources == 1 && + ( + env.APPLY_FIXES_EVENT == 'all' || + env.APPLY_FIXES_EVENT == github.event_name + ) && + env.APPLY_FIXES_MODE == 'commit' && + github.ref != 'refs/heads/master' && + ( + github.event_name == 'push' || + github.event.pull_request.head.repo.full_name == github.repository + ) && + !contains(github.event.head_commit.message, 'skip fix') + with: + branch: >- + ${{ + github.event.pull_request.head.ref || + github.head_ref || + github.ref + }} + commit_message: "[MegaLinter] Apply linters fixes" + commit_user_name: megalinter-bot + commit_user_email: 129584137+megalinter-bot@users.noreply.github.com diff --git a/.gitignore b/.gitignore index 38588393..9ddf3a55 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,5 @@ nb-configuration.xml ### Git ### # Don't exclude the .gitignore itself !.gitignore + +megalinter-reports/ diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml index 250d7843..223fce8b 100644 --- a/.idea/checkstyle-idea.xml +++ b/.idea/checkstyle-idea.xml @@ -1,7 +1,7 @@ - 10.7.0 + 10.25.1 JavaOnly true true diff --git a/.mega-linter.yml b/.mega-linter.yml new file mode 100644 index 00000000..842ba287 --- /dev/null +++ b/.mega-linter.yml @@ -0,0 +1,37 @@ +# Configuration file for MegaLinter +# +# See all available variables at https://megalinter.io/latest/config-file/ and in +# linters documentation + +# all, none, or list of linter keys +APPLY_FIXES: none +PRINT_ALPACA: false + +# See https://megalinter.io/8.8.0/flavors/java/ for a list of linters +DISABLE_LINTERS: + - COPYPASTE_JSCPD + - EDITORCONFIG_EDITORCONFIG_CHECKER + - JAVA_PMD + - JSON_V8R + - JSON_JSONLINT + - JSON_PRETTIER + - SPELL_CSPELL + - SPELL_LYCHEE + - XML_XMLLINT + - YAML_PRETTIER + +# Exclude test files - some are intentionally badly formatted, some produce encoding issues, etc. +YAML_FILTER_REGEX_EXCLUDE: 'src/test/.*' +YAML_YAMLLINT_CONFIG_FILE: '.config/yamllint.yml' +# YAML lint errors shouldn't mark the MegaLinter action as failed +YAML_YAMLLINT_DISABLE_ERRORS: true + +# Markdown lint errors shouldn't mark the MegaLinter action as failed +MARKDOWN_MARKDOWNLINT_DISABLE_ERRORS: true + +# https://megalinter.io/8.8.0/descriptors/java_checkstyle/ +JAVA_CHECKSTYLE_CONFIG_FILE: '.checkstyle.xml' +JAVA_CHECKSTYLE_FILTER_REGEX_INCLUDE: 'src/main' + +# Uncomment if you want MegaLinter to detect errors but not block CI to pass +# DISABLE_ERRORS: true diff --git a/README.md b/README.md index df2160e3..c9d0e977 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://github.com/AuthMe/ConfigMe/actions/workflows/maven_jdk8.yml/badge.svg)](https://github.com/AuthMe/ConfigMe/actions?query=branch%3Amaster) [![Coverage Status](https://coveralls.io/repos/github/AuthMe/ConfigMe/badge.svg?branch=master)](https://coveralls.io/github/AuthMe/ConfigMe?branch=master) [![Javadocs](https://www.javadoc.io/badge/ch.jalu/configme.svg)](https://www.javadoc.io/doc/ch.jalu/configme) -[![Code Climate](https://codeclimate.com/github/AuthMe/ConfigMe/badges/gpa.svg)](https://codeclimate.com/github/AuthMe/ConfigMe) +[![MegaLinter](https://github.com/AuthMe/ConfigMe/workflows/MegaLinter/badge.svg?branch=master)](https://github.com/AuthMe/ConfigMe/actions?query=workflow%3AMegaLinter+branch%3Amaster) A simple configuration management library with YAML support out of the box.