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 autofix and add stdin input #5

Merged
merged 8 commits into from
Oct 10, 2020
Merged

Conversation

fernandrone
Copy link
Owner

@fernandrone fernandrone commented Oct 9, 2020

  • Fix Autofix setting in config file is not working #2. The issue is that the "autofix" command line flag was overriding the Config object. So even if the config had autofix: true, later in the main function the flag value would override this configuration. It didn't help that the default bool value for the flag was 'false'.

  • Refactor the main code at linelint.go, allowing for input from STDIN. This took some inspiration from autopep8, in which to read from STDIN requires the "-" positional argument (any other positional argument is interpreted as a list of files/dirs to lint, and an "empty" list is interpreted as "lint the current directory tree"). This also makes it much easier to test the linting from the main entrypoint.

  • Add a couple tests as Example in linelint_test.go, using the new "read from stdin" functionality.

  • Also refactor the config package to make the newDefaultConfig method public, this way methods (and tests, specially the Example above) can use it to create a "default" config without depending on external file. Also expose the implicit dependency on a file path for the NewConfig method, renaming it to NewConfigFromFile and taking a file path as a parameter.

* Fixes #2. The issue is
that the "autofix" command line flag was overriding the Config object.
So even if the config had autofix: true, later in the main function the
flag value would override this configuration. It didn't help that the
default bool value for the flag was 'false'.

* Refactor the main code at linelint.go, allowing for input from STDIN.
This took some inspiration from autopep8, in which to read from STDIN
requires the "-" positional argument (any other positional argument
is interpreted as a list of files/dirs to lint, and an "empty" list is
interpreted as "lint the current directory tree"). This also makes it
much easier to test the linting from the main entrypoint.

* Add a couple tests as Example in linelint_test.go, using the new
"read from stdin" functionality.
@fernandrone fernandrone changed the title Fix autofix and add stdin Fix autofix and add stdin input Oct 10, 2020
@fernandrone fernandrone merged commit 7907a5d into master Oct 10, 2020
@fernandrone fernandrone deleted the fix-autofix-and-add-stdin branch October 10, 2020 00:07
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.

Autofix setting in config file is not working
1 participant