way_of_working-code_linting-hdi 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -1
- data/README.md +2 -4
- data/code_safety.yml +56 -44
- data/docs/way_of_working/code-linting/index.md +52 -17
- data/docs/way_of_working/code-linting/linters.md +95 -92
- data/lib/way_of_working/code_linting/hdi/generators/concerns/github_metadata.rb +42 -0
- data/lib/way_of_working/code_linting/hdi/generators/document_linters.rb +4 -2
- data/lib/way_of_working/code_linting/hdi/generators/init_linters.rb +108 -4
- data/lib/way_of_working/code_linting/hdi/plugin.rb +12 -0
- data/lib/way_of_working/code_linting/hdi/templates/.eslintrc.js +20 -0
- data/lib/way_of_working/code_linting/hdi/templates/.github/linters/.markdown-link-check.json +11 -11
- data/lib/way_of_working/code_linting/hdi/templates/.github/workflows/mega-linter.yml +107 -33
- data/lib/way_of_working/code_linting/hdi/templates/.mega-linter.yml +61 -109
- data/lib/way_of_working/code_linting/hdi/templates/docs/way_of_working/code-linting/index.md.tt +74 -0
- data/lib/way_of_working/code_linting/hdi/version.rb +1 -1
- data/lib/way_of_working/code_linting/hdi.rb +1 -1
- metadata +20 -4
- data/lib/way_of_working/code_linting/hdi/templates/docs/way_of_working/code-linting/index.md +0 -39
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
---
|
|
2
1
|
# MegaLinter GitHub Action configuration file
|
|
3
2
|
# More info at https://megalinter.io
|
|
3
|
+
---
|
|
4
4
|
name: MegaLinter
|
|
5
5
|
|
|
6
|
-
on:
|
|
6
|
+
on: # yamllint disable-line rule:truthy - false positive
|
|
7
7
|
# Trigger mega-linter at key points in the PR process
|
|
8
8
|
pull_request:
|
|
9
9
|
types:
|
|
@@ -11,78 +11,152 @@ on: # yamllint disable-line rule:truthy
|
|
|
11
11
|
- ready_for_review
|
|
12
12
|
- review_requested
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
contents: read
|
|
16
|
-
issues: write
|
|
17
|
-
pull-requests: write
|
|
18
|
-
|
|
19
|
-
env: # Comment env block if you do not want to apply fixes
|
|
14
|
+
env: # Comment env block if you do not want to apply fixes
|
|
20
15
|
# Apply linter fixes configuration
|
|
21
|
-
APPLY_FIXES: none
|
|
22
|
-
APPLY_FIXES_EVENT: pull_request
|
|
23
|
-
APPLY_FIXES_MODE: commit
|
|
16
|
+
APPLY_FIXES: none # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool)
|
|
17
|
+
APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all)
|
|
18
|
+
APPLY_FIXES_MODE: commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request)
|
|
24
19
|
|
|
25
20
|
concurrency:
|
|
26
21
|
group: ${{ github.ref }}-${{ github.workflow }}
|
|
27
22
|
cancel-in-progress: true
|
|
28
23
|
|
|
24
|
+
permissions: {}
|
|
25
|
+
|
|
29
26
|
jobs:
|
|
30
|
-
|
|
27
|
+
megalinter:
|
|
31
28
|
name: MegaLinter
|
|
32
29
|
runs-on: ubuntu-latest
|
|
30
|
+
|
|
31
|
+
# Give the default GITHUB_TOKEN write permission to commit and push, comment
|
|
32
|
+
# issues & post new PR; remove the ones you do not need
|
|
33
|
+
permissions:
|
|
34
|
+
contents: write
|
|
35
|
+
issues: write
|
|
36
|
+
pull-requests: write
|
|
37
|
+
|
|
33
38
|
steps:
|
|
34
39
|
# Git Checkout
|
|
35
40
|
- name: Checkout Code
|
|
36
|
-
uses: actions/checkout@
|
|
41
|
+
uses: actions/checkout@v5
|
|
37
42
|
with:
|
|
38
43
|
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
|
39
44
|
|
|
45
|
+
# If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to
|
|
46
|
+
# improve performance
|
|
47
|
+
fetch-depth: 0
|
|
48
|
+
|
|
40
49
|
# MegaLinter
|
|
41
50
|
- name: MegaLinter
|
|
42
|
-
|
|
51
|
+
|
|
43
52
|
# You can override MegaLinter flavor used to have faster performances
|
|
44
|
-
# More info at https://megalinter.io/flavors/
|
|
45
|
-
uses:
|
|
53
|
+
# More info at https://megalinter.io/latest/flavors/
|
|
54
|
+
uses: HealthDataInsight/megalinter-custom-flavor-hdi@main
|
|
55
|
+
|
|
56
|
+
id: ml
|
|
57
|
+
|
|
58
|
+
# All available variables are described in documentation
|
|
59
|
+
# https://megalinter.io/latest/configuration/
|
|
46
60
|
env:
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
|
|
61
|
+
# Validates all source when push on main, else just the git diff with
|
|
62
|
+
# main. Override with true if you always want to lint all sources
|
|
63
|
+
#
|
|
64
|
+
# To validate the entire codebase, set to:
|
|
65
|
+
# VALIDATE_ALL_CODEBASE: true
|
|
66
|
+
#
|
|
67
|
+
# To validate only diff with main, set to:
|
|
68
|
+
# VALIDATE_ALL_CODEBASE: >-
|
|
69
|
+
# ${{
|
|
70
|
+
# github.event_name == 'push' &&
|
|
71
|
+
# contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref)
|
|
72
|
+
# }}
|
|
73
|
+
VALIDATE_ALL_CODEBASE: >-
|
|
74
|
+
${{
|
|
75
|
+
github.event_name == 'push' &&
|
|
76
|
+
contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref)
|
|
77
|
+
}}
|
|
78
|
+
|
|
50
79
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
51
|
-
|
|
80
|
+
|
|
81
|
+
# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE
|
|
82
|
+
# .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
|
|
83
|
+
|
|
84
|
+
# Uncomment to disable copy-paste and spell checks
|
|
85
|
+
# DISABLE: COPYPASTE,SPELL
|
|
52
86
|
|
|
53
87
|
# # Upload MegaLinter artifacts
|
|
54
88
|
# - name: Archive production artifacts
|
|
55
|
-
# if:
|
|
56
|
-
# uses: actions/upload-artifact@
|
|
89
|
+
# if: success() || failure()
|
|
90
|
+
# uses: actions/upload-artifact@v4
|
|
57
91
|
# with:
|
|
58
92
|
# name: MegaLinter reports
|
|
93
|
+
# include-hidden-files: "true"
|
|
59
94
|
# path: |
|
|
60
95
|
# megalinter-reports
|
|
61
96
|
# mega-linter.log
|
|
62
97
|
|
|
63
|
-
# #
|
|
98
|
+
# # Set APPLY_FIXES_IF var for use in future steps
|
|
99
|
+
# - name: Set APPLY_FIXES_IF var
|
|
100
|
+
# run: |
|
|
101
|
+
# printf 'APPLY_FIXES_IF=%s\n' "${{
|
|
102
|
+
# steps.ml.outputs.has_updated_sources == 1 &&
|
|
103
|
+
# (
|
|
104
|
+
# env.APPLY_FIXES_EVENT == 'all' ||
|
|
105
|
+
# env.APPLY_FIXES_EVENT == github.event_name
|
|
106
|
+
# ) &&
|
|
107
|
+
# (
|
|
108
|
+
# github.event_name == 'push' ||
|
|
109
|
+
# github.event.pull_request.head.repo.full_name == github.repository
|
|
110
|
+
# )
|
|
111
|
+
# }}" >> "${GITHUB_ENV}"
|
|
112
|
+
|
|
113
|
+
# # Set APPLY_FIXES_IF_* vars for use in future steps
|
|
114
|
+
# - name: Set APPLY_FIXES_IF_* vars
|
|
115
|
+
# run: |
|
|
116
|
+
# printf 'APPLY_FIXES_IF_PR=%s\n' "${{
|
|
117
|
+
# env.APPLY_FIXES_IF == 'true' &&
|
|
118
|
+
# env.APPLY_FIXES_MODE == 'pull_request'
|
|
119
|
+
# }}" >> "${GITHUB_ENV}"
|
|
120
|
+
# printf 'APPLY_FIXES_IF_COMMIT=%s\n' "${{
|
|
121
|
+
# env.APPLY_FIXES_IF == 'true' &&
|
|
122
|
+
# env.APPLY_FIXES_MODE == 'commit' &&
|
|
123
|
+
# (!contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref))
|
|
124
|
+
# }}" >> "${GITHUB_ENV}"
|
|
125
|
+
|
|
126
|
+
# # Create pull request if applicable
|
|
127
|
+
# # (for now works only on PR from same repository, not from forks)
|
|
64
128
|
# - name: Create Pull Request with applied fixes
|
|
129
|
+
# uses: peter-evans/create-pull-request@v7
|
|
65
130
|
# id: cpr
|
|
66
|
-
# if:
|
|
67
|
-
# uses: peter-evans/create-pull-request@v4
|
|
131
|
+
# if: env.APPLY_FIXES_IF_PR == 'true'
|
|
68
132
|
# with:
|
|
69
133
|
# token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
|
70
134
|
# commit-message: "[MegaLinter] Apply linters automatic fixes"
|
|
71
135
|
# title: "[MegaLinter] Apply linters automatic fixes"
|
|
72
136
|
# labels: bot
|
|
137
|
+
|
|
73
138
|
# - name: Create PR output
|
|
74
|
-
# if:
|
|
139
|
+
# if: env.APPLY_FIXES_IF_PR == 'true'
|
|
75
140
|
# run: |
|
|
76
|
-
# echo "
|
|
77
|
-
# echo "
|
|
141
|
+
# echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
|
142
|
+
# echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
|
78
143
|
|
|
79
|
-
# # Push new commit if applicable
|
|
144
|
+
# # Push new commit if applicable
|
|
145
|
+
# # (for now works only on PR from same repository, not from forks)
|
|
80
146
|
# - name: Prepare commit
|
|
81
|
-
# if:
|
|
147
|
+
# if: env.APPLY_FIXES_IF_COMMIT == 'true'
|
|
82
148
|
# run: sudo chown -Rc $UID .git/
|
|
149
|
+
|
|
83
150
|
# - name: Commit and push applied linter fixes
|
|
84
|
-
#
|
|
85
|
-
#
|
|
151
|
+
# uses: stefanzweifel/git-auto-commit-action@v6
|
|
152
|
+
# if: env.APPLY_FIXES_IF_COMMIT == 'true'
|
|
86
153
|
# with:
|
|
87
|
-
# branch:
|
|
154
|
+
# branch: >-
|
|
155
|
+
# ${{
|
|
156
|
+
# github.event.pull_request.head.ref ||
|
|
157
|
+
# github.head_ref ||
|
|
158
|
+
# github.ref
|
|
159
|
+
# }}
|
|
88
160
|
# commit_message: "[MegaLinter] Apply linters fixes"
|
|
161
|
+
# commit_user_name: megalinter-bot
|
|
162
|
+
# commit_user_email: 129584137+megalinter-bot@users.noreply.github.com
|
|
@@ -3,127 +3,65 @@
|
|
|
3
3
|
# See all available variables at https://megalinter.io/configuration/
|
|
4
4
|
# and in linters documentation
|
|
5
5
|
|
|
6
|
-
APPLY_FIXES: none
|
|
7
|
-
ENABLE_LINTERS:
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
6
|
+
APPLY_FIXES: none # all, none, or list of linter keys
|
|
7
|
+
ENABLE_LINTERS: # All other linters will be disabled by default
|
|
8
|
+
- ACTION_ACTIONLINT
|
|
9
|
+
- API_SPECTRAL
|
|
10
|
+
- ARM_ARM_TTK
|
|
11
|
+
- BASH_EXEC
|
|
12
|
+
- BASH_SHELLCHECK
|
|
13
|
+
- BASH_SHFMT
|
|
14
|
+
- BICEP_BICEP_LINTER
|
|
12
15
|
- C_CLANG_FORMAT
|
|
16
|
+
- C_CPPCHECK
|
|
13
17
|
- C_CPPLINT
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- COFFEE_COFFEELINT # in Super-Linter
|
|
18
|
+
- CLOUDFORMATION_CFN_LINT
|
|
19
|
+
- COPYPASTE_JSCPD
|
|
17
20
|
- CPP_CLANG_FORMAT
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
- KOTLIN_KTLINT # in Super-Linter
|
|
34
|
-
# - LUA_LUACHECK # in Super-Linter
|
|
35
|
-
# - LUA_SELENE
|
|
36
|
-
# - LUA_STYLUA
|
|
37
|
-
- MAKEFILE_CHECKMAKE
|
|
38
|
-
# - PERL_PERLCRITIC # in Super-Linter
|
|
39
|
-
# - PHP_BUILTIN
|
|
40
|
-
# - PHP_PHPCS # in Super-Linter
|
|
41
|
-
# - PHP_PHPCSFIXER
|
|
42
|
-
# - PHP_PHPLINT # in Super-Linter
|
|
43
|
-
# - PHP_PHPSTAN # in Super-Linter
|
|
44
|
-
# - PHP_PSALM # in Super-Linter
|
|
45
|
-
# - POWERSHELL_POWERSHELL
|
|
46
|
-
# - POWERSHELL_POWERSHELL_FORMATTER
|
|
47
|
-
- PYTHON_BANDIT
|
|
48
|
-
- PYTHON_BLACK # in Super-Linter
|
|
49
|
-
- PYTHON_FLAKE8 # in Super-Linter
|
|
50
|
-
- PYTHON_ISORT # in Super-Linter
|
|
51
|
-
- PYTHON_MYPY
|
|
52
|
-
- PYTHON_PYLINT # in Super-Linter
|
|
53
|
-
- PYTHON_PYRIGHT
|
|
54
|
-
- PYTHON_RUFF
|
|
55
|
-
- R_LINTR # in Super-Linter
|
|
56
|
-
# - RAKU_RAKU # in Super-Linter
|
|
57
|
-
# - RUBY_RUBOCOP # in Super-Linter
|
|
58
|
-
- RUST_CLIPPY # in Super-Linter
|
|
59
|
-
# - SALESFORCE_LIGHTNING_FLOW_SCANNER
|
|
60
|
-
# - SALESFORCE_SFDX_SCANNER_APEX
|
|
61
|
-
# - SALESFORCE_SFDX_SCANNER_AURA
|
|
62
|
-
# - SALESFORCE_SFDX_SCANNER_LWC
|
|
63
|
-
- SCALA_SCALAFIX
|
|
64
|
-
- SQL_SQLFLUFF # in Super-Linter
|
|
65
|
-
- SQL_TSQLLINT
|
|
66
|
-
- SWIFT_SWIFTLINT
|
|
67
|
-
- TSX_ESLINT
|
|
68
|
-
- TYPESCRIPT_ES # in Super-Linter
|
|
69
|
-
# - TYPESCRIPT_PRETTIER
|
|
70
|
-
- TYPESCRIPT_STANDARD # in Super-Linter
|
|
71
|
-
# - VBDOTNET_DOTNET_FORMAT
|
|
72
|
-
|
|
73
|
-
### Formats
|
|
74
|
-
- CSS_STYLELINT # in Super-Linter
|
|
75
|
-
- ENV_DOTENV_LINTER # in Super-Linter
|
|
76
|
-
# - GRAPHQL_GRAPHQL_SCHEMA_LINTER
|
|
77
|
-
# - HTML_DJLINT # Refuses to see config file
|
|
78
|
-
- HTML_HTMLHINT # in Super-Linter
|
|
79
|
-
- JSON_ESLINT_PLUGIN_JSONC # in Super-Linter
|
|
21
|
+
- CPP_CPPCHECK
|
|
22
|
+
- CPP_CPPLINT
|
|
23
|
+
- CREDENTIALS_SECRETLINT
|
|
24
|
+
- CSS_SCSSLINT
|
|
25
|
+
- CSS_STYLELINT
|
|
26
|
+
- DOCKERFILE_DOCKERFILELINT
|
|
27
|
+
- DOCKERFILE_HADOLINT
|
|
28
|
+
- ENV_DOTENV_LINTER
|
|
29
|
+
- GHERKIN_GHERKIN_LINT
|
|
30
|
+
- GIT_GIT_DIFF
|
|
31
|
+
- GRAPHQL_GRAPHQL_SCHEMA_LINTER
|
|
32
|
+
- HTML_DJLINT
|
|
33
|
+
- HTML_HTMLHINT
|
|
34
|
+
- JAVASCRIPT_ES
|
|
35
|
+
- JSON_ESLINT_PLUGIN_JSONC
|
|
80
36
|
- JSON_JSONLINT
|
|
81
37
|
- JSON_NPM_PACKAGE_JSON_LINT
|
|
82
|
-
|
|
38
|
+
- JSON_PRETTIER
|
|
83
39
|
- JSON_V8R
|
|
84
|
-
|
|
85
|
-
-
|
|
40
|
+
- KOTLIN_DETEKT
|
|
41
|
+
- KOTLIN_KTLINT
|
|
42
|
+
- MAKEFILE_CHECKMAKE
|
|
86
43
|
- MARKDOWN_MARKDOWN_LINK_CHECK
|
|
87
44
|
- MARKDOWN_MARKDOWN_TABLE_FORMATTER
|
|
45
|
+
- MARKDOWN_MARKDOWNLINT
|
|
88
46
|
- MARKDOWN_REMARK_LINT
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
- API_SPECTRAL
|
|
102
|
-
- ARM_ARM_TTK # in Super-Linter
|
|
103
|
-
# - BICEP_BICEP_LINTER
|
|
104
|
-
- CLOUDFORMATION_CFN_LINT # in Super-Linter
|
|
105
|
-
- DOCKERFILE_HADOLINT # in Super-Linter
|
|
106
|
-
- EDITORCONFIG_EDITORCONFIG_CHECKER # in Super-Linter
|
|
107
|
-
# - GHERKIN_GHERKIN_LINT # in Super-Linter
|
|
108
|
-
- KUBERNETES_HELM
|
|
109
|
-
- KUBERNETES_KUBECONFORM
|
|
110
|
-
- KUBERNETES_KUBESCAPE
|
|
111
|
-
- PUPPET_PUPPET_LINT
|
|
112
|
-
# - SNAKEMAKE_LINT # in Super-Linter
|
|
113
|
-
# - SNAKEMAKE_SNAKEFMT # in Super-Linter
|
|
114
|
-
# - TEKTON_TEKTON_LINT # in Super-Linter
|
|
115
|
-
- TERRAFORM_TERRAFORM_FMT # in Super-Linter
|
|
116
|
-
- TERRAFORM_TERRAGRUNT # in Super-Linter
|
|
117
|
-
- TERRAFORM_TERRASCAN # in Super-Linter
|
|
118
|
-
- TERRAFORM_TFLINT # in Super-Linter
|
|
119
|
-
|
|
120
|
-
### Code quality checkers
|
|
121
|
-
- COPYPASTE_JSCPD # in Super-Linter
|
|
47
|
+
- OPENAPI_SPECTRAL
|
|
48
|
+
- PROTOBUF_PROTOLINT
|
|
49
|
+
- PYTHON_BANDIT
|
|
50
|
+
- PYTHON_BLACK
|
|
51
|
+
- PYTHON_FLAKE8
|
|
52
|
+
- PYTHON_ISORT
|
|
53
|
+
- PYTHON_MYPY
|
|
54
|
+
- PYTHON_PYLINT
|
|
55
|
+
- PYTHON_PYRIGHT
|
|
56
|
+
- PYTHON_RUFF
|
|
57
|
+
- PYTHON_RUFF_FORMAT
|
|
58
|
+
- R_LINTR
|
|
122
59
|
- REPOSITORY_CHECKOV
|
|
123
60
|
- REPOSITORY_DEVSKIM
|
|
124
61
|
- REPOSITORY_DUSTILOCK
|
|
125
62
|
- REPOSITORY_GIT_DIFF
|
|
126
|
-
- REPOSITORY_GITLEAKS
|
|
63
|
+
- REPOSITORY_GITLEAKS
|
|
64
|
+
- REPOSITORY_GOODCHECK
|
|
127
65
|
- REPOSITORY_GRYPE
|
|
128
66
|
- REPOSITORY_KICS
|
|
129
67
|
- REPOSITORY_LS_LINT
|
|
@@ -133,10 +71,24 @@ ENABLE_LINTERS: # All other linters will be disabled by default
|
|
|
133
71
|
- REPOSITORY_TRIVY
|
|
134
72
|
- REPOSITORY_TRIVY_SBOM
|
|
135
73
|
- REPOSITORY_TRUFFLEHOG
|
|
136
|
-
# - SPELL_CSPELL
|
|
137
74
|
- SPELL_LYCHEE
|
|
75
|
+
- SPELL_MISSPELL
|
|
138
76
|
- SPELL_PROSELINT
|
|
139
77
|
- SPELL_VALE
|
|
78
|
+
- SQL_SQL_LINT
|
|
79
|
+
- SQL_SQLFLUFF
|
|
80
|
+
- SQL_TSQLLINT
|
|
81
|
+
- SWIFT_SWIFTLINT
|
|
82
|
+
- TERRAFORM_CHECKOV
|
|
83
|
+
- TERRAFORM_KICS
|
|
84
|
+
- TERRAFORM_TERRAFORM_FMT
|
|
85
|
+
- TERRAFORM_TERRAGRUNT
|
|
86
|
+
- TERRAFORM_TERRASCAN
|
|
87
|
+
- TERRAFORM_TFLINT
|
|
88
|
+
- XML_XMLLINT
|
|
89
|
+
- YAML_PRETTIER
|
|
90
|
+
- YAML_V8R
|
|
91
|
+
- YAML_YAMLLINT
|
|
140
92
|
|
|
141
93
|
SHOW_ELAPSED_TIME: false
|
|
142
94
|
FILEIO_REPORTER: false
|
data/lib/way_of_working/code_linting/hdi/templates/docs/way_of_working/code-linting/index.md.tt
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
has_children: true
|
|
3
|
+
layout: page
|
|
4
|
+
status: REQUIRED
|
|
5
|
+
enforcement: manual
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Code Linting
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
We use [MegaLinter](https://megalinter.io/) for most of our linting, but we use [RuboCop](https://rubocop.org) separately for Ruby to support Minitest and Rails cops.
|
|
13
|
+
|
|
14
|
+
Linters help by:
|
|
15
|
+
- Catching syntax errors, undefined variables, and unused code early
|
|
16
|
+
- Ensuring consistent code style across teams and projects
|
|
17
|
+
- Providing automated quality improvements and best practices
|
|
18
|
+
- Saving time in code review and debugging
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
21
|
+
|
|
22
|
+
Add linting to your project:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
way_of_working init code_linting
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This copies organisational coding standards and GitHub Actions workflows to your project.
|
|
29
|
+
|
|
30
|
+
{: .note }
|
|
31
|
+
For Xcode projects, a SwiftLint build phase is automatically added to the project config.
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
Run linting locally:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
way_of_working exec code_linting
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
executes both MegaLinter and RuboCop against your code.
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
Language-specific configs are in the project root or `.github/linters/`. See [linters.md](linters.md) for the complete list.
|
|
46
|
+
|
|
47
|
+
To customise for your project, talk to a member of [<%= code_standards_team %>](https://github.com/orgs/<%= github_organisation %>/teams/<%= code_standards_team %>) and modify the config files as needed, keeping changes minimal and well documented.
|
|
48
|
+
Pull Request changing linting configs require review by a member of <%= code_standards_team %>.
|
|
49
|
+
|
|
50
|
+
## Handling Exceptions
|
|
51
|
+
|
|
52
|
+
On the rare occasions when linters flag false positives, turn off rules with comments giving your justification:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
# pylint: disable=line-too-long - URL cannot be broken
|
|
56
|
+
LONG_URL = "https://example.com/very/long/path/..."
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Documentation
|
|
60
|
+
|
|
61
|
+
Generate project documentation:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
way_of_working exec document
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
{: .important }
|
|
68
|
+
If you disagree with any linter or coding style, please fork the Way of Working code linting [repository](https://github.com/HealthDataInsight/way_of_working-code_linting-hdi) and create a pull request with your proposed changes. The current standards are a starting point intended to evolve with team consensus.
|
|
69
|
+
|
|
70
|
+
## Resources
|
|
71
|
+
|
|
72
|
+
- [MegaLinter documentation](https://megalinter.io/)
|
|
73
|
+
- [RuboCop documentation](https://rubocop.org)
|
|
74
|
+
- [Active linters list](linters.md)
|
|
@@ -12,7 +12,7 @@ rescue LoadError # rubocop:disable Lint/SuppressedException
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
loader = Zeitwerk::Loader.for_gem_extension(WayOfWorking::CodeLinting)
|
|
15
|
-
loader.
|
|
15
|
+
loader.collapse("#{__dir__}/hdi/generators/concerns")
|
|
16
16
|
loader.setup
|
|
17
17
|
|
|
18
18
|
module WayOfWorking
|
metadata
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: way_of_working-code_linting-hdi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tim Gentry
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: octokit
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '9.1'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '9.1'
|
|
13
27
|
- !ruby/object:Gem::Dependency
|
|
14
28
|
name: way_of_working
|
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -56,6 +70,7 @@ files:
|
|
|
56
70
|
- docs/way_of_working/code-linting/index.md
|
|
57
71
|
- docs/way_of_working/code-linting/linters.md
|
|
58
72
|
- lib/way_of_working/code_linting/hdi.rb
|
|
73
|
+
- lib/way_of_working/code_linting/hdi/generators/concerns/github_metadata.rb
|
|
59
74
|
- lib/way_of_working/code_linting/hdi/generators/document_linters.rb
|
|
60
75
|
- lib/way_of_working/code_linting/hdi/generators/exec.rb
|
|
61
76
|
- lib/way_of_working/code_linting/hdi/generators/init.rb
|
|
@@ -64,12 +79,13 @@ files:
|
|
|
64
79
|
- lib/way_of_working/code_linting/hdi/paths.rb
|
|
65
80
|
- lib/way_of_working/code_linting/hdi/plugin.rb
|
|
66
81
|
- lib/way_of_working/code_linting/hdi/supported_linter.rb
|
|
82
|
+
- lib/way_of_working/code_linting/hdi/templates/.eslintrc.js
|
|
67
83
|
- lib/way_of_working/code_linting/hdi/templates/.github/linters/.markdown-link-check.json
|
|
68
84
|
- lib/way_of_working/code_linting/hdi/templates/.github/linters/rubocop_defaults.yml
|
|
69
85
|
- lib/way_of_working/code_linting/hdi/templates/.github/workflows/mega-linter.yml
|
|
70
86
|
- lib/way_of_working/code_linting/hdi/templates/.mega-linter.yml
|
|
71
87
|
- lib/way_of_working/code_linting/hdi/templates/.rubocop
|
|
72
|
-
- lib/way_of_working/code_linting/hdi/templates/docs/way_of_working/code-linting/index.md
|
|
88
|
+
- lib/way_of_working/code_linting/hdi/templates/docs/way_of_working/code-linting/index.md.tt
|
|
73
89
|
- lib/way_of_working/code_linting/hdi/templates/docs/way_of_working/code-linting/linters.md.tt
|
|
74
90
|
- lib/way_of_working/code_linting/hdi/version.rb
|
|
75
91
|
homepage: https://github.com/HealthDataInsight/way_of_working-code_linting-hdi
|
|
@@ -96,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
96
112
|
- !ruby/object:Gem::Version
|
|
97
113
|
version: '0'
|
|
98
114
|
requirements: []
|
|
99
|
-
rubygems_version: 3.
|
|
115
|
+
rubygems_version: 3.3.26
|
|
100
116
|
signing_key:
|
|
101
117
|
specification_version: 4
|
|
102
118
|
summary: Way of Working plugin for HDI code linting using MegaLinter and Rubocop
|
data/lib/way_of_working/code_linting/hdi/templates/docs/way_of_working/code-linting/index.md
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
has_children: true
|
|
3
|
-
layout: page
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Code Linting
|
|
7
|
-
|
|
8
|
-
We use [MegaLinter](https://megalinter.io/) for the majority of our code lining, currently with separate Ruby testing with RuboCop.
|
|
9
|
-
|
|
10
|
-
Code linters like MegaLinter benefit developers and teams because they help improve code quality, reduce errors and inconsistencies, and streamline development. Linters analyze source code for common issues, such as syntax errors, undefined variables, and unused code, and provide suggestions and feedback for improvement.
|
|
11
|
-
|
|
12
|
-
Using a linter like MegaLinter, developers can catch and fix errors early in the development process, saving time and effort in the long run.
|
|
13
|
-
The linter also provides consistency in the codebase, helping to prevent errors caused by different team members using different styles or approaches, which can be especially valuable for large projects with many contributors or where you want staff to be able to switch between projects more efficiently.
|
|
14
|
-
|
|
15
|
-
MegaLinter is a particularly powerful linter because it supports multiple programming languages, making it a one-stop shop for developers working on projects with various languages.
|
|
16
|
-
|
|
17
|
-
{: .note }
|
|
18
|
-
We have chosen not to use the version of [RuboCop](https://rubocop.org) packaged in MegaLinter because it can't support our use of Minitest and Rails "cops". But by using our CLI command to run linting, as documented below, both RuboCop and MegaLinter will be executed against your code.
|
|
19
|
-
|
|
20
|
-
When you add the Way of Working linter to your project, it will copy our per-language organisational code styles (where they differ from defaults) into `.github/linters` and will copy the GitHub Actions workflow files into `.github/workflow`, so that linting automatically runs when you commit to GitHub.
|
|
21
|
-
|
|
22
|
-
If you add the Way of Working linter to your Xcode project, it will automatically add a Swiftlint build phase to the project config file.
|
|
23
|
-
|
|
24
|
-
{: .important }
|
|
25
|
-
If you disagree with any of the linters or linting styles that they apply, please fork the repository and create a pull request with your desired changes. The current coding standards are only intended as a starting point. A Full list of the linters we are currently using can be found [here](linters.md).
|
|
26
|
-
|
|
27
|
-
## Usage
|
|
28
|
-
|
|
29
|
-
To add [MegaLinter](https://megalinter.io/) and [RuboCop](https://rubocop.org) to your project, run the following at the command line:
|
|
30
|
-
|
|
31
|
-
way_of_working init code_linting
|
|
32
|
-
|
|
33
|
-
to run MegaLinter in your project, run:
|
|
34
|
-
|
|
35
|
-
way_of_working exec code_linting
|
|
36
|
-
|
|
37
|
-
to document your use of MegaLinter in your project, run:
|
|
38
|
-
|
|
39
|
-
way_of_working exec document
|