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

CLI: Remove flake8 dependency, run with pre-commit #166

Open
andreoliwa opened this issue May 29, 2020 · 0 comments
Open

CLI: Remove flake8 dependency, run with pre-commit #166

andreoliwa opened this issue May 29, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request plugin-pre-commit Plugin for pre-commit hooks

Comments

@andreoliwa
Copy link
Owner

andreoliwa commented May 29, 2020

Expected Behavior

When running Nitpick, display the correct filenames that contain violations.

Simulate the output of a flake8 plugin, so warnings can be displayed together with tools that use the flake8 format.
If possible, display the correct line and column of the violation.

Also, without relying on flake8, Nitpick can be used for any language, not only for Python projects.
There would be no need to create dummy.py files.

Example output:

$ pre-commit run --all-files nitpick
Nitpick..................................................................Failed
- hook id: nitpick
- exit code: 1

.pre-commit-config.yaml:3:5: NIP339 hook 'debug-statements' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
.pre-commit-config.yaml:3:5: NIP339 hook 'end-of-file-fixer' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
.pre-commit-config.yaml:3:5: NIP339 hook 'trailing-whitespace' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
.pre-commit-config.yaml:9:5: NIP339 hook 'pyupgrade' (rev: v2.4.4) has different values. Use this:
rev: v2.4.1
.pre-commit-config.yaml:50:5: NIP339 hook 'flake8' (rev: 3.8.2) has different values. Use this:
rev: 3.8.1
setup.cfg:25:1: NIP324 section [flake8] has some missing key/value pairs. Use this:
[flake8]
exclude = .tox,build
pyproject.toml:55:1: NIP318 missing values:
[tool.poetry.dev-dependencies]
pylint = "*"

Current Behavior

Nitpick is a flake8 plugin, and flake8 only runs on Python .py files.
Currently, Nitpick chooses an arbitrary Python file and displays all the flake8 warnings as if they were violations of that Python file.
This was mentioned on #73 (comment)

Below is an example of how Nitpick works now.
All violations are displayed under docs/conf.py, line 0, column 1.

$ pre-commit run --all-files nitpick
Nitpick..................................................................Failed
- hook id: nitpick
- exit code: 1

docs/conf.py:0:1: NIP339 File .pre-commit-config.yaml: hook 'debug-statements' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
docs/conf.py:0:1: NIP339 File .pre-commit-config.yaml: hook 'end-of-file-fixer' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
docs/conf.py:0:1: NIP339 File .pre-commit-config.yaml: hook 'trailing-whitespace' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
docs/conf.py:0:1: NIP339 File .pre-commit-config.yaml: hook 'pyupgrade' (rev: v2.4.4) has different values. Use this:
rev: v2.4.1
docs/conf.py:0:1: NIP339 File .pre-commit-config.yaml: hook 'flake8' (rev: 3.8.2) has different values. Use this:
rev: 3.8.1
docs/conf.py:0:1: NIP324 File setup.cfg: section [flake8] has some missing key/value pairs. Use this:
[flake8]
exclude = .tox,build
docs/conf.py:0:1: NIP318 File pyproject.toml has missing values:
[tool.poetry.dev-dependencies]
pylint = "*"

Possible Solution

  1. Run a CLI command like nitpick run to check files.
  2. Accept zero or more files as arguments.
    Check only the desired files, of check all files if no arguments were provided.
    This would make it compatible with the files attribute on pre-commit.
  3. Make flake8 an optional dependency.
    Nitpick would be installed with poetry add --dev --extras flake8 nitpick or pip install nitpick[flake8].
  4. Try to parse the violated config file in order to determine the line and column of the violation.
@andreoliwa andreoliwa added the enhancement New feature or request label May 29, 2020
@andreoliwa andreoliwa self-assigned this May 29, 2020
@andreoliwa andreoliwa added this to Backlog in Nitpick Roadmap May 29, 2020
@andreoliwa andreoliwa moved this from Later to CLI in Nitpick Roadmap Jun 30, 2020
@andreoliwa andreoliwa changed the title Display the correct filenames on violations, run Nitpick as a standalone CLI independent of flake8 Run as a standalone CLI independent of flake8 / display the correct filenames on violations Feb 6, 2021
@andreoliwa andreoliwa moved this from CLI to Now in Nitpick Roadmap Feb 6, 2021
@andreoliwa andreoliwa moved this from Now to CLI in Nitpick Roadmap Feb 6, 2021
@andreoliwa andreoliwa changed the title Run as a standalone CLI independent of flake8 / display the correct filenames on violations CLI: Remove flake8 dependency, run with pre-commit Feb 6, 2021
@andreoliwa andreoliwa moved this from CLI to Next in Nitpick Roadmap Feb 13, 2021
@andreoliwa andreoliwa moved this from Next to Later in Nitpick Roadmap Feb 13, 2021
@andreoliwa andreoliwa added the plugin-pre-commit Plugin for pre-commit hooks label Feb 13, 2021
@andreoliwa andreoliwa moved this from Later to Backlog in Nitpick Roadmap Feb 18, 2021
agos-release-manager pushed a commit to agos-tech/toolchain-config that referenced this issue Dec 9, 2021
The tool is moving its way to being more language agnostic [1],
at least the flake8 configuration is now unnecessary.

For now, we still need the dummy Python files.

[1]: andreoliwa/nitpick#166
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugin-pre-commit Plugin for pre-commit hooks
Projects
Status: Backlog
Nitpick Roadmap
  
Backlog
Development

No branches or pull requests

1 participant