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

Linter highlighting #57

Merged
merged 3 commits into from
Oct 29, 2021
Merged

Linter highlighting #57

merged 3 commits into from
Oct 29, 2021

Conversation

akaihola
Copy link
Owner

@akaihola akaihola commented Aug 15, 2020

This also refactors highlighting support into a separate module and uses that in __main__.py for --diff output highlighting.

@akaihola akaihola added the enhancement New feature or request label Aug 15, 2020
@akaihola akaihola added this to the 1.2.0 milestone Aug 15, 2020
@akaihola akaihola self-assigned this Aug 15, 2020
@akaihola akaihola force-pushed the linter-highlighting branch from ea48940 to 174adf4 Compare August 15, 2020 17:13
@akaihola akaihola mentioned this pull request Aug 16, 2020
1 task
@akaihola akaihola modified the milestones: 1.2.0, 1.3.0 Aug 19, 2020
@akaihola akaihola force-pushed the linter-highlighting branch from 174adf4 to a6e8621 Compare August 19, 2020 18:40
@akaihola akaihola force-pushed the linter-highlighting branch 2 times, most recently from 9d8e8b4 to 0d3b6a4 Compare September 7, 2020 17:56
@akaihola akaihola force-pushed the linter-highlighting branch from 0d3b6a4 to 6de2677 Compare September 9, 2020 18:40
@akaihola akaihola force-pushed the linter-highlighting branch 2 times, most recently from ddec623 to 7f351a2 Compare October 9, 2020 17:34
@akaihola akaihola marked this pull request as draft October 10, 2020 17:49
@akaihola akaihola force-pushed the linter-highlighting branch from 7f351a2 to 9f6df30 Compare November 3, 2020 16:37
@akaihola akaihola force-pushed the linter-highlighting branch from 9f6df30 to 14c89a8 Compare November 13, 2020 06:37
@akaihola akaihola force-pushed the linter-highlighting branch 2 times, most recently from 24b4c13 to 207aac9 Compare December 25, 2020 17:41
@akaihola akaihola force-pushed the linter-highlighting branch 2 times, most recently from 13e7cf3 to e7f8ba8 Compare December 29, 2020 16:58
@akaihola
Copy link
Owner Author

Here's example output from running coverage.py on the test suite and displaying edited lines with no coverage using cov_to_lint.py as the linter:

$ cd ~/darker
$ git checkout 1.0.0
$ coverage run -m pytest -c /dev/null
$ darker --revision 0.1.0.. --check --lint cov_to_lint.py src

Kuvakaappaus - 2020-12-29 19-09-34

@akaihola akaihola force-pushed the linter-highlighting branch 2 times, most recently from 40438e2 to 62b6b50 Compare January 1, 2021 14:39
@akaihola akaihola force-pushed the linter-highlighting branch from 62b6b50 to b78004a Compare April 4, 2021 17:25
@akaihola akaihola force-pushed the linter-highlighting branch 2 times, most recently from e23e24d to dc504e2 Compare May 14, 2021 11:19
@akaihola akaihola force-pushed the linter-highlighting branch 2 times, most recently from bc17347 to 4730f3d Compare May 22, 2021 19:39
@akaihola akaihola force-pushed the linter-highlighting branch 3 times, most recently from 3d396a7 to 1d715f2 Compare July 22, 2021 19:55
akaihola added a commit that referenced this pull request Jul 23, 2021
These parts will end up being refactored in #57 anyway.
@akaihola akaihola modified the milestones: 1.3.0, 1.3.1 Jul 30, 2021
@akaihola akaihola force-pushed the linter-highlighting branch 2 times, most recently from 42cf250 to 0c104c6 Compare August 5, 2021 18:59
@akaihola akaihola modified the milestones: 1.3.1, 1.4.0 Sep 4, 2021
@akaihola akaihola force-pushed the linter-highlighting branch 6 times, most recently from 862d271 to db9262e Compare October 23, 2021 19:51
@akaihola akaihola force-pushed the linter-highlighting branch 4 times, most recently from 74fac25 to 43bd973 Compare October 28, 2021 19:30
Refactor highlighting into its own module and use that also for
``--diff`` highlighting.
- split out code into `darker.highlighting.*` modules
- register custom lexers as setuptools plugin entry points
- refer to built-in and custom Pygments lexers with names instead of
  object instances
- use `PythonLexer` directly instead of using the legacy
  `Python3Lexer` backwards-compatibility name
- separate dummy and real `colorize()` implementations (for use
  without and with Pygments, respectively)
- no need for "fake Pygments" module
- more unit tests
@akaihola akaihola force-pushed the linter-highlighting branch from 43bd973 to b86c5b1 Compare October 28, 2021 19:35
CHANGES.rst Outdated Show resolved Hide resolved
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 28, 2021

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.67%.

Quality metrics Before After Change
Complexity 11.06 🙂 11.03 🙂 -0.03 👍
Method Length 83.24 🙂 83.76 🙂 0.52 👎
Working memory 11.33 😞 11.58 😞 0.25 👎
Quality 54.36% 🙂 53.69% 🙂 -0.67% 👎
Other metrics Before After Change
Lines 853 858 5
Changed files Quality Before Quality After Quality Change
src/darker/main.py 42.35% 😞 42.07% 😞 -0.28% 👎
src/darker/linting.py 63.95% 🙂 60.51% 🙂 -3.44% 👎
src/darker/tests/test_linting.py 77.22% ⭐ 77.07% ⭐ -0.15% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
src/darker/main.py main 29 😞 406 ⛔ 15 😞 19.73% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
src/darker/main.py _reformat_single_file 11 🙂 216 ⛔ 19 ⛔ 35.04% 😞 Try splitting into smaller methods. Extract out complex expressions
src/darker/linting.py run_linter 13 🙂 140 😞 13 😞 46.43% 😞 Try splitting into smaller methods. Extract out complex expressions
src/darker/tests/test_linting.py test_run_linter 0 ⭐ 247 ⛔ 12 😞 51.80% 🙂 Try splitting into smaller methods. Extract out complex expressions
src/darker/main.py format_edited_parts 10 🙂 78 🙂 11 😞 60.54% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@akaihola akaihola merged commit 32e38f3 into master Oct 29, 2021
@akaihola akaihola deleted the linter-highlighting branch October 29, 2021 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant