コード例 #1
0
    def process_files(self, files):
        """
        Run code checks with ESLint.
        """
        log.debug('Processing %s files with %s', files, self.name)
        cmd = self.name
        if npm_exists('eslint'):
            cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'eslint')
        command = [cmd, '--format', 'checkstyle']

        # Add config file or default to recommended linters
        if self.options.get('config'):
            command += ['--config', self.apply_base(self.options['config'])]

        command += files
        output = run_command(command, ignore_error=True)

        if output.startswith('Cannot read config file'):
            msg = u'Your eslint config file is missing or invalid. ' \
                   u'Please ensure that `{}` exists and is valid.'
            msg = msg.format(self.options['config'])
            return self.problems.add(IssueComment(msg))

        filename_converter = functools.partial(self._relativize_filename,
                                               files)
        self._process_checkstyle(output, filename_converter)
コード例 #2
0
    def process_files(self, files):
        """
        Run code checks with ESLint.
        """
        log.debug('Processing %s files with %s', files, self.name)
        cmd = self.name
        if npm_exists('eslint'):
            cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'eslint')
        command = [cmd, '--format', 'checkstyle']

        # Add config file or default to recommended linters
        if self.options.get('config'):
            command += ['--config', self.apply_base(self.options['config'])]

        command += files
        output = run_command(
            command,
            ignore_error=True)

        if output.startswith('Cannot read config file'):
            msg = u'Your eslint config file is missing or invalid. ' \
                   u'Please ensure that `{}` exists and is valid.'
            msg = msg.format(self.options['config'])
            return self.problems.add(IssueComment(msg))

        filename_converter = functools.partial(
            self._relativize_filename,
            files)
        self._process_checkstyle(output, filename_converter)
コード例 #3
0
ファイル: gjslint.py プロジェクト: adampetrie/lint-review
 def create_command(self, files):
     cmd = 'gjslint'
     if npm_exists('gjslint'):
         cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'gjslint')
     command = [cmd, '--strict']
     command += files
     return command
コード例 #4
0
 def process_files(self, files):
     """
     Run code checks with sass-lint.
     Only a single process is made for all files
     to save resources.
     """
     log.debug('Processing %s files with %s', files, self.name)
     cmd = 'sass-lint'
     if npm_exists('sass-lint'):
         cmd = os.path.join(
             os.getcwd(),
             'node_modules',
             '.bin',
             'sass-lint')
     command = [cmd, '-f', 'checkstyle', '-v']
     command += files
     if self.options.get('ignore'):
         command += ['--ignore ', self.options.get('ignore')]
     if self.options.get('config'):
         command += ['--config', self.apply_base(self.options['config'])]
     output = run_command(
         command,
         ignore_error=True)
     filename_converter = functools.partial(
         self._relativize_filename,
         files)
     self._process_checkstyle(output, filename_converter)
コード例 #5
0
ファイル: jshint.py プロジェクト: waltsu/lint-review
 def create_command(self, files):
     cmd = 'jshint'
     if npm_exists('jshint'):
         cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'jshint')
     command = [cmd, '--checkstyle-reporter']
     # Add config file if its present
     if self.options.get('config'):
         command += ['--config', self.apply_base(self.options['config'])]
     command += files
     return command
コード例 #6
0
ファイル: jshint.py プロジェクト: Ronan-/lint-review
 def create_command(self, files):
     cmd = 'jshint'
     if npm_exists('jshint'):
         cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'jshint')
     command = [cmd, '--checkstyle-reporter']
     # Add config file if its present
     if self.options.get('config'):
         command += ['--config', self.apply_base(self.options['config'])]
     command += files
     return command
コード例 #7
0
ファイル: xo.py プロジェクト: ianlintner-wf/lint-review
    def process_files(self, files):
        """
        Run code checks with XO.
        """
        log.debug('Processing %s files with %s', files, self.name)
        cmd = self.name
        if npm_exists('xo'):
            cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'xo')
        command = [cmd, '--reporter', 'checkstyle']

        command += files
        output = run_command(command, ignore_error=True)
        self._process_output(output, files)
コード例 #8
0
ファイル: xo.py プロジェクト: esoergel/lint-review
    def process_files(self, files):
        """
        Run code checks with XO.
        """
        log.debug('Processing %s files with %s', files, self.name)
        cmd = self.name
        if npm_exists('xo'):
            cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'xo')
        command = [cmd, '--reporter', 'checkstyle']

        command += files
        output = run_command(command, ignore_error=True)
        self._process_output(output, files)
コード例 #9
0
 def process_files(self, files):
     """
     Run code checks with ESLint.
     """
     log.debug('Processing %s files with %s', files, self.name)
     cmd = self.name
     if npm_exists('eslint'):
         cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'eslint')
     command = [cmd, '--format', 'checkstyle']
     # Add config file if it's present
     if self.options.get('config'):
         command += ['--config', self.apply_base(self.options['config'])]
     command += files
     output = run_command(command, ignore_error=True)
     self._process_checkstyle(output)
コード例 #10
0
    def process_files(self, files):
        """
        Run code checks with standard.
        """
        log.debug('Processing %s files with %s', files, self.name)
        cmd = self.name
        if npm_exists('standard'):
            cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'standard')

        filename_converter = functools.partial(self._relativize_filename,
                                               files)

        command = [cmd] + list(files)
        output = run_command(command, split=True, ignore_error=True)

        output = filter(lambda line: not line.startswith('standard'), output)
        process_quickfix(self.problems, output, filename_converter)
コード例 #11
0
    def process_files(self, files):
        """
        Run code checks with csslint.
        Only a single process is made for all files
        to save resources.
        """
        log.debug('Processing %s files with %s', files, self.name)
        cmd = 'csslint'
        if npm_exists('csslint'):
            cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'csslint')
        command = [cmd, '--format=checkstyle-xml']

        if self.options.get('ignore'):
            command += ['--ignore=' + self.options.get('ignore')]
        command += files
        output = run_command(command, ignore_error=True)
        self._process_checkstyle(output)
コード例 #12
0
ファイル: eslint.py プロジェクト: Ronan-/lint-review
 def process_files(self, files):
     """
     Run code checks with ESLint.
     """
     log.debug('Processing %s files with %s', files, self.name)
     cmd = self.name
     if npm_exists('eslint'):
         cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'eslint')
     command = [cmd, '--format', 'checkstyle']
     # Add config file if it's present
     if self.options.get('config'):
         command += ['--config', self.apply_base(self.options['config'])]
     command += files
     output = run_command(
         command,
         ignore_error=True)
     self._process_checkstyle(output)
コード例 #13
0
ファイル: csslint.py プロジェクト: colindecarlo/lint-review
    def process_files(self, files):
        """
        Run code checks with csslint.
        Only a single process is made for all files
        to save resources.
        """
        log.debug('Processing %s files with %s', files, self.name)
        cmd = 'csslint'
        if npm_exists('csslint'):
            cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'csslint')
        command = [cmd, '--format=checkstyle-xml']

        if self.options.get('ignore'):
            command += ['--ignore=' + self.options.get('ignore')]
        command += files
        output = run_command(
            command,
            ignore_error=True)
        self._process_checkstyle(output)
コード例 #14
0
ファイル: standardjs.py プロジェクト: esoergel/lint-review
    def process_files(self, files):
        """
        Run code checks with standard.
        """
        log.debug('Processing %s files with %s', files, self.name)
        cmd = self.name
        if npm_exists('standard'):
            cmd = os.path.join(os.getcwd(), 'node_modules', '.bin', 'standard')

        filename_converter = functools.partial(
            self._relativize_filename,
            files)

        command = [cmd] + list(files)
        output = run_command(
            command,
            split=True,
            ignore_error=True)

        output = [line for line in output if not line.startswith('standard')]
        process_quickfix(self.problems, output, filename_converter)
コード例 #15
0
ファイル: jscs.py プロジェクト: ianlintner-wf/lint-review
 def check_dependencies(self):
     """
     See if jscs is on the system path.
     """
     return in_path('jscs') or npm_exists('jscs')
コード例 #16
0
ファイル: xo.py プロジェクト: esoergel/lint-review
 def check_dependencies(self):
     """
     See if XO is on the system path.
     """
     return in_path('xo') or npm_exists('xo')
コード例 #17
0
ファイル: standardjs.py プロジェクト: esoergel/lint-review
 def check_dependencies(self):
     """
     See if standard is on the system path.
     """
     return in_path('standard') or npm_exists('standard')
コード例 #18
0
ファイル: eslint.py プロジェクト: ianlintner-wf/lint-review
 def check_dependencies(self):
     """
     See if ESLint is on the system path.
     """
     return in_path('eslint') or npm_exists('eslint')
コード例 #19
0
ファイル: test_jscs.py プロジェクト: esoergel/lint-review
from __future__ import absolute_import
from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.tools.jscs import Jscs
from lintreview.utils import in_path
from lintreview.utils import npm_exists
from unittest import TestCase
from unittest import skipIf
from nose.tools import eq_

jscs_missing = not(in_path('jscs') or npm_exists('jscs'))


class TestJscs(TestCase):

    needs_jscs = skipIf(jscs_missing, 'Needs jscs to run')

    fixtures = [
        'tests/fixtures/jscs/no_errors.js',
        'tests/fixtures/jscs/has_errors.js',
    ]

    def setUp(self):
        self.problems = Problems()
        self.tool = Jscs(self.problems)

    def test_match_file(self):
        self.assertFalse(self.tool.match_file('test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertTrue(self.tool.match_file('test.js'))
コード例 #20
0
from __future__ import absolute_import
from unittest import TestCase
from unittest import skipIf

from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.tools.xo import Xo
from lintreview.utils import in_path
from lintreview.utils import npm_exists
from nose.tools import eq_

xo_missing = not (in_path('xo') or npm_exists('xo'))

FILE_WITH_NO_ERRORS = 'tests/samples/xo/no_errors.js',
FILE_WITH_ERRORS = 'tests/samples/xo/has_errors.js'


class TestXo(TestCase):

    needs_xo = skipIf(xo_missing, 'Needs xo to run')

    def setUp(self):
        self.problems = Problems()
        options = {'ignore': ''}
        self.tool = Xo(self.problems, options)

    def test_match_file(self):
        self.assertFalse(self.tool.match_file('test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertTrue(self.tool.match_file('test.js'))
コード例 #21
0
from __future__ import absolute_import
from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.utils import in_path
from lintreview.utils import npm_exists
from lintreview.tools.sasslint import Sasslint
from unittest import TestCase
from unittest import skipIf
from nose.tools import eq_

sasslint_missing = not(in_path('sass-lint') or npm_exists('sass-lint'))


class TestSasslint(TestCase):

    needs_sasslint = skipIf(sasslint_missing, 'Needs sasslint')

    fixtures = [
        'tests/fixtures/sasslint/no_errors.scss',
        'tests/fixtures/sasslint/has_errors.scss',
    ]

    def setUp(self):
        self.problems = Problems()
        self.tool = Sasslint(self.problems)

    def test_match_file(self):
        self.assertFalse(self.tool.match_file('test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertTrue(self.tool.match_file('test.sass'))
コード例 #22
0
ファイル: test_eslint.py プロジェクト: minichate/lint-review
from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.tools.eslint import Eslint
from lintreview.utils import in_path
from lintreview.utils import npm_exists
from unittest import TestCase
from unittest import skipIf
from nose.tools import eq_

eslint_missing = not (in_path('eslint') or npm_exists('eslint'))


class TestEslint(TestCase):

    needs_eslint = skipIf(eslint_missing, 'Needs eslint to run')

    fixtures = [
        'tests/fixtures/eslint/no_errors.js',
        'tests/fixtures/eslint/has_errors.js'
    ]

    def setUp(self):
        self.problems = Problems()
        self.tool = Eslint(self.problems)

    def test_match_file(self):
        self.assertFalse(self.tool.match_file('test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertTrue(self.tool.match_file('test.js'))
        self.assertTrue(self.tool.match_file('dir/name/test.js'))
コード例 #23
0
ファイル: csslint.py プロジェクト: alexBaizeau/lint-review
 def check_dependencies(self):
     """
     See if csslint is on the system path.
     """
     return in_path('csslint') or npm_exists('csslint')
コード例 #24
0
ファイル: test_jscs.py プロジェクト: pSub/lint-review
from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.tools.jscs import Jscs
from lintreview.utils import in_path
from lintreview.utils import npm_exists
from unittest import TestCase
from unittest import skipIf
from nose.tools import eq_

jscs_missing = not (in_path("jscs") or npm_exists("jscs"))


class TestJcs(TestCase):

    needs_jscs = skipIf(jscs_missing, "Needs jscs to run")

    fixtures = ["tests/fixtures/jscs/no_errors.js", "tests/fixtures/jscs/has_errors.js"]

    def setUp(self):
        self.problems = Problems()
        self.tool = Jscs(self.problems)

    def test_match_file(self):
        self.assertFalse(self.tool.match_file("test.php"))
        self.assertFalse(self.tool.match_file("dir/name/test.py"))
        self.assertFalse(self.tool.match_file("test.py"))
        self.assertTrue(self.tool.match_file("test.js"))
        self.assertTrue(self.tool.match_file("dir/name/test.js"))

    @needs_jscs
    def test_check_dependencies(self):
コード例 #25
0
ファイル: test_jshint.py プロジェクト: markstory/lint-review
from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.tools.jshint import Jshint
from lintreview.utils import in_path
from lintreview.utils import npm_exists
from unittest import TestCase
from unittest import skipIf
from nose.tools import eq_

jshint_missing = not (in_path("jshint") or npm_exists("jshint"))


class TestJshint(TestCase):

    needs_jshint = skipIf(jshint_missing, "Needs jshint to run")

    fixtures = [
        "tests/fixtures/jshint/no_errors.js",
        "tests/fixtures/jshint/has_errors.js",
        "tests/fixtures/jshint/error_on_multiple_lines.js",
    ]

    def setUp(self):
        self.problems = Problems()
        self.tool = Jshint(self.problems)

    def test_match_file(self):
        self.assertFalse(self.tool.match_file("test.php"))
        self.assertFalse(self.tool.match_file("dir/name/test.py"))
        self.assertFalse(self.tool.match_file("test.py"))
        self.assertTrue(self.tool.match_file("test.js"))
コード例 #26
0
from __future__ import absolute_import
from unittest import TestCase
from unittest import skipIf

from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.tools.standardjs import Standardjs
from lintreview.utils import in_path
from lintreview.utils import npm_exists
from nose.tools import eq_

standardjs_missing = not(in_path('standard') or npm_exists('standard'))

FILE_WITH_NO_ERRORS = 'tests/fixtures/standardjs/no_errors.js',
FILE_WITH_ERRORS = 'tests/fixtures/standardjs/has_errors.js'


class TestStandardjs(TestCase):

    needs_standardjs = skipIf(standardjs_missing, 'Needs standardjs to run')

    def setUp(self):
        self.problems = Problems()
        options = {}
        self.tool = Standardjs(self.problems, options)

    def test_match_file(self):
        self.assertFalse(self.tool.match_file('test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertTrue(self.tool.match_file('test.js'))
コード例 #27
0
from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.utils import in_path
from lintreview.utils import npm_exists
from lintreview.tools.sasslint import Sasslint
from unittest import TestCase
from unittest import skipIf
from nose.tools import eq_

sasslint_missing = not (in_path("sass-lint") or npm_exists("sass-lint"))


class TestSasslint(TestCase):

    needs_sasslint = skipIf(sasslint_missing, "Needs sasslint")

    fixtures = ["tests/fixtures/sasslint/no_errors.scss", "tests/fixtures/sasslint/has_errors.scss"]

    def setUp(self):
        self.problems = Problems()
        self.tool = Sasslint(self.problems)

    def test_match_file(self):
        self.assertFalse(self.tool.match_file("test.php"))
        self.assertFalse(self.tool.match_file("dir/name/test.py"))
        self.assertFalse(self.tool.match_file("test.py"))
        self.assertTrue(self.tool.match_file("test.sass"))
        self.assertTrue(self.tool.match_file("dir/name/test.sass"))
        self.assertTrue(self.tool.match_file("dir/name/test.scss"))

    @needs_sasslint
コード例 #28
0
from unittest import TestCase
from unittest import skipIf

from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.tools.standardjs import Standardjs
from lintreview.utils import in_path
from lintreview.utils import npm_exists
from nose.tools import eq_

standardjs_missing = not (in_path('standard') or npm_exists('standard'))

FILE_WITH_NO_ERRORS = 'tests/fixtures/standardjs/no_errors.js',
FILE_WITH_ERRORS = 'tests/fixtures/standardjs/has_errors.js'


class TestStandardjs(TestCase):

    needs_standardjs = skipIf(standardjs_missing, 'Needs standardjs to run')

    def setUp(self):
        self.problems = Problems()
        options = {}
        self.tool = Standardjs(self.problems, options)

    def test_match_file(self):
        self.assertFalse(self.tool.match_file('test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertTrue(self.tool.match_file('test.js'))
        self.assertTrue(self.tool.match_file('dir/name/test.js'))
コード例 #29
0
from __future__ import absolute_import
from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.tools.jscs import Jscs
from lintreview.utils import in_path
from lintreview.utils import npm_exists
from unittest import TestCase
from unittest import skipIf
from nose.tools import eq_

jscs_missing = not (in_path('jscs') or npm_exists('jscs'))


class TestJscs(TestCase):

    needs_jscs = skipIf(jscs_missing, 'Needs jscs to run')

    fixtures = [
        'tests/fixtures/jscs/no_errors.js',
        'tests/fixtures/jscs/has_errors.js',
    ]

    def setUp(self):
        self.problems = Problems()
        self.tool = Jscs(self.problems)

    def test_match_file(self):
        self.assertFalse(self.tool.match_file('test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertTrue(self.tool.match_file('test.js'))
コード例 #30
0
 def check_dependencies(self):
     """
     See if standard is on the system path.
     """
     return in_path('standard') or npm_exists('standard')
コード例 #31
0
ファイル: test_eslint.py プロジェクト: Ronan-/lint-review
from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.tools.eslint import Eslint
from lintreview.utils import in_path
from lintreview.utils import npm_exists
from unittest import TestCase
from unittest import skipIf
from nose.tools import eq_

eslint_missing = not(in_path('eslint') or npm_exists('eslint'))

class TestEslint(TestCase):

    needs_eslint = skipIf(eslint_missing, 'Needs eslint to run')

    fixtures = [
        'tests/fixtures/eslint/no_errors.js',
        'tests/fixtures/eslint/has_errors.js'
    ]

    def setUp(self):
        self.problems = Problems()
        self.tool = Eslint(self.problems)

    def test_match_file(self):
        self.assertFalse(self.tool.match_file('test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertTrue(self.tool.match_file('test.js'))
        self.assertTrue(self.tool.match_file('dir/name/test.js'))
コード例 #32
0
ファイル: test_utils.py プロジェクト: waltsu/lint-review
def test_npm_exists():
    assert utils.npm_exists('jshint'), 'Should be there.'
    assert not utils.npm_exists('not there'), 'Should not be there.'