MegaLinter는 저장소 소스 의 코드 , IAC , 구성 및 스크립트 의 일관성을 분석하여 개발자가 사용하는 IDE/도구 상자에 관계없이 모든 프로젝트 소스가 깨끗하고 형식화되었는지 확인하는 CI/CD 워크플로우 용 오픈 소스 도구입니다. , OX 보안 으로 구동됩니다.
62개 언어, 23개 형식, 20개 도구 형식을 지원하고 GitHub 작업 또는 모든 CI 시스템으로 즉시 사용할 수 있으며 고도로 구성 가능 하고 모든 용도에 무료입니다 .
MegaLinter는 시장의 많은 주요 CI/CD 도구와 기본적으로 통합 되어 있습니다.
MegaLinter v8로 업그레이드하세요 :)
아래로 이동하기 전에 이 README보다 사용자 탐색이 훨씬 쉬운 온라인 설명서 웹 사이트를 참조하십시오.
기술적 부채를 피하기 위해 프로젝트에는 깨끗한 코드가 포함되어야 하며, 이는 진화적인 유지 관리를 더 어렵고 시간 소모적으로 만듭니다.
코드 포맷터와 코드 린터를 사용하면 프로젝트 시작부터 프로젝트 라이프사이클의 각 단계까지 코드 베이스를 더 쉽게 읽을 수 있고 모범 사례를 준수할 수 있습니다 .
모든 개발자가 IDE에서 Linter를 사용하는 좋은 습관을 갖고 있는 것은 아니므로 코드 검토를 처리하기가 더 어렵고 길어집니다.
MegaLinter를 사용하면 귀하와 귀하의 팀이 다음과 같은 이점을 누릴 수 있습니다.
npx mega-linter-runner --install
실행하여 구성 파일을 생성합니다(node.js를 설치해야 함).참고 사항 :
super-linter/super-linter@v3
oxsecurity/megalinter@v8
로 바꾸면 됩니다).모든 린터는 최신 버전으로 자주 업그레이드되는 MegaLinter 도커 이미지에 통합되어 있습니다.
언어 | 린터 | 추가의 | |
---|---|---|---|
![]() | 세게 때리다 | bash-exec BASH_EXEC | |
![]() | 세게 때리다 | 쉘체크 BASH_SHELLCHECK | |
![]() | 세게 때리다 | shfmt BASH_SHFMT | |
![]() | 기음 | cpplint C_CPPLINT | |
![]() | 기음 | clang 형식 C_CLANG_FORMAT | |
![]() | 클로저 | clj-콘도 CLOJURE_CLJ_KONDO | |
![]() | 클로저 | cljstyle CLOJURE_CLJSTYLE | |
![]() | 커피 | 커피린트 커피_커피린트 | |
![]() | C++ (CPP) | cpplint CPP_CPPLINT | |
![]() | C++ (CPP) | clang 형식 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 | |
![]() | 자바스크립트 | 에스린트 자바스크립트_ES | |
![]() | 자바스크립트 | 기준 JAVASCRIPT_STANDARD | |
![]() | 자바스크립트 | 더 예뻐요 JAVASCRIPT_예쁘다 | |
![]() | JSX | 에스린트 JSX_ESLINT | |
![]() | 코틀린 | ktlint KOTLIN_KTLINT | |
![]() | 코틀린 | 탐지 KOTLIN_DETEKT | |
![]() | 루아 | 루아체크 LUA_LUACHECK | |
![]() | 루아 | 셀레네 LUA_SELENE | |
![]() | 루아 | 스타일루아 LUA_STYLUA | |
![]() | 메이크파일 | 체크메이크 MAKEFILE_CHECKMAKE | |
![]() | 펄 | 펄크리틱 PERL_PERLCRITIC | |
![]() | PHP | phpcs PHP_PHPCS | |
![]() | PHP | PHPstan PHP_PHSTAN | |
![]() | PHP | 찬송가 PHP_PSALM | |
![]() | PHP | PHPlint PHP_PHPLINT | |
![]() | PHP | PHP-CS-Fixer PHP_PHPCSFIXER | |
![]() | 파워쉘 | 파워쉘 POWERSHELL_POWERSHELL | |
![]() | 파워쉘 | powershell_formatter POWERSHELL_POWESHELL_FORMATTER | |
![]() | 파이썬 | 필린트 PYTHON_PYLINT | |
![]() | 파이썬 | 검은색 PYTHON_BLACK | |
![]() | 파이썬 | 플레이크8 PYTHON_FLAKE8 | |
![]() | 파이썬 | 분리하다 PYTHON_ISORT | |
![]() | 파이썬 | 적기 PYTHON_BANDIT | |
![]() | 파이썬 | 마이피 PYTHON_MYPY | |
![]() | 파이썬 | 피라이트 PYTHON_PYRIGHT | |
![]() | 파이썬 | 주름 옷깃 PYTHON_RUFF | |
![]() | 아르 자형 | 린트 R_LINTR | |
![]() | 라쿠 | 라쿠 RAKU_RAKU | |
![]() | 루비 | 루보캅 RUBY_RUBOCOP | |
![]() | 녹 | 클리피 RUST_CLIPPY | |
![]() | 세일즈포스 | sfdx-스캐너-에이펙스 SALESFORCE_SFDX_SCANNER_APEX | |
![]() | 세일즈포스 | sfdx-스캐너-aura SALESFORCE_SFDX_SCANNER_AURA | |
![]() | 세일즈포스 | sfdx-스캐너-lwc SALESFORCE_SFDX_SCANNER_LWC | |
![]() | 세일즈포스 | 번개 흐름 스캐너 SALESFORCE_LIGHTNING_FLOW_SCANNER | |
![]() | 스칼라 | 스칼라픽스 SCALA_SCALAFIX | |
![]() | SQL | SQL플러프 SQL_SQLFLUFF | |
![]() | SQL | tsqllint SQL_TSQLLINT | |
![]() | 스위프트 | 스위프트린트 SWIFT_SWIFTLINT | |
![]() | TSX | 에스린트 TSX_ESLINT | |
![]() | 타자본 | 에스린트 TYPESCRIPT_ES | |
![]() | 타자본 | TS-표준 TYPESCRIPT_STANDARD | |
![]() | 타자본 | 더 예뻐요 TYPESCRIPT_PRETTIER | |
![]() | 비주얼 베이직 .NET (VBDOTNET) | 도트넷 형식 VBDOTNET_DOTNET_FORMAT |
체재 | 린터 | 추가의 | |
---|---|---|---|
![]() | CSS | 스타일린트 CSS_STYLELINT | |
![]() | 환경 | dotenv-linter ENV_DOTENV_LINTER | |
![]() | 그래프HQL | graphql-스키마-린터 GRAPHQL_GRAPHQL_SCHEMA_LINTER | |
![]() | HTML | djlint HTML_DJLINT | |
![]() | HTML | HTML힌트 HTML_HTML힌트 | |
![]() | 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 | |
![]() | 유액 | chktex 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 | 먼저 RST_RSTFMT | |
![]() | XML | xmllint XML_XMLLINT | |
![]() | YAML | 더 예뻐요 YAML_예쁘다 | |
![]() | YAML | 야믈린트 YAML_YAMLLINT | |
![]() | YAML | v8r YAML_V8R |
툴링 형식 | 린터 | 추가의 | |
---|---|---|---|
![]() | 행동 | 액션린트 ACTION_ACTIONLINT | |
![]() | 앤시블 | 앤서블린트 ANSIBLE_ANSIBLE_LINT | |
![]() | API | 유령 같은 API_SPECTRAL | |
![]() | 팔 | 팔-ttk ARM_ARM_TTK | |
![]() | 이두근 | bicep_linter BICEP_BICEP_LINTER | |
![]() | 클라우드포메이션 | cfn-린트 CLOUDFORMATION_CFN_LINT | |
![]() | 도커파일 | 하돌린트 DOCKERFILE_HADOLINT | |
![]() | 편집기 구성 | 편집기 구성 검사기 EDITORCONFIG_EDITORCONFIG_CHECKER | |
![]() | 작은 오이 | 작은 오이 린트 GHERKIN_GHERKIN_LINT | |
![]() | 쿠버네티스 | kubeconform KUBERNETES_KUBECONFORM | |
![]() | 쿠버네티스 | 지배 KUBERNETES_HELM | |
![]() | 쿠버네티스 | 쿠베스케이프 KUBERNETES_KUBESCAPE | |
![]() | 인형 | 꼭두각시 린트 PUPPET_PUPPET_LINT | |
![]() | 스네이크메이크 | 뱀 만들기 SNAKEMAKE_LINT | |
![]() | 스네이크메이크 | 뱀 fmt SNAKEMAKE_SNAKEFMT | |
![]() | 텍톤 | 텍톤 린트 TEKTON_TEKTON_LINT | |
![]() | 테라폼 | 티플린트 TERRAFORM_TFLINT | |
![]() | 테라폼 | 테라스캔 TERRAFORM_TERRASCAN | |
![]() | 테라폼 | 테라그런트 TERRAFORM_TERRAGRUNT | |
![]() | 테라폼 | 테라폼-fmt TERRAFORM_TERRAFORM_FMT |
코드 품질 검사기 | 린터 | 추가의 | |
---|---|---|---|
![]() | 복사 붙여넣기 | jscpd COPYPASTE_JSCPD | |
![]() | 저장소 | 체크코프 REPOSITORY_CHECKOV | |
![]() | 저장소 | 데브스킴 REPOSITORY_DEVSKIM | |
![]() | 저장소 | 먼지통 REPOSITORY_DUSTILOCK | |
![]() | 저장소 | git_diff REPOSITORY_GIT_DIFF | |
![]() | 저장소 | gitleaks REPOSITORY_GITLEAKS | |
![]() | 저장소 | 그리프 REPOSITORY_GRYPE | |
![]() | 저장소 | 킥스 REPOSITORY_KICS | |
![]() | 저장소 | ls-lint REPOSITORY_LS_LINT | |
![]() | 저장소 | 비밀글 REPOSITORY_SECRETLINT | |
![]() | 저장소 | semgrep REPOSITORY_SEMGREP | |
![]() | 저장소 | Syft REPOSITORY_SYFT | |
![]() | 저장소 | 사소한 REPOSITORY_TRIVY | |
![]() | 저장소 | 사소한 일 REPOSITORY_TRIVY_SBOM | |
![]() | 저장소 | 송로버섯 REPOSITORY_TRUFFLEHOG | |
![]() | 주문 | cspell SPELL_CSPELL | |
![]() | 주문 | 프로셀린트 SPELL_PROSELINT | |
![]() | 주문 | 골짜기 SPELL_VALE | |
![]() | 주문 | 그 열매 SPELL_LYCHEE |
저장소 루트에서 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 섹션에 각 개별 linter 실행 상태를 표시합니다. 이것이 없으면 전체 실행의 전반적인 상태만 볼 수 있습니다. 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
Pull Request 댓글을 활용하려면 구성 지침을 따르세요.
DonKoning의 자세한 튜토리얼을 따라갈 수도 있습니다.
리포지토리의 루트 디렉터리에 bitbucket-pipelines.yml
파일을 생성합니다.
다음 템플릿을 복사하여 붙여넣거나 기존 파이프라인에 단계를 추가하세요.
image : atlassian/default-image:3
pipelines :
default :
- parallel :
- step :
name :
확장하다