:sparkles: Surface lint errors during code review

Overview

Linty Fresh Build Status Join the chat at https://gitter.im/lyft/linty_fresh

Keep your codebase sparkly clean with the power of LINT!

Linty Fresh parses lint errors and report them back to GitHub as comments on a pull request.

Linty Fresh

Requirements

Contributing

CONTRIBUTING.md

Installation

Linty Fresh is hosted in PyPi. To get started, Run

pip3 install linty-fresh

Install from source

Linty Fresh uses setuptools for installation. After cloning the repo, run

python3 setup.py install

Usage

We recommend you create a GitHub user for your organization used just for commenting on PRs. Create a token for that user that only has access to the repo scope (or public_repo scope for OSS projects). Then add that token as a secret to your CI system as the environment variable GITHUB_AUTH_TOKEN. You should ensure this user and it's token are scoped down as much as possible. You should assume that anyone who has permissions to run a job in your CI system would have access to this token. See Travis CI documentation storing encrypted secrets for more information.

If you are looking for a good secret management system to store secrets like this, check out Confidant.

Once you have your GitHub user, integrating Linty Fresh is easy! Assuming you are running PyLint and the output is going to pylint.txt, add the following snippet to the bottom of your automation script.

linty_fresh --pr_url ${PR_URL} --commit "${COMMIT}" \
            --linter pylint pylint.txt

Take a look at our run_tests.sh script as an example for how this works on Travis CI.

Currently each invocation of linty_fresh can only accept one lint file, but this will likely change.

Supported Linters

Comments
  • Changes github comment to include linter name

    Changes github comment to include linter name

    Our use case is that we are running many commands through linty fresh - for our iOS repo, we have xcodebuild, swiftlint, and stringslint errors.

    When one of these fails, people have ended up being confused about the difference between a "lint" step - "oh, stupid lint" ... except that the code is not compiling ("xcodebuild").

    I've updated the comments to be more specific. For example rather than saying "Linty Fresh Says" now we'll say "xcodebuild says".

    By default the name of the --linter will be used. I also added a --linter_name argument which can be used to override this in cases where it might not make sense (e.g. passthrough)

    opened by tildedave 3
  • Add async for type error

    Add async for type error

    Hoping this fixes this error:

    Traceback (most recent call last):
      File "/private/var/tmp/b/3263360e4c13ed7221fd5574dfffe441/execroot/lyftios/bazel-out/darwin-opt/bin/tools/lintyfresh/lintyfresh.runfiles/lyftios/tools/lintyfresh/linty_fresh_runner.py", line 9, in <module>
        linty_fresh.main.main()
      File "/private/var/tmp/b/3263360e4c13ed7221fd5574dfffe441/execroot/lyftios/bazel-out/darwin-opt/bin/tools/lintyfresh/lintyfresh.runfiles/pip_deps/pypi__linty_fresh/linty_fresh/main.py", line 95, in main
        loop.run_until_complete(run_loop(args))
      File "/Applications/Xcode-12.2.0.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
        return future.result()
      File "/private/var/tmp/b/3263360e4c13ed7221fd5574dfffe441/execroot/lyftios/bazel-out/darwin-opt/bin/tools/lintyfresh/lintyfresh.runfiles/pip_deps/pypi__linty_fresh/linty_fresh/main.py", line 87, in run_loop
        await asyncio.gather(*awaitable_array)
      File "/private/var/tmp/b/3263360e4c13ed7221fd5574dfffe441/execroot/lyftios/bazel-out/darwin-opt/bin/tools/lintyfresh/lintyfresh.runfiles/pip_deps/pypi__linty_fresh/linty_fresh/reporters/github_reporter.py", line 82, in report
        with aiohttp.ClientSession(headers=headers) as client_session:
      File "/private/var/tmp/b/3263360e4c13ed7221fd5574dfffe441/execroot/lyftios/bazel-out/darwin-opt/bin/tools/lintyfresh/lintyfresh.runfiles/pip_deps/pypi__aiohttp/aiohttp/client.py", line 1070, in __enter__
        raise TypeError("Use async with instead")
    TypeError: Use async with instead
    
    opened by keith 1
  • Revert

    Revert "Bump python version and aiohttp library (#56)"

    This reverts commit 9aa2b7621872dcadc80538d56a3a6cef2abdbb55.

    When running after this change we see:

    Traceback (most recent call last):
      File "/private/var/tmp/b/3263360e4c13ed7221fd5574dfffe441/execroot/lyftios/bazel-out/darwin-opt/bin/tools/lintyfresh/lintyfresh.runfiles/lyftios/tools/lintyfresh/linty_fresh_runner.py", line 9, in <module>
        linty_fresh.main.main()
      File "/private/var/tmp/b/3263360e4c13ed7221fd5574dfffe441/execroot/lyftios/bazel-out/darwin-opt/bin/tools/lintyfresh/lintyfresh.runfiles/pip_deps/pypi__linty_fresh/linty_fresh/main.py", line 95, in main
        loop.run_until_complete(run_loop(args))
      File "/Applications/Xcode-12.2.0.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
        return future.result()
      File "/private/var/tmp/b/3263360e4c13ed7221fd5574dfffe441/execroot/lyftios/bazel-out/darwin-opt/bin/tools/lintyfresh/lintyfresh.runfiles/pip_deps/pypi__linty_fresh/linty_fresh/main.py", line 87, in run_loop
        await asyncio.gather(*awaitable_array)
      File "/private/var/tmp/b/3263360e4c13ed7221fd5574dfffe441/execroot/lyftios/bazel-out/darwin-opt/bin/tools/lintyfresh/lintyfresh.runfiles/pip_deps/pypi__linty_fresh/linty_fresh/reporters/github_reporter.py", line 82, in report
        with aiohttp.ClientSession(headers=headers) as client_session:
      File "/private/var/tmp/b/3263360e4c13ed7221fd5574dfffe441/execroot/lyftios/bazel-out/darwin-opt/bin/tools/lintyfresh/lintyfresh.runfiles/pip_deps/pypi__aiohttp/aiohttp/client.py", line 1070, in __enter__
        raise TypeError("Use async with instead")
    TypeError: Use async with instead
    
    opened by keith 1
  • Delete comments on re-run

    Delete comments on re-run

    Would it make sense to delete all existing linty_fresh comments when making new ones? Sometimes these comments are folded, depending on the linter, but they're also sometimes not, or at the top level which makes it hard to tell if the comment has been addressed.

    I don't feel like these automated lint comments add a ton of historical value so if re-running the linter has the capability of making the same comments, if the issues haven't been addressed, it seems like we would be safe first clearing the existing ones.

    opened by keith 1
  • Comment on the PR with problems that aren't in the diff.

    Comment on the PR with problems that aren't in the diff.

    In SwiftLint there are rules that can be enforced like the length of a file. When these hit, the error message will be on the last line even though the commit caused the failure.

    This will still comment if it can on the top of the file with any failing messages.

    opened by rowillia 1
  • [Wrong repository :( ] Add my waiting Prs to a branch to create a

    [Wrong repository :( ] Add my waiting Prs to a branch to create a "post" package

    Update:

    I'm sorry I wanted to do it on my master branch :(

    (Forgot a minute that github automatically use the fork source as the source of the PR :( )

    opened by twidi 1
  • [pylint] Ensure path and line are present

    [pylint] Ensure path and line are present

    We need the path and the line to create the message, and the regex for the pylint linter does not ensure it.

    In a pylint report, it is possible to find a line containing only :: so the script crashes.

    This commit fixes the problem by updating the PYLINT_LINE_REGEX to force the presence of a path and a line.

    opened by twidi 1
  • Move to pre-commit

    Move to pre-commit

    This removes our usage of setup_requires for development only dependencies, and manages linters in a way that I think is nicer in general. This fixes an issue we hit where setup_requires, even though it's not consumed upstream, broke upstream dependees because of invalid version locking.

    opened by keith 0
  • Move to setup.cfg

    Move to setup.cfg

    This is the newer / nicer way to configure this without arbitrary code execution. I was hoping this would help with our install issues, but it doesn't look like it will. Either way I think it's the right thing to do

    opened by keith 0
  • Lock dependencies

    Lock dependencies

    flake8-debugger shipped a new version that's incompatible with the other constraints. In the future we probably want to change how this works but for now this fixes that issue.

    opened by keith 0
  • Print summary and return exit code 1 if problem found

    Print summary and return exit code 1 if problem found

    Before this commit, nothing was printed on the output to know if something happened or not, and there was no difference in the exit code if lint problems were found or not.

    The exit code statis is important when integrating this tool in a CI, to mark the PR as failed.

    This commit resolves this by:

    • adding a return value to the report method, a tuple with:
      • Reporter name
      • Number of line with problem(s)
      • Number not already present on github
      • Raised overflow, or None
      • Number that cannot be pushed on github
    • passing this result from the main function to a new manage_results function that will:
      • display a message depending of the result for each reporter
      • return 1 if at least 1 problem was found in the PR (even if already pushed on Github on a previous call), and 0 if not
    opened by twidi 0
  • Sort messages added to Github for check consistency

    Sort messages added to Github for check consistency

    To know if a message should be added to Github we check if it was already added. Or if we have more than one messages for a line, they are not guaranteed to be in the same order, so the check fail.

    This commit simply sort the lines before adding them to the final message to check.

    (It also simplifies this part of the code using the fact that set.add will not add a new occurence of the value if already present, so the extra set and the if..in are not needed)

    opened by twidi 2
  • Support parsing FindBugs output

    Support parsing FindBugs output

    FindBugs is a popular Java static analyzer. http://findbugs.sourceforge.net/

    See our guidelines for contributing for more info on how to add a linter https://github.com/lyft/linty_fresh/blob/master/CONTRIBUTING.md

    n00b 
    opened by rowillia 0
  • Support parsing Infer output

    Support parsing Infer output

    http://fbinfer.com/ is a great static analyzer for finding bugs. We should support parsing it's output.

    For example:

    ./Root/Hello.java:27: error: NULL_DEREFERENCE
      object a last assigned on line 25 could be null and is dereferenced at line 27
    
    ./Root/Hello.java:37: error: RESOURCE_LEAK
       resource acquired to stream by call to allocateResource() at line 31 is not released after line 37
    

    See https://github.com/lyft/linty_fresh/blob/master/CONTRIBUTING.md for more information on how to get started.

    n00b 
    opened by rowillia 0
Owner
Lyft
Lyft
A framework for detecting, highlighting and correcting grammatical errors on natural language text.

Gramformer Human and machine generated text often suffer from grammatical and/or typographical errors. It can be spelling, punctuation, grammatical or

Prithivida 1.3k Jan 8, 2023
OpenStack Hacking Style Checks. Mirror of code maintained at opendev.org.

Introduction hacking is a set of flake8 plugins that test and enforce the OpenStack StyleGuide Hacking pins its dependencies, as a new release of some

Mirrors of opendev.org/openstack 224 Jan 5, 2023
A static type analyzer for Python code

pytype - ?? ✔ Pytype checks and infers types for your Python code - without requiring type annotations. Pytype can: Lint plain Python code, flagging c

Google 4k Dec 31, 2022
Pylint plugin for improving code analysis for when using Django

pylint-django About pylint-django is a Pylint plugin for improving code analysis when analysing code using Django. It is also used by the Prospector t

Python Code Quality Authority 544 Jan 6, 2023
coala provides a unified command-line interface for linting and fixing all your code, regardless of the programming languages you use.

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." ― John F. Woods coala provides a

coala development group 3.4k Dec 29, 2022
Flake8 plugin to find commented out or dead code

flake8-eradicate flake8 plugin to find commented out (or so called "dead") code. This is quite important for the project in a long run. Based on eradi

wemake.services 277 Dec 27, 2022
A plugin for Flake8 that checks pandas code

pandas-vet pandas-vet is a plugin for flake8 that provides opinionated linting for pandas code. It began as a project during the PyCascades 2019 sprin

Jacob Deppen 146 Dec 28, 2022
Code audit tool for python.

Pylama Code audit tool for Python and JavaScript. Pylama wraps these tools: pycodestyle (formerly pep8) © 2012-2013, Florent Xicluna; pydocstyle (form

Kirill Klenov 967 Jan 7, 2023
Utilities for pycharm code formatting (flake8 and black)

Pycharm External Tools Extentions to Pycharm code formatting tools. Currently supported are flake8 and black on a selected code block. Usage Flake8 [P

Haim Daniel 13 Nov 3, 2022
Convert shellcode into :sparkles: different :sparkles: formats!

Bluffy Convert shellcode into ✨ different ✨ formats! Bluffy is a utility which was used in experiments to bypass Anti-Virus products (statically) by f

pre.empt.dev 305 Dec 17, 2022
Product-Review-Summarizer - Created a product review summarizer which clustered thousands of product reviews and summarized them into a maximum of 500 characters, saving precious time of customers and helping them make a wise buying decision.

Product-Review-Summarizer - Created a product review summarizer which clustered thousands of product reviews and summarized them into a maximum of 500 characters, saving precious time of customers and helping them make a wise buying decision.

Parv Bhatt 1 Jan 1, 2022
Lint game data metafiles against GTA5.xsd for Rockstar's game engine (RAGE)

rage-lint Lint RAGE (only GTA5 at the moment) meta/XML files for validity based off of the GTA5.xsd generated from game code. This script accepts a se

GoatGeek 11 Sep 18, 2022
django-compat-lint

django_compat_lint -- check Django compatibility of your code Django's API stability policy is nice, but there are still things that change from one v

James Bennett 40 Sep 30, 2021
QuickStart specific rules for cfn-python-lint

AWS Quick Start cfn-lint rules This repo provides CloudFormation linting rules specific to AWS Quick Start guidelines, for more information see the Co

AWS Quick Start 12 Jul 30, 2022
The interactive graphing library for Python (includes Plotly Express) :sparkles:

plotly.py Latest Release User forum PyPI Downloads License Data Science Workspaces Our recommended IDE for Plotly’s Python graphing library is Dash En

Plotly 12.7k Jan 5, 2023
The interactive graphing library for Python (includes Plotly Express) :sparkles:

plotly.py Latest Release User forum PyPI Downloads License Data Science Workspaces Our recommended IDE for Plotly’s Python graphing library is Dash En

Plotly 8.9k Feb 18, 2021
Code for Findings of ACL 2022 Paper "Sentiment Word Aware Multimodal Refinement for Multimodal Sentiment Analysis with ASR Errors"

SWRM Code for Findings of ACL 2022 Paper "Sentiment Word Aware Multimodal Refinement for Multimodal Sentiment Analysis with ASR Errors" Clone Clone th

null 14 Jan 3, 2023
A simple program which checks Python source files for errors

Pyflakes A simple program which checks Python source files for errors. Pyflakes analyzes programs and detects various errors. It works by parsing the

Python Code Quality Authority 1.2k Dec 30, 2022
Daemon to ban hosts that cause multiple authentication errors

__ _ _ ___ _ / _|__ _(_) |_ ) |__ __ _ _ _ | _/ _` | | |/ /| '_ \/ _` | ' \

Fail2Ban 7.8k Jan 9, 2023
A framework for detecting, highlighting and correcting grammatical errors on natural language text.

Gramformer Human and machine generated text often suffer from grammatical and/or typographical errors. It can be spelling, punctuation, grammatical or

Prithivida 1.3k Jan 8, 2023