from coalib.bearlib.abstractions.Lint import Lint
from coalib.bears.LocalBear import LocalBear
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY


class JuliaLintBear(LocalBear, Lint):
    executable = 'julia'
    arguments = '-e \'import Lint.lintfile; lintfile({filename})\''
    output_regex = r'(^.*\.jl):(?P<line>\d+) (?P<severity>.)\d+ (?P<message>.*)'
    use_stdout = True
    severity_map = {
        "E": RESULT_SEVERITY.MAJOR,
        "W": RESULT_SEVERITY.NORMAL,
        "I": RESULT_SEVERITY.INFO
    }

    def run(self, filename, file):
        '''
        Lints Julia code using ``Lint.jl``.
        https://github.com/tonyhffong/Lint.jl
        '''
        return self.lint(filename, file)

from coalib.bearlib.abstractions.Lint import Lint
from coalib.bears.LocalBear import LocalBear
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY


class JuliaLintBear(LocalBear, Lint):
    executable = 'julia'
    arguments = '-e \'import Lint.lintfile; lintfile({filename})\''
    prerequisite_command = ['julia', '-e', 'import Lint.lintfile']
    prerequisite_fail_msg = 'Run `Pkg.add("Lint")` from Julia to install Lint.'
    output_regex = r'(^.*\.jl):(?P<line>\d+) (?P<severity>.)\d+ (?P<message>.*)'
    use_stdout = True
    severity_map = {
        "E": RESULT_SEVERITY.MAJOR,
        "W": RESULT_SEVERITY.NORMAL,
        "I": RESULT_SEVERITY.INFO
    }

    def run(self, filename, file):
        '''
        Lints Julia code using ``Lint.jl``.
        https://github.com/tonyhffong/Lint.jl
        '''
        return self.lint(filename, file)

Add Skip Condition for JuliaBear
bears/julia: Add Skip Condition for JuliaBear

Add prerequisite_command and prerequisite_fail_msg
to JuliaBear.

Fixes https://github.com/coala-analyzer/coala-bears/issues/222
