Coder Social home page Coder Social logo

sublimelinter-contrib-cflint's Introduction

SublimeLinter-contrib-CFLint

Build Status

This linter plugin for SublimeLinter 3 provides an interface to CFLint. It will be used with files that have the CFML syntax.

Installation

SublimeLinter 3 must be installed in order to use this plugin. If SublimeLinter 3 is not installed, please follow the instructions here.

Linter installation

Before using this plugin, you must ensure that CFLint and SublimeText-CFML are installed on your system.

To install CFLint, do the following:

  1. Download and install latest Java SE 8+ JRE, or JDK if you plan to build it yourself.
  2. Download latest CFLint standalone JAR (CFLint-1.2.0-all.jar or newer) from the GitHub releases or Maven repository. Alternatively, build it yourself using these instructions. This is the JAR file that will be provided to jar_file in the settings.

To install SublimeText-CFML, do the following:

  1. Follow the instructions from jcberquist/sublimetext-cfml.

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. If you want to install from source so you can modify the source code, you probably know what you are doing so we won’t cover that here.

To install via Package Control, do the following:

  1. Within Sublime Text, bring up the Command Palette and type install. Among the commands you should see Package Control: Install Package. If that command is not highlighted, use the keyboard or mouse to select it. There will be a pause of a few seconds while Package Control fetches the list of available plugins.

  2. When the plugin list appears, type cflint. Among the entries, you should see SublimeLinter-contrib-CFLint. If that entry is not highlighted, use the keyboard or mouse to select it.

Settings

For general information on how SublimeLinter 3 works with settings, please see Settings. For information on standard linter settings, please see Linter Settings.

Plugin-specific settings

Once you have installed both the SublimeLinter 3 and SublimeLinter-contrib-CFLint plugins you will need to edit the CFLint settings.

Preferences > Package Settings > SublimeLinter > Settings

You will see a CFLint section under the user settings (SublimeLinter.sublime-settings -- User):

"linters": {
    "cflint": {
        "@disable": false,
        "args": [],
        "aux_config_dirs": [],
        "config_file_name": "cflintrc.xml",
        "excludes": [],
        "jar_file": ""
    }
},

Add the full path to your CFLint JAR file and optionally add config file information:

  • jar_file (required): This must contain the absolute path to the CFLint-*-all.jar file.
  • config_file_name (optional): This must contain just the file name for the CFLint config file. [default: .cflintrc]
  • aux_config_dirs (optional): An array of paths that will act as auxiliary directories in which to search for the config file if not found for the file being linted.

Contributing

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

  1. Fork the plugin repository.
  2. Hack on a separate topic branch created from the latest master.
  3. Commit and push the topic branch.
  4. Make a pull request.
  5. Be patient. ;-)

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 for helping out!

sublimelinter-contrib-cflint's People

Contributors

andrew-dixon avatar ckaznocha avatar kamasamak avatar kaste avatar therealagentk avatar timsayshey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublimelinter-contrib-cflint's Issues

Add to Package Control

make contrib-CFLint available for download through wbond's Package Control. This should help with project visibility and support auto-updating when you make a release.

Error with SublimeLinter 4

CRITICAL: cflint: Calling 'get_view_settings' outside of lint context

Traceback (most recent call last):
File "./python3.3/threading.py", line 901, in _bootstrap_inner
File "./python3.3/threading.py", line 1142, in run
File "sublime_linter in /Users/xxx/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter.sublime-package", line 263, in lint
File "sublime_linter in /Users/xxx/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter.sublime-package", line 323, in get_linters_for_view
File "sublime_linter in /Users/xxx/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter.sublime-package", line 323, in
File "linter in /Users/xxx/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-contrib-CFLint.sublime-package", line 61, in init
File "lint.linter in /Users/xxx/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter.sublime-package", line 360, in get_view_settings
RuntimeError: CRITICAL: cflint: Calling 'get_view_settings' outside of lint context

Error - install windows 7

Windows 7:
Straight from the install - SublimeLinter then SublimeLinter-contrib-CFLint

File "lint.linter in C:\Users\bob\AppData\Roaming\Sublime Text 3\Installed Packages\SublimeLinter.sublime-package", line 349, in get_view_settings
AttributeError: '_thread._local' object has no attribute 'settings'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./python3.3/threading.py", line 901, in _bootstrap_inner
  File "./python3.3/threading.py", line 1142, in run
  File "sublime_linter in C:\Users\bob\AppData\Roaming\Sublime Text 3\Installed Packages\SublimeLinter.sublime-package", line 244, in lint
  File "sublime_linter in C:\Users\bob\AppData\Roaming\Sublime Text 3\Installed Packages\SublimeLinter.sublime-package", line 296, in get_linters_for_view
  File "sublime_linter in C:\Users\bob\AppData\Roaming\Sublime Text 3\Installed Packages\SublimeLinter.sublime-package", line 296, in <setcomp>
  File "linter in C:\Users\bob\AppData\Roaming\Sublime Text 3\Installed Packages\SublimeLinter-contrib-CFLint.sublime-package", line 61, in __init__
  File "lint.linter in C:\Users\bob\AppData\Roaming\Sublime Text 3\Installed Packages\SublimeLinter.sublime-package", line 353, in get_view_settings
RuntimeError: CRITICAL: cflint: Calling 'get_view_settings' outside of lint context

Windows Sublime3 cflint extraction issue

Receiving the error

SublimeLinter: WARNING: no cflint version could be extracted from:


C:\Program Files\Sublime Text 3>java -jar C:\Users\andrew.mikos\workspace\zAssorted\CFLint-0.4-all.jar -version 

CFLint 0.4

in the console when trying to initialize the linter on a cfm or cfc file. The batch file set up is a single line and as follows:

java -jar C:\Users\andrew.mikos\workspace\zAssorted\CFLint-0.4-all.jar %*

It works fine running through command line, however it can't seem to extract the version when run via SublimeLinter. The output in the console shows carriage return characters following all 3 lines, which may be related.

User interface frozen on save

Mac OS 10.8.5
Sublime build 3083

SublimeLinter-contrib-CFLint plugin
https://github.com/ckaznocha/SublimeLinter-contrib-CFLint

CFLint 0.2.0
https://github.com/cflint/CFLint

With the lint mode set to background every time I save a file I get the spinning beach ball for a few seconds and the user interface is frozen. Presumably the plugin is running cflint and waiting for that to return which ties up the user interface. I base this assumption on when I run CFLint from the command line it takes about the same amount of time to process the file as the interface is frozen when I save.

Include link to lint rules

Out of the box, cflint is fairly opinionated about coding style, which can add quite a bit of lint to an ordinary CFML file. It took me a while to track down the lint rules and how to apply them so that cflint becomes more useful. My suggestion would be to include a link to the rules document (https://github.com/cflint/CFLint/blob/dev/RULES.md) and an example .cflintrc file, like:

{
    "output": [],
    "rule": [],
    "excludes": [],
    "includes": [{
        "code": "MISSING_VAR"
    },{
        "code": "OUTPUT_ATTR"
    },{
        "code": "AVOID_USING_STRUCTNEW"
    },{
        "code": "AVOID_USING_ARRAYNEW"
    },{
        "code": "UNUSED_LOCAL_VARIABLE"
    },{
        "code": "SQL_SELECT_STAR"
    }],
    "inheritParent": false,
    "inheritPlugins": true
}

Updating for latest CFLint

I wanted to update this plugin to be compatible with the latest CFLint as well as keeping it easy to use and flexible. Here is a link to my fork. Below is a summary of the major changes I've made. Please provide whatever suggestions/criticisms you have so that they may be addressed before I submit a pull request.

  • Modified to use standalone JAR file instead of old batch/script file.

  • Removed version attributes due to the implementation of version checking in SublimeLinter -- it would check the Java version instead. If anyone knows of a way around this, please let me know or re-implement the version checking yourself.

  • Added plugin settings for JAR file path, config file name, and auxiliary config file directories. I left the default for config_file_name to be cflintrc.xml as it was previously, but the standard naming for that file is .cflintrc.xml for the XML format and .cflintrc or .cflintrc.json for the JSON format. Should I just change the default?

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.