GithubHelp home page GithubHelp logo

lintr's Introduction

lintr

Build Status Coverage Status

Static code analysis for R

lintr

Emacs

lintr has built-in integration with flycheck versions greater than 0.23. Emacs Example

Installation

Put the following in your .emacs file to automatically use lintr to check R files. Note you will need to change the path to where you put lintr.el

(require 'flycheck)
(add-hook 'ess-mode-hook
          (lambda () (flycheck-mode t)))

Configuration

You can also configure what linters are used. e.g. using a different line length cutoff.

  • M-X customize-opton -> flycheck-r-linters -> with_defaults(line_length_linter(120))

Vim

lintr can be integrated with syntastic for on the fly linting.

Vim Example

Installation

Put the file syntastic/lintr.vim in syntastic/syntax_checkers/r. If you are using pathogen this directory is ~/.vim/bundles/syntastic/syntax_checkers/r.

You will also need to add the following lines to your .vimrc.

let g:syntastic_enable_r_lintr_checker = 1
let g:syntastic_r_checkers = 1

Configuration

You can also configure what linters are used. e.g. using a different line length cutoff.

let g:syntastic_r_lintr_linters = "with_defaults(line_length_linter(120))"

Sublime Text 3

lintr can be intergrated with Sublime Linter for on the fly linting.

Sublime Example

Installation

Simply install sublimeLinter-contrib-lintr using Package Control.

For more information see Sublime Linter Docs

Configuration

You can also configure what linters are used. e.g. using a different line length cutoff. In the SublimeLinter User Settings

{
  "user": {
    "linters": {
      "r": {
        "linters": "with_defaults(line_length_linter(120))"
      }
    }
  }
}

Available linters

  • Syntax errors: reported by parse.
  • object_usage_linter: checks that closures have the proper usage using codetools::checkUsage(). Note this runs base::eval() on the code, so do not use with untrusted code.
  • absolute_paths_linter: checks that no absolute paths are used.
  • assignment_linter: checks that <- is always used for assignment
  • closed_curly_linter: check that closed curly braces should always be on their own line unless they follow an else.
  • commas_linter: check that all commas are followed by spaces, but do not have spaces before them.
  • infix_spaces_linter: check that all infix operators have spaces around them.
  • line_length_linter: check the line length of both comments and code is less than length.
  • no_tab_linter: check that only spaces are used, never tabs.
  • object_camel_case_linter: check that function and variable names are not camelCase.
  • object_snake_case_linter: check that function and variable names are not snake_case.
  • object_multiple_dots_linter: check that function and variable names are separated by _ rather than ..
  • object_length_linter: check that function and variable names are not more than length characters.
  • open_curly_linter: check that opening curly braces are never on their own line and are always followed by a newline.
  • single_quotes_linter: checks that only single quotes are used to delimit string contestants.
  • spaces_inside_linter: check that parentheses and square brackets do not have spaces directly inside them.
  • spaces_left_parentheses_linter: check that all left parentheses have a space before them unless they are in a function call.
  • trailing_blank_lines_linter: check there are no trailing blank lines.
  • trailing_whitespace_linter: check there are no trailing whitespace characters.

References

Most of the default linters are based on Hadley Wickham's R Style Guide.

lintr's People

Contributors

jimhester avatar jjallaire avatar kirillseva avatar ttriche avatar wesleyburr avatar

Watchers

 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.