GithubHelp home page GithubHelp logo

khileshchauhan / neal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uber/neal

0.0 0.0 0.0 1.78 MB

๐Ÿ”Ž๐Ÿž A language-agnostic linting platform

Home Page: https://uber.github.io/NEAL/

License: MIT License

Makefile 1.26% OCaml 94.94% Python 1.79% Swift 2.00% Starlark 0.02%

neal's Introduction

NEAL

NEAL (Not Exactly A Linter) is a language-independent code analysis tool that aims to enable more people to write quality enforcement rules.

Example

One of the simplest rules we have at Uber is to restrict the use of Forced-Values in Swift. (This post explains some of the risks of abusing forced-values.)

A forced-value consists of any expression that results in an optional value followed by the forced-unwrapping operator (!). Here's a contrived example that would result in a runtime crash.

// test.swift
(nil as Int?)!

NEAL doesn't have any rules built-in, so we have to write a new rule to detect this pattern:

// test.rules
rule NoForcedValues {
  Swift::ForcedValueExpression {
    fail("No forced unwrapping allowed")
  }
}

Now if you run NEAL you should see something like the following:

$ neal --rules test.rules test.swift

[1 of 1]: Analysing test.swift
On file test.swift: (NoForcedValues)

  1 | (nil as Int?)!
  ~ |              ^

error: No forced unwrapping allowed

Alternatively, you can create a minimal configuration file called neal.json:

{
  "rules": [ "test.rules" ]
}

After that you can get the same result by simply running:

$ neal .

For a more comprehensive guide to writing your own rules check out Writing a new rule.

Installation

The recommended way of installing NEAL is through Homebrew, using the following command:

$ brew install neal

Installing from source

To build and install NEAL from source, make sure you have OPAM installed and that you're using OCaml 4.04 or later.

$ brew install opam
$ opam init
$ opam switch 4.04.2
$ eval "$(opam config env)"

After you have setup OPAM and OCaml, you can setup, build and install NEAL using make.

$ NATIVE=1 make setup build install

Basic usage

NEAL has builtin support for Python and Swift, but it's highly extensible, and can be used with any language.

$ neal [options] [path to files or directories]

For a list of CLI options, runtime options and configuration attributes see the Configuration guide.

Acknowledgements

Getting Started <self> rules testing_rules reference configuration basics components/index.rst developing changelog

neal's People

Contributors

tadeuzagallo avatar sm11963 avatar myhrvold avatar tapthaker avatar kaar3k avatar rvantonder avatar lutzifer avatar mkr-plse 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.