Skip to content

lint: All text files for general formatting#15641

Merged
mattklein123 merged 4 commits intoenvoyproxy:mainfrom
phlax:lint-text-files
Mar 30, 2021
Merged

lint: All text files for general formatting#15641
mattklein123 merged 4 commits intoenvoyproxy:mainfrom
phlax:lint-text-files

Conversation

@phlax
Copy link
Copy Markdown
Member

@phlax phlax commented Mar 24, 2021

Signed-off-by: Ryan Northey ryan@synca.io

Commit Message: lint: All text files for general formatting
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue] Fix #15442
[Optional Deprecated:]
[Optional API Considerations:]

@phlax phlax marked this pull request as draft March 24, 2021 10:27
@phlax phlax changed the title lint: All text files for general formatting [WIP] lint: All text files for general formatting Mar 24, 2021
@phlax
Copy link
Copy Markdown
Member Author

phlax commented Mar 24, 2021

cc @mattklein123 @htuch

this is a first attempt at a script to cleanup text/code files in the repo that have language-independent linting issues

so far it does not:

  • allow exceptions
  • automate a fix
  • fix the files

@phlax
Copy link
Copy Markdown
Member Author

phlax commented Mar 24, 2021

just looking at autofix - to automate untabify it will require hard-coding what the indentation should be for any given file type

@phlax
Copy link
Copy Markdown
Member Author

phlax commented Mar 24, 2021

re untabify - this situation is made worse as .sh scripts currently use a mix of indents sometimes within the same file

my vote is defo to use 4-space indents but im struggling to find anything (reliable) that will properly lint indents in shell scripts (no matter what the number of spaces is)

@htuch
Copy link
Copy Markdown
Member

htuch commented Mar 25, 2021

@phlax I'd probably prefer Python here TBH. Bash becomes hard to write if we want to extend it.

@phlax
Copy link
Copy Markdown
Member Author

phlax commented Mar 25, 2021

ill have a look at reimplementing in python.

my concern is that it will make it much slower and probs require quite a bit more code. Also some of the things (like finding the text files) are going to be much harder to implement in python (bash still has some uses 8/) so we may end up with the ~same bash lines just wrapped in python

@htuch
Copy link
Copy Markdown
Member

htuch commented Mar 25, 2021

I think pathlib globbing is pretty good for this. But, I agree on performance. I guess my question is how complex do we anticipate this growing? The current level of complexity is fine and somewhat maintainable. I would hate to see something that reached 2x the size though..

@phlax
Copy link
Copy Markdown
Member Author

phlax commented Mar 25, 2021

I think pathlib globbing is pretty good for this.

its not the globbing thats the issue - its easy enough to find and filter files - this is using git to filter what it sees as a "text" file

@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy[\w/]*/(v1alpha\d?|v1|v2alpha\d?|v2))|(api/envoy/type/(matcher/)?\w+.proto).
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
API shepherd assignee is @mattklein123
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #15641 was synchronize by phlax.

see: more, trace.

@phlax phlax force-pushed the lint-text-files branch 4 times, most recently from cf3524e to 65ee3b1 Compare March 29, 2021 11:56
Copy link
Copy Markdown
Member

@davinci26 davinci26 left a comment

Choose a reason for hiding this comment

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

+1 to write it with python because it would help with having cross platform tooling

@phlax
Copy link
Copy Markdown
Member Author

phlax commented Mar 29, 2021

+1 to write it with python because it would help with having cross platform tooling

apologies - the conversation continued in slack - and for the reason that bash really is the best tool for these it has been done this way for now

using python would add a huge amount of complexity and depending on how much complexity was added would potentially be a lot slower

@phlax
Copy link
Copy Markdown
Member Author

phlax commented Mar 29, 2021

also at very least (without a lot of working around) it would need to include a github dependency - so it would require a lot more of users (ie python + git package)

@phlax phlax force-pushed the lint-text-files branch from 982f5b5 to 747ca57 Compare March 30, 2021 11:00
@phlax phlax changed the title [WIP] lint: All text files for general formatting lint: All text files for general formatting Mar 30, 2021
@phlax phlax marked this pull request as ready for review March 30, 2021 12:46
@phlax
Copy link
Copy Markdown
Member Author

phlax commented Mar 30, 2021

@mattklein123 this should be ready for final review hopefully

i have excluded all of the *_corpus/ folders so hopefully this doesnt mess with any test data that it shouldnt

current exclude is

 NOLINT_RE="\.patch$|^test/.*_corpus/|^tools/.*_corpus/|password_protected_password.txt"

phlax added 3 commits March 30, 2021 14:39
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
@phlax phlax force-pushed the lint-text-files branch from 747ca57 to d9d7832 Compare March 30, 2021 13:41
@phlax
Copy link
Copy Markdown
Member Author

phlax commented Mar 30, 2021

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #15641 (comment) was created by @phlax.

see: more, trace.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Very nice, thanks. Just some small comments.

/wait

Signed-off-by: Ryan Northey <ryan@synca.io>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@mattklein123 mattklein123 merged commit 20e4dd2 into envoyproxy:main Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve general text file linting

5 participants