GithubHelp home page GithubHelp logo

dlint-plugin-example's Introduction

Dlint Plugin Example

This repository demonstrates a custom Dlint plugin. Custom plugins are useful for internal linter rules or rules that aren't generally applicable to all Python codebases, but would like to build on Dlint's functionality.

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.

Both dlint_plugin_abs.py and dlint_plugin_sys.py correctly follow these conventions and are appropriately installed via setup.py.

Installing

$ git clone https://github.com/duo-labs/dlint-plugin-example
$ pip install dlint-plugin-example

Using

$ flake8 --select=DUO example.py
example.py:3:1: DUO401 use of "sys" not allowed
example.py:5:10: DUO400 use of "abs" not allowed

Developing

To ensure your custom plugins are functioning as expected you should include tests that exercise their behavior. Without appropriate testing your plugins may produce false positives or false negatives. Dlint has made the dlint.test functionality available to aid in plugin testing efforts.

See test_dlint_plugin_abs.py and test_dlint_plugin_sys.py for more information.

Testing

$ pytest

Linting

$ flake8

Coverage

$ pytest --cov

dlint-plugin-example's People

Contributors

mschwager avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.