All Projects → dalance → flexlint

dalance / flexlint

Licence: MIT license
A flexible linter with rules defined by regular expression

Programming Languages

rust
11053 projects
Makefile
30231 projects
SystemVerilog
227 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to flexlint

Cflint
Static code analysis for CFML (a linter)
Stars: ✭ 156 (+721.05%)
Mutual labels:  lint, linter
Woke
✊ Detect non-inclusive language in your source code.
Stars: ✭ 190 (+900%)
Mutual labels:  lint, linter
Clippy Check
📎 GitHub Action for PR annotations with clippy warnings
Stars: ✭ 159 (+736.84%)
Mutual labels:  lint, linter
yamburger
YAML syntax got you down? That's a YAMBURGER!
Stars: ✭ 32 (+68.42%)
Mutual labels:  lint, linter
D Scanner
Swiss-army knife for D source code
Stars: ✭ 221 (+1063.16%)
Mutual labels:  lint, linter
Protolint
A pluggable linter and fixer to enforce Protocol Buffer style and conventions.
Stars: ✭ 142 (+647.37%)
Mutual labels:  lint, linter
Ue4 Style Guide
An attempt to make Unreal Engine 4 projects more consistent
Stars: ✭ 2,656 (+13878.95%)
Mutual labels:  lint, linter
Editorconfig Checker
A tool to verify that your files are in harmony with your .editorconfig
Stars: ✭ 119 (+526.32%)
Mutual labels:  lint, linter
Husky.Net
Git hooks made easy with Husky.Net internal task runner! 🐶 It brings the dev-dependency concept to the .NET world!
Stars: ✭ 394 (+1973.68%)
Mutual labels:  lint, linter
Protoc Gen Lint
A plug-in for Google's Protocol Buffers (protobufs) compiler to lint .proto files for style violations.
Stars: ✭ 221 (+1063.16%)
Mutual labels:  lint, linter
elm-lint
elm-lint lints Elm source code, to add additional guarantees to your project.
Stars: ✭ 27 (+42.11%)
Mutual labels:  lint, linter
Sql Lint
An SQL linter
Stars: ✭ 243 (+1178.95%)
Mutual labels:  lint, linter
Njsscan
njsscan is a semantic aware SAST tool that can find insecure code patterns in your Node.js applications.
Stars: ✭ 128 (+573.68%)
Mutual labels:  lint, linter
Misspell Fixer
Simple tool for fixing common misspellings, typos in source code
Stars: ✭ 154 (+710.53%)
Mutual labels:  lint, linter
Ansible Lint Action
GitHub Action for running ansible-lint as part of your workflows! [ https://github.com/marketplace/actions/ansible-lint ]
Stars: ✭ 124 (+552.63%)
Mutual labels:  lint, linter
Textlint
The pluggable natural language linter for text and markdown.
Stars: ✭ 2,158 (+11257.89%)
Mutual labels:  lint, linter
Scopelint
scopelint checks for unpinned variables in go programs
Stars: ✭ 110 (+478.95%)
Mutual labels:  lint, linter
Yamllint
A linter for YAML files.
Stars: ✭ 1,750 (+9110.53%)
Mutual labels:  lint, linter
Whispers
Identify hardcoded secrets and dangerous behaviours
Stars: ✭ 66 (+247.37%)
Mutual labels:  lint, linter
Fsharplint
Lint tool for F#
Stars: ✭ 224 (+1078.95%)
Mutual labels:  lint, linter

flexlint

flexlint is a flexible linter with rules defined by regular expression.

Actions Status Crates.io codecov

Install

Download from release page, and extract to the directory in PATH.

Alternatively you can install by cargo.

cargo install flexlint

Usage

Option

flexlint 0.1.0
dalance <[email protected]>
A flexible linter with rules specified by regular expression

USAGE:
    flexlint [FLAGS] [OPTIONS]

FLAGS:
    -h, --help       Prints help information
    -s, --simple     Show results by simple format
    -V, --version    Prints version information
    -v, --verbose    Show verbose message

OPTIONS:
    -r, --rule <rule>    Rule file [default: .flexlint.toml]

Rule file is searched to the upper directory until /. So you can put rule file (.flexlint.toml) on the repository root like .gitignore.

Rule definition

Rule definition is below:

[[rules]]
name      =  ""   # name of rule
pattern   =  ""   # check pattern by regexp
required  =  ""   # required pattern by regexp [Optional]
forbidden =  ""   # forbidden pattern by regexp [Optional]
ignore    =  ""   # ignore pattern by regexp [Optional]
hint      =  ""   # hint message
includes  =  [""] # include file globs
excludes  =  [""] # exclude file globs [Optional]

If pattern is matched, required or forbidden is tried to match at the pattern matched point. So required pattern is not matched, or forbidden pattern is matched, then check is failed. required and forbidden is optional, but if both of them is not defined, check is skipped. If the pattern matched point is included in the ignore matched range, check is skipped. If files matched includes match excludes too, the files are skipped.

The example for if with brace of C/C++ is below:

[[rules]]
name      = "'if' with brace"
pattern   = '(?m)(^|[\t ])if\s'
forbidden = '(?m)(^|[\t ])if\s[^;{]*$'
ignore    = '(/\*/?([^/]|[^*]/)*\*/)|(//.*\n)'
hint      = "multiline 'if' must have brace"
includes  = ["**/*.c", "**/*.cpp"]
excludes  = ["external/*.c"]

pattern is matched if keyword and forbidden check that if must have ; or { until the end of line. ( This example don't support some brace-style, you can modify it )

ignore is defined to skip single line comment (// ...) and multi-line comment (/* ... */).

Regular expression

The syntax of regular expression follows Rust regex crate.

The example of output

If flexlint is executed in example directory of the repository, the output is below:

$ cd example
$ flexlint
Fail: 'if' with brace
   --> test.c:4:4
  |
4 |     if ( hoge )
  |    ^^^^ hint: multiline 'if' must have brace

Fail: verilog 'always' forbidden
   --> test.sv:7:4
  |
7 |     always @ ( posedge clk ) begin
  |    ^^^^^^^^ hint: 'always' must be replaced to 'always_comb'/'always_ff'

Fail: 'if' with 'begin'
   --> test.sv:13:8
   |
13 |         if ( rst )
   |        ^^^^ hint: 'if' statement must have 'begin'

Fail: 'else' with 'begin'
   --> test.sv:15:8
   |
15 |         else
   |        ^^^^^^ hint: 'else' statement must have 'begin'
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].