All Projects → dlint-py → dlint

dlint-py / dlint

Licence: BSD-3-Clause license
Dlint is a tool for encouraging best coding practices and helping ensure Python code is secure.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to dlint

Njsscan
njsscan is a semantic aware SAST tool that can find insecure code patterns in your Node.js applications.
Stars: ✭ 128 (-1.54%)
Mutual labels:  linter, static-analysis
Woke
✊ Detect non-inclusive language in your source code.
Stars: ✭ 190 (+46.15%)
Mutual labels:  linter, static-analysis
Rstcheck
Checks syntax of reStructuredText and code blocks nested within it
Stars: ✭ 130 (+0%)
Mutual labels:  linter, static-analysis
Gopherci
GopherCI was a project to help you maintain high-quality Go projects, by checking each GitHub Pull Request, for backward incompatible changes, and a suite of other third party static analysis tools.
Stars: ✭ 105 (-19.23%)
Mutual labels:  linter, static-analysis
Protoc Gen Lint
A plug-in for Google's Protocol Buffers (protobufs) compiler to lint .proto files for style violations.
Stars: ✭ 221 (+70%)
Mutual labels:  linter, static-analysis
Wemake Python Styleguide
The strictest and most opinionated python linter ever!
Stars: ✭ 1,714 (+1218.46%)
Mutual labels:  linter, flake8
Bodyclose
Analyzer: checks whether HTTP response body is closed and a re-use of TCP connection is not blocked.
Stars: ✭ 181 (+39.23%)
Mutual labels:  linter, static-analysis
Clj Kondo
A linter for Clojure code that sparks joy.
Stars: ✭ 1,083 (+733.08%)
Mutual labels:  linter, static-analysis
Spotbugs
SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.
Stars: ✭ 2,569 (+1876.15%)
Mutual labels:  linter, static-analysis
Bellybutton
Custom Python linting through AST expressions
Stars: ✭ 196 (+50.77%)
Mutual labels:  linter, static-analysis
Unimport
A linter, formatter for finding and removing unused import statements.
Stars: ✭ 96 (-26.15%)
Mutual labels:  linter, static-analysis
Revive
🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
Stars: ✭ 3,139 (+2314.62%)
Mutual labels:  linter, static-analysis
Static Analysis
⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.
Stars: ✭ 9,310 (+7061.54%)
Mutual labels:  linter, static-analysis
Abaplint
Standalone linter for ABAP
Stars: ✭ 111 (-14.62%)
Mutual labels:  linter, static-analysis
Flake8
The official GitHub mirror of https://gitlab.com/pycqa/flake8
Stars: ✭ 1,112 (+755.38%)
Mutual labels:  linter, static-analysis
Cflint
Static code analysis for CFML (a linter)
Stars: ✭ 156 (+20%)
Mutual labels:  linter, static-analysis
Awesome Go Linters
A curated list of awesome Go linters. More than 60 linters and tools!
Stars: ✭ 801 (+516.15%)
Mutual labels:  linter, static-analysis
Sonar Jproperties Plugin
SonarQube Java Properties Analyzer
Stars: ✭ 5 (-96.15%)
Mutual labels:  linter, static-analysis
Diktat
Strict coding standard for Kotlin and a custom set of rules for detecting code smells, code style issues and bugs
Stars: ✭ 196 (+50.77%)
Mutual labels:  linter, static-analysis
D Scanner
Swiss-army knife for D source code
Stars: ✭ 221 (+70%)
Mutual labels:  linter, static-analysis

Dlint

CI Coverage Status Python Versions PyPI Version

Dlint is a tool for encouraging best coding practices and helping ensure Python code is secure.

The most important thing I have done as a programmer in recent years is to aggressively pursue static code analysis. Even more valuable than the hundreds of serious bugs I have prevented with it is the change in mindset about the way I view software reliability and code quality.

For a static analysis project to succeed, developers must feel they benefit from and enjoy using it.

For documentation and a list of rules see docs.

Installing

$ python -m pip install dlint

And double check that it was installed correctly:

$ python -m flake8 -h
Usage: flake8 [options] file file ...

...

Installed plugins: dlint: 0.13.0, mccabe: 0.5.3, pycodestyle: 2.2.0, pyflakes: 1.3.0

Note the dlint: 0.13.0.

Using

Dlint builds on flake8 to perform its linting. This provides many useful features without re-inventing the wheel.

CLI

Let's run a simple check:

$ cat << EOF > test.py
print("TEST1")
exec('print("TEST2")')
EOF
$ python test.py
TEST1
TEST2
$ python -m flake8 --select=DUO test.py
test.py:2:1: DUO105 use of "exec" is insecure

The --select=DUO flag tells flake8 to only run Dlint lint rules.

From here, we can easily run Dlint against a directory of Python code:

$ python -m flake8 --select=DUO /path/to/code

To fine-tune your linting, check out the flake8 help:

$ python -m flake8 --help

Inline Editor

Dlint results can also be included inline in your editor for fast feedback. This typically requires an editor plugin or extension. Here are some starting points for common editors:

Integrating

Dlint can easily be integrated into CI pipelines, or anything really.

For more information and examples see 'How can I integrate Dlint into XYZ?'.

Custom Plugins

Dlint's custom plugins are built on a simple naming convention, and rely on Python modules. To make a Dlint custom plugin use the following conventions:

  • The Python module name must start with dlint_plugin_.
  • The linter class name must start with Dlint.
  • The linter class should inherit from dlint.linters.base.BaseLinter.
    • If for some reason you'd like to avoid this, then you must implement the get_results function appropriately and inherit from ast.NodeVisitor.

See an example plugin for further details.

Developing

First, install development packages:

$ python -m pip install -r requirements.txt
$ python -m pip install -r requirements-dev.txt
$ python -m pip install -e .

Testing

$ pytest

Linting

$ flake8

Coverage

$ pytest --cov

Benchmarking

$ pytest -k test_benchmark_run --benchmark-py-file /path/to/file.py tests/test_benchmark/

Or get benchmark results for linters individually:

$ pytest -k test_benchmark_individual --benchmark-py-file /path/to/file.py tests/test_benchmark/

Or run against a single linter:

$ pytest -k test_benchmark_individual[DUO138-BadReCatastrophicUseLinter] --benchmark-py-file /path/to/file.py tests/test_benchmark/
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].