├── .gitignore ├── .python-version ├── .travis.yml ├── LICENSE ├── README.md ├── linter.py ├── messages.json └── messages ├── 1.0.5.txt ├── 1.0.6.txt ├── 1.0.7.txt ├── 1.1.2.txt └── install.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /.python-version: -------------------------------------------------------------------------------- 1 | 3.8 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.3" 4 | # command to install dependencies 5 | install: 6 | - pip install flake8 7 | - pip install pydocstyle 8 | # command to run tests 9 | script: 10 | - flake8 . --max-line-length=120 11 | - pydocstyle . --add-ignore=D202 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy 2 | of this software and associated documentation files (the "Software"), to deal 3 | in the Software without restriction, including without limitation the rights 4 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 5 | copies of the Software, and to permit persons to whom the Software is 6 | furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SublimeLinter-ruby 2 | ========================= 3 | 4 | [![Build Status](https://travis-ci.org/SublimeLinter/SublimeLinter-ruby.svg?branch=master)](https://travis-ci.org/SublimeLinter/SublimeLinter-ruby) 5 | 6 | This linter plugin for [SublimeLinter](https://github.com/SublimeLinter/SublimeLinter) provides an interface to linting via [ruby -wc](https://www.ruby-lang.org). 7 | It will be used with files that have the "Ruby" syntax. 8 | 9 | 10 | ## Installation 11 | 12 | SublimeLinter must be installed in order to use this plugin. 13 | 14 | Please use [Package Control](https://packagecontrol.io) to install the linter plugin. 15 | 16 | Before installing this plugin, ensure that `ruby` is installed on your system. 17 | On Mac OS X and Linux, `ruby` comes pre-installed. On Windows, follow the instructions on the [Ruby site](https://www.ruby-lang.org/en/downloads/). 18 | 19 | If you are using `rvm` or `rbenv`, ensure that they are loaded in your shell’s "profile" file. 20 | 21 | 22 | ## Settings 23 | 24 | - SublimeLinter settings: http://sublimelinter.com/en/latest/settings.html 25 | - Linter settings: http://sublimelinter.com/en/latest/linter_settings.html 26 | -------------------------------------------------------------------------------- /linter.py: -------------------------------------------------------------------------------- 1 | # 2 | # linter.py 3 | # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 4 | # 5 | # Written by Aparajita Fishman 6 | # Copyright (c) 2015-2016 The SublimeLinter Community 7 | # Copyright (c) 2013-2014 Aparajita Fishman 8 | # 9 | # License: MIT 10 | # 11 | 12 | """This module exports the Ruby plugin class.""" 13 | 14 | from SublimeLinter.lint import RubyLinter 15 | import re 16 | 17 | 18 | class Ruby(RubyLinter): 19 | """Provides an interface to ruby -wc.""" 20 | 21 | defaults = { 22 | 'selector': 'source.ruby - text.html' 23 | } 24 | 25 | cmd = 'ruby -wc' 26 | regex = ( 27 | r'^(?P.+?):(?P\d+): (?:(?P.*?error)|(?Pwarning))[,:] (?P[^\r\n]+)\r?\n' 28 | r'(?:^[^\r\n]+\r?\n^(?P.*?)\^)?' 29 | ) 30 | multiline = True 31 | comment_re = r'\s*#' 32 | on_stderr = None 33 | 34 | def split_match(self, match): 35 | """ 36 | Return the components of the match. 37 | 38 | We override this because unrelated library files can throw errors, 39 | and we only want errors from the linted file. 40 | 41 | """ 42 | 43 | if match: 44 | if match.group('file') != '-': 45 | match = None 46 | 47 | match, line, col, error, warning, message, _ = super().split_match(match) 48 | near = self.search_token(message) 49 | 50 | return match, line, col, error, warning, message, near 51 | 52 | def search_token(self, message): 53 | """Search text token to be highlighted.""" 54 | 55 | # First search for variable name enclosed in quotes 56 | m = re.search("(?<=`).*(?=')", message) 57 | 58 | # Then search for variable name following a dash 59 | if m is None: 60 | m = re.search('(?<= - )\S+', message) 61 | 62 | # Then search for mismatched indentation 63 | if m is None: 64 | m = re.search("(?<=mismatched indentations at ')end", message) 65 | 66 | # Then search for equal operator in conditional 67 | if m is None: 68 | m = re.search('(?<=found )=(?= in conditional)', message) 69 | 70 | # Then search for use of operator in void context 71 | if m is None: 72 | m = re.search('\S+(?= in void context)', message) 73 | 74 | # Then search for END in method 75 | if m is None: 76 | m = re.search('END(?= in method)', message) 77 | 78 | return m.group(0) if m else None 79 | -------------------------------------------------------------------------------- /messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "install": "messages/install.txt", 3 | "1.0.5": "messages/1.0.5.txt", 4 | "1.0.6": "messages/1.0.6.txt", 5 | "1.0.7": "messages/1.0.7.txt", 6 | "1.1.2": "messages/1.1.2.txt" 7 | } 8 | -------------------------------------------------------------------------------- /messages/1.0.5.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-ruby 1.0.5 2 | ------------------------- 3 | - Added 'ruby on rails' to syntax. 4 | -------------------------------------------------------------------------------- /messages/1.0.6.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-ruby 1.0.6 2 | ------------------------- 3 | - Added rspec syntax. 4 | -------------------------------------------------------------------------------- /messages/1.0.7.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-ruby 1.0.7 2 | ------------------------- 3 | - Added erb ("HTML (Rails)") support. 4 | -------------------------------------------------------------------------------- /messages/1.1.2.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-ruby 1.1.2 2 | ------------------------- 3 | - Support SublimeLinter 4.5.3 4 | -------------------------------------------------------------------------------- /messages/install.txt: -------------------------------------------------------------------------------- 1 | SublimeLinter-ruby 2 | ------------------------------- 3 | This linter plugin for SublimeLinter provides an interface to ruby. 4 | 5 | Please read the installation instructions at: 6 | 7 | https://github.com/SublimeLinter/SublimeLinter-ruby 8 | --------------------------------------------------------------------------------