ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Sublime​Linter-contrib-codeclimate

by meengit ST3

Code Climate linter for SublimeLinter

Details

Installs

  • Total 3K
  • Win 2K
  • Mac 658
  • Linux 244
Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11
Windows 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Mac 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

SublimeLinter-contrib-codeclimate

This SublimeLinter plugin provides an interface to the codeclimate CLI. Code Climate supports a variety of languages through standardized Docker images known as static analysis engines.

Dependencies

SublimeLinter and the codeclimate CLI must be installed to use this plugin.

  • If you haven't installed SublimeLinter yet, please follow the instructions here.
  • If you haven't installed the codeclimate CLI yet, please follow the instructions here.

It is recommended to add the codeclimate executable to your $PATH variable. You can find some help for this step in the SublimeLinter documentation. Besides, it is also possible to set a custom path to the codeclimate executable in the SublimeLinter settings (see Settings).

Plugin installation

Please use Package Control to install the linter plugin. This will ensure that the plugin will be updated when new versions are available.

Within Sublime Text, bring up the Command Palette and type install. Select Package Control: Install Package and wait a few seconds while Package Control fetches the list of the available plugins.

When the plugin list appears, type codeclimate and select SublimeLinter-contrib-codeclimate.

How it works

  • If the opened folder in SublimeText contains a .codeclimate.yml configuration file in its root, codeclimate will recognize this file's settings. Otherwise, it will automatically run the default inspections of structure and duplication.
  • If you have a .codeclimate.yml configuration file in a different folder, you can set SublimeLinter's working_dir setting (see Settings).

There are some use cases SublimeLinter can't run codeclimate. For instance: if you open a single file beside already opened folders in the same view. In that case, the linter will fail and print a warning because the single file has no working directory (which is required by codeclimate).

Limitations

This plugin may cause performance problems if many projects and documents are open in SublimeText.

I recommend deactivating the plugin globally by default and then activating it depending on your opened folders or as part of a SublimeText Project.

Settings

To see how SublimeLinter's settings works, please see settings and (generic) linter settings in SublimeLinter's documentation.

Examples

Here I try to give you some examples of everyday use cases.

Disable/enable this plugin

{
  "linters": {
    "codeclimate": {
      "disable": true
    }
  }
}

For SublimeLinter's global settings, go to Preferences > Package Settings > SublimeLinter > Settings.

Set executable

You can set the path to the codeclimate executable in the global SublimeLinter settings or your project settings:

{
  "linters": {
    "codeclimate": {
      "executable": "/usr/local/bin/codeclimate"
    }
  }
}

Pass arguments to the codeclimate CLI

If you want to ignore the configuration of a .codeclimate.yml, for instance, to run a subset of codeclimate engines, you can set linter arguments in the global SublimeLinter settings or your project settings:

{
  "linters": {
    "codeclimate": {
      "args": [
          "-e",
          "structure",
          "-e",
          "duplication"
        ]
    }
  }
}

Customize the working directory

Suppose you use a .codeclimate.yml-configuration file. In that case, the codeclimate CLI needs to be executed in your configuration file's directory. Otherwise, it can't detect your configuration and runs only the default analyzes.

SublimeLinter takes the current file's root folder in SublimeText's sidebar as the working directory for executing its linter commands. You can change this behavior by setting the working directory of execution:

{
  "linters": {
    "codeclimate": {
      "working_dir": "/path/to/working/dir"
    }
  }
}

Hint: Make sure the working directory is in the path of the file you want to lint!

Set associated file types

You can set the associated file types in the global SublimeLinter settings or your project settings:

{
  "linters": {
    "codeclimate": {
      "selector": "source.php, source.python"
    }
  }
}

To find out what selector to use for given file type, use the “Tools > Developer > Show Scope Name” menu entry. (SublimeLinter documenation)

Contributing

If you would like to contribute enhancements or fixes, please do the following:

  1. Fork the plugin repository.
  2. Do your changes on a separate topic branch created from the latest main.
  3. Commit and push the topic branch.
  4. Make a pull request.

Please note that modifications should follow these coding guidelines:

  • Indent is 4 spaces.
  • Code should pass flake8 and pep257 linters.
  • Vertical whitespace helps readability, don’t be afraid to use it.
  • Please use descriptive variable names, no abbreviations unless they are very well known.

Thank you very much for helping out!

License

MIT, see LICENSE