OpenParable
Skip to content
← Back to skills

Fix Linter Test

Testing & Quality
fix-linter-test

Fix Linter Test is an Agent Skill for testing & quality published in the oxsecurity/megalinter repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Debug and fix a failing MegaLinter linter test. Use when a linter test fails in CI or locally.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/oxsecurity/megalinter/blob/HEAD/.claude/skills/fix-linter-test/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/fix-linter-test, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Debug the failing test for $ARGUMENTS.

Steps:

  1. Find the test file in megalinter/tests/test_megalinter/linters/
  2. Check if it's auto-generated (has @generated by .automation/build.py header) — if so, fix the descriptor YAML or fixtures, NOT the test file itself
  3. Read the descriptor YAML in megalinter/descriptors/ to understand expected behavior (cli_lint_mode, config_file_name, cli_lint_errors_regex, file_extensions)
  4. Check test fixtures in .automation/test/<test_folder>/:
    • Good files must pass the linter cleanly
    • Bad files must trigger errors matching cli_lint_errors_regex
    • File extensions must match file_extensions or file_names_regex in the descriptor
  5. If a custom linter class exists in megalinter/linters/, review it for issues
  6. Common failure causes:
    • Fixture file extensions don't match descriptor's file_extensions
    • cli_lint_errors_regex doesn't match actual linter output format
    • Missing config file referenced in config_file_name
    • cli_lint_mode mismatch (file vs list_of_files vs project)
    • Version pin broken or tool not installable in Dockerfile
    • Linter behavior differs between host OS and Docker container (Linux)
  7. Reproduce in Docker (required — linters are not installed locally):
    LINTER="<descriptor_id_lowercase>_<linter_name>"
    docker buildx build --platform linux/amd64 --file linters/$LINTER/Dockerfile --tag $LINTER .
    docker run --rm --env TEST_CASE_RUN=true --env OUTPUT_DETAIL=detailed \
      --env TEST_KEYWORDS="${LINTER}_test" --env MEGALINTER_VOLUME_ROOT="." \
      --volume "$(pwd):/tmp/lint" $LINTER
    
    To run only a specific test method (e.g., test_failure):
    --env TEST_KEYWORDS="${LINTER}_test and test_failure"
    
  8. In CI, filter tests via commit message body: TEST_KEYWORDS=<linter>_test
  9. Update CHANGELOG.md only if the fix changes user-visible linter behavior (wrong error count, missed files, broken output). Add one line under Fixes in the beta section:
    - Fix <linter-name>: <what was wrong and what users now get>
    
    Do NOT add an entry for test-infrastructure-only fixes (fixture paths, test class regeneration, etc.).