MegaLinter は、リポジトリ ソース内のコード、 IAC 、構成、およびスクリプトの一貫性を分析するCI/CD ワークフロー用のオープンソースツールで、すべてのプロジェクト ソースがクリーンであり、開発者が使用する IDE/ツールボックスに関係なくフォーマットされていることを確認します。 OX Securityを利用しています。
62 の言語、 23 の形式、 20 のツール形式をサポートし、GitHub アクションまたは任意の CI システムとしてすぐに使用でき、高度に構成可能であらゆる用途に無料です。
MegaLinter は、市場の主要な CI/CD ツールの多くとネイティブに統合されています。
MegaLinter v8 にアップグレードします:)
以下に進む前に、この README よりもユーザー ナビゲーションがはるかに簡単なオンライン ドキュメント Web サイトを参照してください。
技術的負債を避けるために、プロジェクトにはクリーンなコードが含まれている必要があります。技術的負債により、進化的なメンテナンスが困難になり、時間がかかります。
コード フォーマッタとコード リンターを使用すると、コード ベースが読みやすくなり、キックオフからプロジェクト ライフサイクルの各ステップに至るまで、ベスト プラクティスが尊重されます。
すべての開発者が IDE でリンターを使用する良い習慣を持っているわけではないため、コード レビューの処理が難しくなり、時間がかかります。
MegaLinter を使用すると、あなたとあなたのチームに次の利点があります。
npx mega-linter-runner --install
実行して構成ファイルを生成します (node.js をインストールする必要があります)注:
super-linter/super-linter@v3
をoxsecurity/megalinter@v8
に置き換えるだけです)。すべてのリンターは MegaLinter Docker イメージに統合されており、最新バージョンに頻繁にアップグレードされます。
言語 | リンター | 追加 | |
---|---|---|---|
![]() | バッシュ | bash-exec BASH_EXEC | |
![]() | バッシュ | シェルチェック BASH_SHELLCHECK | |
![]() | バッシュ | シュフムト BASH_SHFMT | |
![]() | C | CPプリント C_CPPLINT | |
![]() | C | クラン形式 C_CLANG_FORMAT | |
![]() | クロージャー | CLJ近藤 CLOJURE_CLJ_KONDO | |
![]() | クロージャー | cljstyle CLOJURE_CLJSTYLE | |
![]() | コーヒー | コーヒー糸くず COFFEE_COFFEELINT | |
![]() | C++ (CPP) | CPプリント CPP_CPPLINT | |
![]() | C++ (CPP) | クラン形式 CPP_CLANG_FORMAT | |
![]() | C# (CSHARP) | ドットネット形式 CSHARP_DOTNET_FORMAT | |
![]() | C# (CSHARP) | シャルピア CSHARP_CSHARPIER | |
![]() | C# (CSHARP) | ロズリネーター CSHARP_ROSLYNATOR | |
![]() | ダーツ | ダータナライザー DART_DARTANALYZER | |
![]() | 行く | ゴランシリント GO_GOLANGCI_LINT | |
![]() | 行く | 復活する GO_REVIVE | |
![]() | グルービー | npm-groovy-lint GROOVY_NPM_GROOVY_LINT | |
![]() | ジャワ | チェックスタイル JAVA_CHECKSTYLE | |
![]() | ジャワ | 午後 JAVA_PMD | |
![]() | ジャバスクリプト | エスリント JAVASCRIPT_ES | |
![]() | ジャバスクリプト | 標準 JAVASCRIPT_STANDARD | |
![]() | ジャバスクリプト | より美しい JAVASCRIPT_PRETTIER | |
![]() | JSX | エスリント JSX_ESLINT | |
![]() | コトリン | クトリント KOTLIN_KTLINT | |
![]() | コトリン | 検出する KOTLIN_DETEKT | |
![]() | ルア | ルアチェック LUA_LUACHECK | |
![]() | ルア | セレーネ LUA_SELENE | |
![]() | ルア | スタイラス LUA_STYLUA | |
![]() | メイクファイル | チェックメイク MAKEFILE_CHECKMAKE | |
![]() | パール | パールクリティック PERL_PERLCRITIC | |
![]() | PHP | phpcs PHP_PHPCS | |
![]() | PHP | phpstan PHP_PHPSTAN | |
![]() | PHP | 詩篇 PHP_PSALM | |
![]() | PHP | phplint PHP_PHPLINT | |
![]() | PHP | php-cs-fixer PHP_PHPCSFIXER | |
![]() | パワーシェル | パワーシェル POWERSHELL_パワーシェル | |
![]() | パワーシェル | powershell_formatter POWERSHELL_POWERSHELL_FORMATTER | |
![]() | ニシキヘビ | パイリント PYTHON_PYLINT | |
![]() | ニシキヘビ | 黒 パイソン_ブラック | |
![]() | ニシキヘビ | フレーク8 PYTHON_FLAKE8 | |
![]() | ニシキヘビ | 分離する PYTHON_ISORT | |
![]() | ニシキヘビ | 盗賊 PYTHON_BANDIT | |
![]() | ニシキヘビ | マイピー PYTHON_MYPY | |
![]() | ニシキヘビ | 著作権 PYTHON_PYRIGHT | |
![]() | ニシキヘビ | ラフ パイソン_ラフ | |
![]() | R | リンター R_LINTR | |
![]() | 楽 | 楽 楽楽 | |
![]() | ルビー | ルボコップ ルビー_ルボコップ | |
![]() | さび | クリッピー RUST_CLIPPY | |
![]() | セールスフォース | sfdx スキャナー apex 販売力_SFDX_SCANNER_APEX | |
![]() | セールスフォース | sfdx スキャナーオーラ 販売力_SFDX_SCANNER_AURA | |
![]() | セールスフォース | sfdx スキャナー lwc 販売力_SFDX_SCANNER_LWC | |
![]() | セールスフォース | ライトニングフロースキャナー SALESFORCE_LIGHTNING_FLOW_SCANNER | |
![]() | スカラ | スカラフィックス SCALA_SCALAFIX | |
![]() | SQL | スクフルフ SQL_SQLFLUFF | |
![]() | SQL | ツクリント SQL_TSQLLINT | |
![]() | 迅速 | スウィフトリント SWIFT_SWIFTLINT | |
![]() | TSX | エスリント TSX_ESLINT | |
![]() | タイプスクリプト | エスリント TYPESCRIPT_ES | |
![]() | タイプスクリプト | TS標準 TYPESCRIPT_STANDARD | |
![]() | タイプスクリプト | より美しい TYPESCRIPT_PRETTIER | |
![]() | Visual Basic .NET (VBDOTNET) | ドットネット形式 VBDOTNET_DOTNET_FORMAT |
形式 | リンター | 追加 | |
---|---|---|---|
![]() | CSS | スタイルリント CSS_STYLELINT | |
![]() | 環境 | dotenv-linter ENV_DOTENV_LINTER | |
![]() | グラフキュール | グラフql-スキーマ-リンター GRAPHQL_GRAPHQL_SCHEMA_LINTER | |
![]() | HTML | ジリント HTML_DJLINT | |
![]() | HTML | htmlヒント HTML_HTMLHINT | |
![]() | JSON | jsonlint JSON_JSONLINT | |
![]() | JSON | eslint-プラグイン-jsonc JSON_ESLINT_PLUGIN_JSONC | |
![]() | JSON | v8r JSON_V8R | |
![]() | JSON | より美しい JSON_PRETTIER | |
![]() | JSON | npm-パッケージ-json-lint JSON_NPM_PACKAGE_JSON_LINT | |
![]() | ラテックス | チェックテックス LATEX_CHKTEX | |
![]() | マークダウン | マークダウンリント MARKDOWN_MARKDOWNLINT | |
![]() | マークダウン | コメント-糸くず MARKDOWN_REMARK_LINT | |
![]() | マークダウン | マークダウンリンクチェック MARKDOWN_MARKDOWN_LINK_CHECK | |
![]() | マークダウン | マークダウンテーブルフォーマッタ MARKDOWN_MARKDOWN_TABLE_FORMATTER | |
![]() | プロトバッファ | プロトリント PROTOBUF_PROTOLINT | |
![]() | RST | 最初のリント RST_RST_LINT | |
![]() | RST | 最初のチェック RST_RSTCHECK | |
![]() | RST | rstfmt RST_RSTFMT | |
![]() | XML | xmlint XML_XMLLINT | |
![]() | YAML | より美しい YAML_PRETTIER | |
![]() | YAML | ヤムリント YAML_YAMLINT | |
![]() | YAML | v8r YAML_V8R |
ツーリングフォーマット | リンター | 追加 | |
---|---|---|---|
![]() | アクション | アクションリント ACTION_ACTIONLINT | |
![]() | アニブル | ansible-lint ANSIBLE_ANSIBLE_LINT | |
![]() | API | スペクトル API_SPECTRAL | |
![]() | アーム | 腕-ttk ARM_ARM_TTK | |
![]() | 力こぶ | 上腕二頭筋_リンター BICEP_BICEP_LINTER | |
![]() | 雲の形成 | cfn-lint CLOUDFORMATION_CFN_LINT | |
![]() | ドッカーファイル | ハドリント DOCKERFILE_HADOLINT | |
![]() | エディタ設定 | エディタ設定チェッカー EDITORCONFIG_EDITORCONFIG_CHECKER | |
![]() | ガーキン | ガーキンの糸くず GHERKIN_GHERKIN_LINT | |
![]() | Kubernetes | キューブコンフォーム KUBERNETES_KUBECONFORM | |
![]() | Kubernetes | 舵 KUBERNETES_HELM | |
![]() | Kubernetes | キューブスケープ KUBERNETES_KUBESCAPE | |
![]() | 人形 | 人形の糸くず PUPPET_PUPPET_LINT | |
![]() | スネークメイク | ヘビメイク SNAKEMAKE_LINT | |
![]() | スネークメイク | スネークfmt SNAKEMAKE_SNAKEFMT | |
![]() | テクトン | テクトンリント TEKTON_TEKTON_LINT | |
![]() | テラフォーム | フリント TERRAFORM_TFLINT | |
![]() | テラフォーム | テラスキャン TERRAFORM_TERRASCAN | |
![]() | テラフォーム | テラグラント TERRAFORM_TERRAGRUNT | |
![]() | テラフォーム | terraform-fmt TERRAFORM_TERRAFORM_FMT |
コード品質チェッカー | リンター | 追加 | |
---|---|---|---|
![]() | コピーペースト | jscpd コピーペースト_JSCPD | |
![]() | リポジトリ | チェコフ REPOSITORY_CHECKOV | |
![]() | リポジトリ | デブスキム REPOSITORY_DEVSKIM | |
![]() | リポジトリ | ダストロック REPOSITORY_DUSTILOCK | |
![]() | リポジトリ | git_diff REPOSITORY_GIT_DIFF | |
![]() | リポジトリ | ギトリークス REPOSITORY_GITLEAKS | |
![]() | リポジトリ | 不平不満 REPOSITORY_GRYPE | |
![]() | リポジトリ | キック REPOSITORY_KICS | |
![]() | リポジトリ | ls-lint REPOSITORY_LS_LINT | |
![]() | リポジトリ | 秘密の糸くず REPOSITORY_SECRETLINT | |
![]() | リポジトリ | セムグレップ REPOSITORY_SEMGREP | |
![]() | リポジトリ | シフト リポジトリ_SYFT | |
![]() | リポジトリ | つまらない REPOSITORY_TRIVY | |
![]() | リポジトリ | トリビースボム REPOSITORY_TRIVY_SBOM | |
![]() | リポジトリ | トリュフホッグ REPOSITORY_TRUFFLEHOG | |
![]() | スペル | 呪文 SPELL_CSPELL | |
![]() | スペル | プロセリント SPELL_PROSELINT | |
![]() | スペル | 谷 SPELL_VALE | |
![]() | スペル | ライチ スペル_ライチ |
リポジトリのルートでnpx mega-linter-runner --install
を実行し、質問に答えるだけで、すぐに使用できる MegaLinter の設定ファイルが生成されます :)
次の手順の例では、最新の MegaLinter 安定バージョン ( v8 、常に最新リリースに対応) を使用しています。
oxsecurity/megalinter:v8
oxsecurity/megalinter@v8
ベータ版(メインブランチの内容に相当)もご利用いただけます
oxsecurity/megalinter:beta
oxsecurity/megalinter@beta
.github/workflows/mega-linter.yml
という新しいファイルを作成します。注:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
を渡すと、 MegaLinter はプル リクエストの Checks セクションで実行される個々のリンターのステータスをマークします。これを行わないと、完全な実行の全体的なステータスのみが表示されます。 GitHub Secret は GitHub によって自動的に設定されるため、設定する必要はありません。アクションに渡すだけで済みます。GITHUB_TARGET_URL
環境変数が存在する場合は Github Pull Request のステータスを取得できます。リポジトリには、以下のようなGitHubアクションを含む.github/workflows
フォルダーが必要です。
.github/workflows/mega-linter.yml
---
# MegaLinter GitHub Action configuration file
# More info at https://megalinter.io
name : MegaLinter
on :
# Trigger mega-linter at every push. Action will also be visible from Pull Requests to main
push : # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions)
pull_request :
branches : [master, main]
env : # Comment env block if you don't want to apply fixes
# Apply linter fixes configuration
APPLY_FIXES : all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool)
APPLY_FIXES_EVENT : pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all)
APPLY_FIXES_MODE : commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request)
concurrency :
group : ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress : true
jobs :
megalinter :
name : MegaLinter
runs-on : ubuntu-latest
permissions :
# Give the default GITHUB_TOKEN write permission to commit and push, comment issues & post new PR
# Remove the ones you do not need
contents : write
issues : write
pull-requests : write
steps :
# Git Checkout
- name : Checkout Code
uses : actions/checkout@v4
with :
token : ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
fetch-depth : 0 # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to improve performances
# MegaLinter
- name : MegaLinter
id : ml
# You can override MegaLinter flavor used to have faster performances
# More info at https://megalinter.io/flavors/
uses : oxsecurity/megalinter@v8
env :
# All available variables are described in documentation
# https://megalinter.io/configuration/
VALIDATE_ALL_CODEBASE : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
# DISABLE: COPYPASTE,SPELL # Uncomment to disable copy-paste and spell checks
# Upload MegaLinter artifacts
- name : Archive production artifacts
if : success() || failure()
uses : actions/upload-artifact@v4
with :
name : MegaLinter reports
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
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')
uses : peter-evans/create-pull-request@v6
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 "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request 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/main' && (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
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/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
uses : stefanzweifel/git-auto-commit-action@v4
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 : [email protected]
リポジトリのルートに.gitlab-ci.yml
ファイルを作成または更新します。
# MegaLinter GitLab CI job configuration file
# More info at https://megalinter.io/
mega-linter :
stage : test
# You can override MegaLinter flavor used to have faster performances
# More info at https://megalinter.io/flavors/
image : oxsecurity/megalinter:v8
script : [ "true" ] # if script: ["true"] doesn't work, you may try -> script: [ "/bin/bash /entrypoint.sh" ]
variables :
# All available variables are described in documentation
# https://megalinter.io/configuration/
DEFAULT_WORKSPACE : $CI_PROJECT_DIR
# ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
artifacts :
when : always
paths :
- megalinter-reports
expire_in : 1 week
Gitlab アクセス トークンを作成し、プロジェクトの CI/CD マスク変数の変数GITLAB_ACCESS_TOKEN_MEGALINTERで定義します。トークン (プロジェクト トークンなど) が、マージ リクエストにコメントするための適切なロール (少なくとも開発者) であることを確認してください。
R2Devops の友人たちは、Gitlab-CI MegaLinter ワークフローをオープンソース テンプレート マーケットプレイスにパッケージ化しており、MegaLinter の結果を Gitlab コード品質レポートに投稿できます。
次の Azure Pipelines YAML テンプレートを使用します。
ビルド検証ブランチ ポリシーは、単一のリポジトリに対して、またはすべてのリポジトリに対して構成できます。すべてのリポジトリにわたって構成する場合、パイプラインは中央リポジトリに保存されます。
コード リポジトリ内のazure-pipelines.yaml
ファイルに以下を追加します。
# Run MegaLinter to detect linting and security issues
- job : MegaLinter
pool :
vmImage : ubuntu-latest
steps :
# Checkout repo
- checkout : self
# Pull MegaLinter docker image
- script : docker pull oxsecurity/megalinter:v8
displayName : Pull MegaLinter
# Run MegaLinter
- script : |
docker run -v $(System.DefaultWorkingDirectory):/tmp/lint
--env-file <(env | grep -e SYSTEM_ -e BUILD_ -e TF_ -e AGENT_)
-e SYSTEM_ACCESSTOKEN=$(System.AccessToken)
-e GIT_AUTHORIZATION_BEARER=$(System.AccessToken)
oxsecurity/megalinter:v8
displayName: Run MegaLinter
# Upload MegaLinter reports
- task : PublishPipelineArtifact@1
condition : succeededOrFailed()
displayName : Upload MegaLinter reports
inputs :
targetPath : " $(System.DefaultWorkingDirectory)/megalinter-reports/ "
artifactName : MegaLinterReport
別のリポジトリ (例: 「MegaLinter」 リポジトリ) 内のazure-pipelines.yaml
ファイルに以下を追加します。
# Run MegaLinter to detect linting and security issues
trigger : none
pool :
vmImage : ubuntu-latest
variables :
repoName : $[ replace(split(variables['System.PullRequest.SourceRepositoryURI'], '/')[6], '%20', ' ') ]
steps :
# Checkout triggering repo
- checkout : git://$(System.TeamProject)/$(repoName)@$(System.PullRequest.SourceBranch)
displayName : Checkout Triggering Repository
# Pull MegaLinter docker image
- script : docker pull oxsecurity/megalinter:v8
displayName : Pull MegaLinter
# Run MegaLinter
- script : |
docker run -v $(System.DefaultWorkingDirectory):/tmp/lint
--env-file <(env | grep -e SYSTEM_ -e BUILD_ -e TF_ -e AGENT_)
-e SYSTEM_ACCESSTOKEN=$(System.AccessToken)
-e GIT_AUTHORIZATION_BEARER=$(System.AccessToken)
oxsecurity/megalinter:v8
displayName: Run MegaLinter
# Upload MegaLinter reports
- task : PublishPipelineArtifact@1
condition : succeededOrFailed()
displayName : MegaLinter Report
inputs :
targetPath : $(System.DefaultWorkingDirectory)/megalinter-reports/
artifactName : MegaLinterReport
プル リクエストのコメントを活用するには、設定手順に従ってください。
DonKoning によるこの詳細なチュートリアルに従うこともできます。
リポジトリのルート ディレクトリにbitbucket-pipelines.yml
ファイルを作成します。
次のテンプレートをコピーして貼り付けるか、ステップを既存のパイプラインに追加します。
image : atlassian/default-image:3
pipelines :
default :
- parallel :
- step :
name :
拡大する