for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import re
from coalib.bearlib.abstractions.Lint import Lint
from coalib.bears.LocalBear import LocalBear
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY
class RubyLintBear(LocalBear, Lint):
executable = 'ruby'
arguments = '-wc'
output_regex = re.compile(
r'(?P<file_name>.+?):(?P<line>\d+): (?P<message>'
r'(?:(?P<error>.*?error)|(?P<warning>warning))[,:] [^\r\n]+)\r?\n'
r'(?:^[^\r\n]+\r?\n^(?P<col>.*?)\^)?')
use_stderr = True
@staticmethod
def _get_groupdict(match):
groups = Lint._get_groupdict(match)
if groups["error"] != None:
groups["severity"] = RESULT_SEVERITY.MAJOR
else:
groups["severity"] = RESULT_SEVERITY.NORMAL
return groups
def run(self, filename, file):
'''
Checks the code with `ruby -wc` on each file separately.
return self.lint(filename)