gitops-catalog icon indicating copy to clipboard operation
gitops-catalog copied to clipboard

Yamllint

Open strangiato opened this issue 3 years ago • 6 comments

I am looking at adding yamllint to the repo/github actions to enforce better formatting.

@pittar @gnunn1 any thoughts or opinions on adding this to the current configuration?

I also wanted to get your thoughts on a few of the settings that are the most common problems in the repo:

  • Line Length: This is a likely disable. There are a lot of lines that are longer including some scripts. This is going to be very challenging to work around and is probably better to simply disable.
  • --- at the start of files: I'm not a huge fan of this and would be happy to turn it off.
  • New line at end of line: No objection for me on this one. I like it since it prevents weird merge issues if you add content to the end of a file.
  • Wrong indentation: This seems to be two different issues. Some are actual indentation issues where objects are either 3 spaces instead of 2 or something else like that. The other issue is with list objects not indented under the parent. For example:
myList:
- name: myObject

instead of

myList:
  - name: myObject

The rest of the errors seem pretty minor but a count of all of the errors can be found below:

Row Labels Count of Errors
[error] no new line character at the end of file (new-line-at-end-of-file) 189
[error] too many blank lines (1 > 0) (empty-lines) 12
[error] too many blank lines (2 > 0) (empty-lines) 1
[error] too many spaces after colon (colons) 7
[error] too many spaces after hyphen (hyphens) 7
[error] too many spaces inside braces (braces) 2
[error] trailing spaces (trailing-spaces) 33
[error] wrong indentation 317
[warning] comment not indented like content (comments-indentation) 1
[warning] missing document start "---" (document-start) 329
[warning] truthy value should be one of [false, true] (truthy) 7

strangiato avatar Sep 17 '21 02:09 strangiato

@strangiato I like this idea. I agree with your suggested rules to disable (was never a fan of --- at the beginning of a file).

@gnunn1 , what do you think? I'm good with this addition.

pittar avatar Sep 21 '21 13:09 pittar

I'm probably the one guilty of:

myList:
- name: myObject

As I like that style but I can change, really I can! Seriously I think having an enforced standard would be excellent, I'm all for it,

gnunn1 avatar Sep 28 '21 16:09 gnunn1

Gerald has spoken! Looking forward to updating a ton of yaml!

pittar avatar Sep 28 '21 16:09 pittar

Fantastic!

I will break this up into several smaller PRs.

I will setup a .yamllint file for the project and the do separate PRs for each style update. Once all of the style changes are updated I can add it into a GitHub action so it will be enforced moving forward.

strangiato avatar Sep 28 '21 17:09 strangiato

Sounds good! Might as well keep this issue open until the PRs are in.

pittar avatar Sep 28 '21 17:09 pittar

Just wanted to provide a quick update on this as I have not forgotten about it.

I ran into some issues with the output generated from yamllint with the github actions formatting. I submitted a PR upstream to resolve the issue here:

https://github.com/adrienverge/yamllint/pull/422

Once that is merged and added to a release I will resolve the last few linting issues and submit a PR to add the GitHub Action to run yamllint on all future PRs.

strangiato avatar Nov 30 '21 21:11 strangiato