Skip to content

fix: make markdown lint blocking for changed files#271

Merged
marcusquinn merged 2 commits intomainfrom
fix/markdown-lint-blocking
Jan 31, 2026
Merged

fix: make markdown lint blocking for changed files#271
marcusquinn merged 2 commits intomainfrom
fix/markdown-lint-blocking

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Jan 31, 2026

Summary

Makes markdown lint checks blocking for changed files while keeping them advisory for the full codebase. This prevents markdown formatting issues (like MD031 - blank lines around code blocks) from being merged.

Changes

  • linters-local.sh: Modified check_markdown_lint() to:

    • Track check_mode ("changed" vs "all")
    • Return exit 1 (blocking) when violations found in changed files
    • Keep advisory mode (exit 0) for full codebase scan
    • Simplified fallback when markdownlint not installed
  • AGENTS.md: Added "blank lines around code blocks (MD031)" to Quality line as a reminder

Why

PR #269 introduced an MD031 violation that was caught by Codacy post-merge, requiring a follow-up fix PR #270. This change ensures such issues are caught during preflight checks.

Testing

  1. With markdownlint installed: Changed files with violations → blocking (exit 1)
  2. With markdownlint installed: No violations → pass (exit 0)
  3. Without markdownlint: Advisory warning only (exit 0)

Summary by CodeRabbit

Documentation

  • Updated quality criteria to include new formatting requirements for code blocks in markdown documentation.

Chores

  • Enhanced markdown linting workflow with improved error detection and violation counting, introducing blocking versus advisory check modes, better fallback handling when tools are unavailable, and improved behavior in non-repository environments.

✏️ Tip: You can customize this high-level summary in your review settings.

- Modified check_markdown_lint() to track check_mode (changed vs all)
- Changed files now return exit 1 (blocking) when violations found
- All files fallback remains advisory (exit 0)
- Simplified fallback when markdownlint not installed (advisory only)
- Added MD031 reminder to AGENTS.md Quality line

This prevents markdown lint issues like MD031 (blank lines around
code blocks) from being merged, while not requiring cleanup of all
pre-existing issues in the codebase.
@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the quality gates for markdown files by making linting a blocking requirement for any content modified within a pull request. This change ensures that new or updated markdown adheres to established style guidelines, proactively preventing common formatting errors like MD031 (blank lines around code blocks) from being introduced. The system maintains an advisory mode for the existing codebase, allowing for a focused approach on new contributions while providing flexibility for addressing legacy issues.

Highlights

  • Blocking Markdown Linting for Changed Files: Markdown lint checks are now configured to be blocking (return exit code 1) for any files that have been modified in the pull request, preventing formatting issues from being merged.
  • Advisory Mode for Full Codebase: The markdown lint checks remain advisory (return exit code 0) when scanning the entire codebase, allowing for gradual cleanup of pre-existing issues without blocking new development.
  • Script Logic Enhancement: The linters-local.sh script has been updated to introduce a check_mode variable, which dynamically determines whether the linting should be blocking or advisory based on the scope of files being checked.
  • Quality Standard Documentation: The AGENTS.md file has been updated to explicitly include 'blank lines around code blocks (MD031)' as a quality standard, reinforcing the importance of this specific markdown rule.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively makes markdown linting blocking for changed files while keeping it advisory for the full codebase, which is a great improvement to catch formatting issues early. The changes in linters-local.sh are well-implemented, especially the simplification of the fallback logic for when markdownlint is not installed. I have one suggestion to refactor a small portion of the script to improve readability and reduce a duplicated check.

Comment on lines 408 to 422
if [[ "$check_mode" == "changed" ]]; then
print_error "Markdown: $violations style issues in changed files (BLOCKING)"
else
print_warning "Markdown: $violations style issues found (advisory)"
fi
echo "$lint_output" | head -10
if [[ $violations -gt 10 ]]; then
echo "... and $((violations - 10)) more"
fi
print_info "Run: markdownlint --fix .agent/**/*.md to auto-fix"
# Non-blocking for now - many pre-existing issues
# TODO: Make blocking after fixing existing issues
print_info "Run: markdownlint --fix <file> to auto-fix"
# Blocking for changed files, advisory for all files
if [[ "$check_mode" == "changed" ]]; then
return 1
fi
return 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for handling violations can be simplified to improve readability and avoid checking the value of check_mode twice. You can first print the violation details (which are common to both modes) and then have a single if/else block to handle the mode-specific logic of printing the final message and returning the correct exit code.

Suggested change
if [[ "$check_mode" == "changed" ]]; then
print_error "Markdown: $violations style issues in changed files (BLOCKING)"
else
print_warning "Markdown: $violations style issues found (advisory)"
fi
echo "$lint_output" | head -10
if [[ $violations -gt 10 ]]; then
echo "... and $((violations - 10)) more"
fi
print_info "Run: markdownlint --fix .agent/**/*.md to auto-fix"
# Non-blocking for now - many pre-existing issues
# TODO: Make blocking after fixing existing issues
print_info "Run: markdownlint --fix <file> to auto-fix"
# Blocking for changed files, advisory for all files
if [[ "$check_mode" == "changed" ]]; then
return 1
fi
return 0
echo "$lint_output" | head -10
if [[ $violations -gt 10 ]]; then
echo "... and $((violations - 10)) more"
fi
print_info "Run: markdownlint --fix <file> to auto-fix"
if [[ "$check_mode" == "changed" ]]; then
print_error "Markdown: $violations style issues in changed files (BLOCKING)"
return 1
else
print_warning "Markdown: $violations style issues found (advisory)"
return 0
fi

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 411 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Jan 31 23:20:34 UTC 2026: Code review monitoring started
Sat Jan 31 23:20:35 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 411
Sat Jan 31 23:20:35 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Sat Jan 31 23:20:37 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 411
  • VULNERABILITIES: 0

Generated on: Sat Jan 31 23:22:02 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@augmentcode
Copy link

augmentcode bot commented Jan 31, 2026

🤖 Augment PR Summary

Summary: Makes local Markdown linting block merges when style violations are introduced in changed Markdown files, while keeping full codebase scans advisory.

Changes:

  • Updated .agent/scripts/linters-local.sh to track whether linting is running on changed files vs all files (check_mode)
  • Returns exit 1 (blocking) when markdownlint finds violations in changed files, but exits 0 for advisory full-scan violations
  • Simplified the no-markdownlint fallback to a warning-only path with install guidance
  • Updated .agent/AGENTS.md quality reminder to call out MD031 (blank lines around code blocks)

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

if [[ $violations -gt 0 ]]; then
print_warning "Markdown: $violations style issues found"
if [[ "$check_mode" == "changed" ]]; then
print_error "Markdown: $violations style issues in changed files (BLOCKING)"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

violations is derived via grep -c "MD[0-9]" || echo "0", which can yield a non-numeric value (e.g., 0 0) when markdownlint emits non-MD errors; that can make this new blocking path misbehave or hide a real markdownlint failure as a clean run. Consider ensuring violations is always a single integer and treating non-rule output from markdownlint as an error case.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 31, 2026

Walkthrough

This PR refactors markdown linting logic to distinguish between blocking and advisory modes, implementing three-stage file selection (uncommitted changes, branch diff, fallback to all tracked .md files). Additionally, quality documentation is updated to include MD031 formatting standards for code blocks.

Changes

Cohort / File(s) Summary
Documentation & Standards
.agent/AGENTS.md
Updated Quality description to include MD031 (blank lines around code blocks) formatting requirement.
Linting Script Refactoring
.agent/scripts/linters-local.sh
Introduced check_mode variable to enforce blocking vs. advisory behavior. Implemented three-stage markdown file selection (uncommitted changes → branch diff → fallback to all tracked files). Enhanced violation counting with numeric guards and mode-aware return codes. Simplified fallback path when markdownlint unavailable. Enforces advisory mode for non-git-repo scenarios.

Sequence Diagram

sequenceDiagram
    participant Script as linters-local.sh
    participant Git as Git Repository
    participant FileSystem as File System
    participant Linter as markdownlint
    participant Output as Output Handler

    Script->>Git: Check if uncommitted changes exist
    alt Uncommitted files found
        Git-->>Script: Return uncommitted .md files
        Script->>Script: Set check_mode=blocking
        Script->>FileSystem: Select uncommitted files
    else No uncommitted files
        Script->>Git: Get diff against main branch
        alt Branch diff exists
            Git-->>Script: Return differing .md files
            Script->>Script: Set check_mode=blocking
        else No branch diff
            Script->>FileSystem: List all tracked .md files
            Script->>Script: Set check_mode=advisory
        end
    end
    
    Script->>Linter: Run markdownlint on selected files
    alt markdownlint available
        Linter-->>Script: Return violations (parsed count)
        Script->>Script: Validate count is numeric
        alt Violations found
            Script->>Output: Show sample issues
        end
    else markdownlint unavailable
        Script->>Script: Set check_mode=advisory
        Script->>Output: Display installation suggestion
    end
    
    Script->>Output: Emit mode-aware message
    alt check_mode=blocking
        Output-->>Script: Return non-zero exit code
    else check_mode=advisory
        Output-->>Script: Return success (0)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🔍 Markdown lines now stand their ground,
Blocking strict, advisory's sound,
Three-stage checks dance left and right,
Quality standards burning bright ✨
Zero debt, the DevOps way—pristine!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: making markdown linting blocking for changed files to prevent formatting issues from being merged.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/markdown-lint-blocking

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Ensure violations count is always a valid integer
- Reorder logic to show violations before mode-specific message
- Single check_mode conditional for message and return code
@sonarqubecloud
Copy link

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 411 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Jan 31 23:24:20 UTC 2026: Code review monitoring started
Sat Jan 31 23:24:21 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 411
Sat Jan 31 23:24:21 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Sat Jan 31 23:24:23 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 411
  • VULNERABILITIES: 0

Generated on: Sat Jan 31 23:25:50 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@marcusquinn marcusquinn merged commit e91794d into main Jan 31, 2026
7 of 9 checks passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.agent/scripts/linters-local.sh (1)

398-431: ⚠️ Potential issue | 🟠 Major

Handle markdownlint execution errors separately from rule violations.

When markdownlint itself fails (bad config, invalid arguments, syntax errors), the error output won't match the MD[0-9] rule pattern, causing violation_count=0 and the function to return 0 (success)—even in blocking mode. This bypasses the reliability requirement. Capture the tool's exit code and treat execution failures as blocking errors in changed-file mode and advisory warnings in full-scan mode.

🔧 Suggested fix
-        lint_output=$($markdownlint_cmd $md_files 2>&1) || true
+        local lint_exit=0
+        lint_output=$($markdownlint_cmd $md_files 2>&1) || lint_exit=$?
         
         if [[ -n "$lint_output" ]]; then
             # Count violations - ensure single integer (grep -c can fail, use wc -l as fallback)
             local violation_count
             violation_count=$(echo "$lint_output" | grep -c "MD[0-9]" 2>/dev/null) || violation_count=0
             # Ensure it's a valid integer
             if ! [[ "$violation_count" =~ ^[0-9]+$ ]]; then
                 violation_count=0
             fi
             violations=$violation_count
 
             if [[ $violations -gt 0 ]]; then
                 # Show violations first (common to both modes)
                 echo "$lint_output" | head -10
                 if [[ $violations -gt 10 ]]; then
                     echo "... and $((violations - 10)) more"
                 fi
                 print_info "Run: markdownlint --fix <file> to auto-fix"
                 
                 # Mode-specific message and return code
                 if [[ "$check_mode" == "changed" ]]; then
                     print_error "Markdown: $violations style issues in changed files (BLOCKING)"
                     return 1
                 else
                     print_warning "Markdown: $violations style issues found (advisory)"
                     return 0
                 fi
+            elif [[ $lint_exit -ne 0 ]]; then
+                print_error "Markdown: markdownlint failed (non-rule error)"
+                if [[ "$check_mode" == "changed" ]]; then
+                    return 1
+                else
+                    return 0
+                fi
             fi
         fi
         print_success "Markdown: No style issues found"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant