Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix markdown linter errors #16076

Merged
merged 1 commit into from Oct 3, 2023

Conversation

apainintheneck
Copy link
Contributor

@apainintheneck apainintheneck commented Oct 3, 2023

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

v0.13 of the markdownlint gem just got released and it has a few new rules which our docs ended up failing. This fixes those linter errors so that CI is no longer red.

Rules:
MD055 - Tables: Each row must start and end with a '|'
MD057 - Tables: In the second row every column must have at least '---',
possibly surrounded with alignment ':' chars

Related to: #16070

For the curious, this is how you can fix the MD055 linter error. It doesn't seem like this linter has a built-in fix option.

$ gawk -i inplace '
BEGIN {
  cmd = "bundle exec rake lint"
  while((cmd | getline line) > 0) {
    split(line, arr, ":")
    filename = arr[1]
    if(filename !~ /\.md$/) continue

    lineno = arr[2]
    if(lineno !~ /^[0-9]+$/) continue

    error = arr[3]
    if(error !~ /^ MD[0-9][0-9][0-9]/) continue

    files[filename] = 1
    lines[filename, lineno] = error
  }
  close(cmd)

  for(filename in files) ARGV[ARGC++] = filename
}

files[FILENAME] && lines[FILENAME, FNR] ~ /MD055/ {
  sub(/^[ ]*\|[ ]*/, "")
  sub(/[ ]*\|[ ]*$/, "")
  printf("| %s |\n", $0)
  next
}

{ print }
'

v0.13 of the `markdownlint` gem just got released and it has
a few new rules which are docs ended up failing. This fixes
those linter errors so that CI is no longer red.

Rules:
MD055 - Tables: Each row must start and end with a '|'
MD057 - Tables: In the second row every column must have at least '---',
        possibly surrounded with alignment ':' chars
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks great, thanks again @apainintheneck and particularly for the PR and quick turnaround here.

@MikeMcQuaid MikeMcQuaid merged commit d0eef12 into Homebrew:master Oct 3, 2023
27 checks passed
@buildpulse
Copy link

buildpulse bot commented Oct 3, 2023

Known disruptive tests have failed for this pull request.

Commit SHA: d0eef12
Build URL: https://github.com/Homebrew/brew/actions/runs/6392568960/attempts/1

Suite Name Test Name Details
rspec SystemCommand with both STDOUT and STDERR output from upstream with print_stdout its result stderr is expected to eq "2\n4\n6\n"

@EricFromCanada
Copy link
Member

I'd have simply disabled rule MD055 in docs/.mdl_style.rb, since leading and trailing pipes are not required for GitHub Flavored Markdown.

@apainintheneck
Copy link
Contributor Author

@EricFromCanada Feel free to change it if you think it's important. I was having fun using awk so I wasn't thinking about if there was a better way to handle this.

@EricFromCanada
Copy link
Member

@apainintheneck ¯\_(ツ)_/¯

@github-actions github-actions bot added the outdated PR was locked due to age label Nov 5, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants