Skip to content

Commit 89d1f7e

Browse files
authored
#376 Replace CodeClimate with MegaLinter (#489)
* Add MegaLinter GitHub Action & config * Remove CodeClimate things * Replace badge on readme with MegaLinter badge * Update config to Checkstyle 10.25.1
1 parent e262938 commit 89d1f7e

File tree

8 files changed

+250
-51
lines changed

8 files changed

+250
-51
lines changed

.checkstyle.xml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<?xml version="1.0"?>
22
<!DOCTYPE module PUBLIC
3-
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4-
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
55
<!--
6-
In order to be compatible with CodeClimate, we have to stay in sync with the version of Checkstyle that they are using.
7-
It doesn't seem to be updated much by default, but we can specify a channel, which is currently using 10.7.0.
8-
Check the links below to get up-to-date version information.
9-
https://github.com/codeclimate/codeclimate-checkstyle/branches/all (channel/ branches)
10-
https://docs.codeclimate.com/docs/checkstyle
11-
https://github.com/codeclimate/codeclimate-checkstyle/blob/master/bin/install-checkstyle.sh
6+
In order to be compatible with Megalint, we have to stay in sync with the version of Checkstyle that they are using.
7+
This is, at the time of writing, 10.25.0. Check the documentation to get up-to-date version information:
8+
https://megalinter.io/8.8.0/descriptors/java_checkstyle/
9+
The output of the GitHub Action also reports the Checkstyle version:
10+
https://github.com/AuthMe/ConfigMe/actions/workflows/mega-linter.yml?query=branch%3Amaster
1211
-->
1312

1413
<module name="Checker">
1514
<property name="charset" value="UTF-8" />
16-
<property name="severity" value="warning" />
15+
<property name="severity" value="error" />
1716
<property name="fileExtensions" value="java" />
1817

1918
<module name="SuppressWarningsFilter" />
@@ -147,7 +146,7 @@
147146
<module name="JavadocTagContinuationIndentation" />
148147
<module name="JavadocType" />
149148
<module name="JavadocVariable">
150-
<property name="scope" value="package" />
149+
<property name="accessModifiers" value="package" />
151150
</module>
152151
<module name="MissingJavadocMethod">
153152
<property name="scope" value="package" />

.codeclimate.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.config/yamllint.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rules:
2+
line-length:
3+
max: 120
4+
5+
# GitHub Actions use 'on' as key in their config, which hits the "truthy" check. Disable it.
6+
# https://github.com/adrienverge/yamllint/issues/430
7+
truthy:
8+
check-keys: false

.github/workflows/mega-linter.yml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# MegaLinter GitHub Action configuration file
2+
# More info at https://megalinter.io
3+
---
4+
name: MegaLinter
5+
6+
# Trigger mega-linter at every push. Action will also be visible from
7+
# Pull Requests to master
8+
on:
9+
# Comment this line to trigger action only on pull-requests
10+
# (not recommended if you don't pay for GH Actions)
11+
push:
12+
13+
pull_request:
14+
branches:
15+
- master
16+
17+
# Permissions. Depending on config, contents: write, issues: write and pull-requests: write should be added
18+
permissions:
19+
contents: read
20+
pull-requests: write
21+
22+
# Comment env block if you do not want to apply fixes
23+
env:
24+
# Apply linter fixes configuration
25+
#
26+
# When active, APPLY_FIXES must also be defined as environment variable
27+
# (in github/workflows/mega-linter.yml or other CI tool)
28+
APPLY_FIXES: none
29+
30+
# Decide which event triggers application of fixes in a commit or a PR
31+
# (pull_request, push, all)
32+
APPLY_FIXES_EVENT: pull_request
33+
34+
# If APPLY_FIXES is used, defines if the fixes are directly committed (commit)
35+
# or posted in a PR (pull_request)
36+
APPLY_FIXES_MODE: commit
37+
38+
concurrency:
39+
group: ${{ github.ref }}-${{ github.workflow }}
40+
cancel-in-progress: true
41+
42+
jobs:
43+
megalinter:
44+
name: MegaLinter
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
# Git Checkout
49+
- name: Checkout Code
50+
uses: actions/checkout@v4
51+
with:
52+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
53+
54+
# If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to
55+
# improve performance
56+
fetch-depth: 0
57+
58+
# MegaLinter
59+
- name: MegaLinter
60+
61+
# You can override MegaLinter flavor used to have faster performances
62+
# More info at https://megalinter.io/latest/flavors/
63+
uses: oxsecurity/megalinter/flavors/java@v8
64+
65+
id: ml
66+
67+
# All available variables are described in documentation
68+
# https://megalinter.io/latest/config-file/
69+
env:
70+
# Validates all source when push on master, else just the git diff with
71+
# master. Override with true if you always want to lint all sources
72+
#
73+
# To validate the entire codebase, set to:
74+
# VALIDATE_ALL_CODEBASE: true
75+
#
76+
# To validate only diff with master, set to:
77+
# VALIDATE_ALL_CODEBASE: >-
78+
# ${{
79+
# github.event_name == 'push' &&
80+
# github.ref == 'refs/heads/master'
81+
# }}
82+
VALIDATE_ALL_CODEBASE: true
83+
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
86+
# Uncomment to use ApiReporter (Grafana)
87+
# API_REPORTER: true
88+
# API_REPORTER_URL: ${{ secrets.API_REPORTER_URL }}
89+
# API_REPORTER_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_BASIC_AUTH_USERNAME }}
90+
# API_REPORTER_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_BASIC_AUTH_PASSWORD }}
91+
# API_REPORTER_METRICS_URL: ${{ secrets.API_REPORTER_METRICS_URL }}
92+
# API_REPORTER_METRICS_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_USERNAME }}
93+
# API_REPORTER_METRICS_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_PASSWORD }}
94+
# API_REPORTER_DEBUG: false
95+
96+
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF
97+
# .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
98+
99+
# Upload MegaLinter artifacts
100+
- name: Archive production artifacts
101+
uses: actions/upload-artifact@v4
102+
if: success() || failure()
103+
with:
104+
name: MegaLinter reports
105+
include-hidden-files: "true"
106+
path: |
107+
megalinter-reports
108+
mega-linter.log
109+
110+
# Create pull request if applicable
111+
# (for now works only on PR from same repository, not from forks)
112+
- name: Create Pull Request with applied fixes
113+
uses: peter-evans/create-pull-request@v6
114+
id: cpr
115+
if: >-
116+
steps.ml.outputs.has_updated_sources == 1 &&
117+
(
118+
env.APPLY_FIXES_EVENT == 'all' ||
119+
env.APPLY_FIXES_EVENT == github.event_name
120+
) &&
121+
env.APPLY_FIXES_MODE == 'pull_request' &&
122+
(
123+
github.event_name == 'push' ||
124+
github.event.pull_request.head.repo.full_name == github.repository
125+
) &&
126+
!contains(github.event.head_commit.message, 'skip fix')
127+
with:
128+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
129+
commit-message: "[MegaLinter] Apply linters automatic fixes"
130+
title: "[MegaLinter] Apply linters automatic fixes"
131+
labels: bot
132+
133+
- name: Create PR output
134+
if: >-
135+
steps.ml.outputs.has_updated_sources == 1 &&
136+
(
137+
env.APPLY_FIXES_EVENT == 'all' ||
138+
env.APPLY_FIXES_EVENT == github.event_name
139+
) &&
140+
env.APPLY_FIXES_MODE == 'pull_request' &&
141+
(
142+
github.event_name == 'push' ||
143+
github.event.pull_request.head.repo.full_name == github.repository
144+
) &&
145+
!contains(github.event.head_commit.message, 'skip fix')
146+
run: |
147+
echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}"
148+
echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}"
149+
150+
# Push new commit if applicable
151+
# (for now works only on PR from same repository, not from forks)
152+
- name: Prepare commit
153+
if: >-
154+
steps.ml.outputs.has_updated_sources == 1 &&
155+
(
156+
env.APPLY_FIXES_EVENT == 'all' ||
157+
env.APPLY_FIXES_EVENT == github.event_name
158+
) &&
159+
env.APPLY_FIXES_MODE == 'commit' &&
160+
github.ref != 'refs/heads/master' &&
161+
(
162+
github.event_name == 'push' ||
163+
github.event.pull_request.head.repo.full_name == github.repository
164+
) &&
165+
!contains(github.event.head_commit.message, 'skip fix')
166+
run: sudo chown -Rc $UID .git/
167+
168+
- name: Commit and push applied linter fixes
169+
uses: stefanzweifel/git-auto-commit-action@v5
170+
if: >-
171+
steps.ml.outputs.has_updated_sources == 1 &&
172+
(
173+
env.APPLY_FIXES_EVENT == 'all' ||
174+
env.APPLY_FIXES_EVENT == github.event_name
175+
) &&
176+
env.APPLY_FIXES_MODE == 'commit' &&
177+
github.ref != 'refs/heads/master' &&
178+
(
179+
github.event_name == 'push' ||
180+
github.event.pull_request.head.repo.full_name == github.repository
181+
) &&
182+
!contains(github.event.head_commit.message, 'skip fix')
183+
with:
184+
branch: >-
185+
${{
186+
github.event.pull_request.head.ref ||
187+
github.head_ref ||
188+
github.ref
189+
}}
190+
commit_message: "[MegaLinter] Apply linters fixes"
191+
commit_user_name: megalinter-bot
192+
commit_user_email: [email protected]

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,5 @@ nb-configuration.xml
109109
### Git ###
110110
# Don't exclude the .gitignore itself
111111
!.gitignore
112+
113+
megalinter-reports/

.idea/checkstyle-idea.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.mega-linter.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Configuration file for MegaLinter
2+
#
3+
# See all available variables at https://megalinter.io/latest/config-file/ and in
4+
# linters documentation
5+
6+
# all, none, or list of linter keys
7+
APPLY_FIXES: none
8+
PRINT_ALPACA: false
9+
10+
# See https://megalinter.io/8.8.0/flavors/java/ for a list of linters
11+
DISABLE_LINTERS:
12+
- COPYPASTE_JSCPD
13+
- EDITORCONFIG_EDITORCONFIG_CHECKER
14+
- JAVA_PMD
15+
- JSON_V8R
16+
- JSON_JSONLINT
17+
- JSON_PRETTIER
18+
- SPELL_CSPELL
19+
- SPELL_LYCHEE
20+
- XML_XMLLINT
21+
- YAML_PRETTIER
22+
23+
# Exclude test files - some are intentionally badly formatted, some produce encoding issues, etc.
24+
YAML_FILTER_REGEX_EXCLUDE: 'src/test/.*'
25+
YAML_YAMLLINT_CONFIG_FILE: '.config/yamllint.yml'
26+
# YAML lint errors shouldn't mark the MegaLinter action as failed
27+
YAML_YAMLLINT_DISABLE_ERRORS: true
28+
29+
# Markdown lint errors shouldn't mark the MegaLinter action as failed
30+
MARKDOWN_MARKDOWNLINT_DISABLE_ERRORS: true
31+
32+
# https://megalinter.io/8.8.0/descriptors/java_checkstyle/
33+
JAVA_CHECKSTYLE_CONFIG_FILE: '.checkstyle.xml'
34+
JAVA_CHECKSTYLE_FILTER_REGEX_INCLUDE: 'src/main'
35+
36+
# Uncomment if you want MegaLinter to detect errors but not block CI to pass
37+
# DISABLE_ERRORS: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Build Status](https://github.com/AuthMe/ConfigMe/actions/workflows/maven_jdk8.yml/badge.svg)](https://github.com/AuthMe/ConfigMe/actions?query=branch%3Amaster)
33
[![Coverage Status](https://coveralls.io/repos/github/AuthMe/ConfigMe/badge.svg?branch=master)](https://coveralls.io/github/AuthMe/ConfigMe?branch=master)
44
[![Javadocs](https://www.javadoc.io/badge/ch.jalu/configme.svg)](https://www.javadoc.io/doc/ch.jalu/configme)
5-
[![Code Climate](https://codeclimate.com/github/AuthMe/ConfigMe/badges/gpa.svg)](https://codeclimate.com/github/AuthMe/ConfigMe)
5+
[![MegaLinter](https://github.com/AuthMe/ConfigMe/workflows/MegaLinter/badge.svg?branch=master)](https://github.com/AuthMe/ConfigMe/actions?query=workflow%3AMegaLinter+branch%3Amaster)
66

77
A simple configuration management library with YAML support out of the box.
88

0 commit comments

Comments
 (0)