Exemplo n.º 1
0
 def create_fixer_command(self, files):
     command = ['phpcbf']
     if composer_exists('phpcbf'):
         command = ['vendor/bin/phpcbf']
     command = self._apply_options(command)
     command += files
     return command
Exemplo n.º 2
0
 def create_fixer_command(self, files):
     command = ['phpcbf']
     if composer_exists('phpcbf'):
         command = ['vendor/bin/phpcbf']
     command = self._apply_options(command)
     command += files
     return command
Exemplo n.º 3
0
 def create_command(self, files):
     command = ['phpcs']
     if composer_exists('phpcs'):
         command = ['vendor/bin/phpcs']
     command += ['--report=checkstyle']
     command = self._apply_options(command)
     command += files
     return command
Exemplo n.º 4
0
 def create_command(self, files):
     command = ['phpcs']
     if composer_exists('phpcs'):
         command = ['vendor/bin/phpcs']
     command += ['--report=checkstyle']
     command = self._apply_options(command)
     command += files
     return command
Exemplo n.º 5
0
 def create_command(self, files):
     command = ['phpcs']
     if composer_exists('phpcs'):
         command = ['vendor/bin/phpcs']
     command += ['--report=checkstyle']
     standard = 'PSR2'
     if self.options.get('standard'):
         standard = self.apply_base(self.options['standard'])
     extension = 'php'
     if self.options.get('extensions'):
         extension = self.options['extensions']
     command += ['--standard=' + standard]
     command += ['--extensions=' + extension]
     if self.options.get('tab_width'):
         command += ['--tab-width=' + str(self.options['tab_width'])]
     command += files
     return command
Exemplo n.º 6
0
 def create_command(self, files):
     command = ['phpcs']
     if composer_exists('phpcs'):
         command = ['vendor/bin/phpcs']
     command += ['--report=checkstyle']
     standard = 'PSR2'
     if self.options.get('standard'):
         standard = self.apply_base(self.options['standard'])
     extension = 'php'
     if self.options.get('extensions'):
         extension = self.options['extensions']
     command += ['--standard=' + standard]
     command += ['--extensions=' + extension]
     if self.options.get('tab_width'):
         command += ['--tab-width=' + str(self.options['tab_width'])]
     command += files
     return command
Exemplo n.º 7
0
    def create_command(self, files):
        command = ['phpcs']
        if composer_exists('phpcs'):
            command = ['vendor/bin/phpcs']
        command += ['--report=checkstyle']
        standard = 'PSR2'
        if self.options.get('standard'):
            standard = self.apply_base(self.options['standard'])
        command.append('--standard=' + stringify(standard))

        if self.options.get('ignore'):
            ignore = self.options['ignore']
            command.append('--ignore=' + stringify(ignore))
        if self.options.get('exclude'):
            exclude = self.options['exclude']
            command.append('--exclude=' + stringify(exclude))
        extension = 'php'
        if self.options.get('extensions'):
            extension = self.options['extensions']
        command.append('--extensions=' + stringify(extension))
        if self.options.get('tab_width'):
            command += ['--tab-width=' + stringify(self.options['tab_width'])]
        command += files
        return command
Exemplo n.º 8
0
from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.tools.phpcs import Phpcs
from lintreview.utils import in_path, composer_exists
from unittest import TestCase
from unittest import skipIf
from nose.tools import eq_

phpcs_missing = not (composer_exists('phpcs'))


class Testphpcs(TestCase):

    needs_phpcs = skipIf(phpcs_missing, 'Needs phpcs')

    fixtures = [
        'tests/fixtures/phpcs/no_errors.php',
        'tests/fixtures/phpcs/has_errors.php',
    ]

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

    def test_match_file(self):
        self.assertTrue(self.tool.match_file('test.php'))
        self.assertTrue(self.tool.match_file('dir/name/test.php'))
        self.assertFalse(self.tool.match_file('dir/name/test.py'))
        self.assertFalse(self.tool.match_file('test.py'))
        self.assertFalse(self.tool.match_file('test.js'))
Exemplo n.º 9
0
 def check_dependencies(self):
     """
     See if phpcs is on the system path.
     """
     return in_path('phpcs') or composer_exists('phpcs')
Exemplo n.º 10
0
 def check_dependencies(self):
     """
     See if phpcs is on the system path.
     """
     return in_path('phpcs') or composer_exists('phpcs')
Exemplo n.º 11
0
from lintreview.review import Problems
from lintreview.review import Comment
from lintreview.tools.phpcs import Phpcs
from lintreview.utils import in_path, composer_exists
from unittest import TestCase
from unittest import skipIf
from nose.tools import eq_

phpcs_missing = not(composer_exists('phpcs'))


class Testphpcs(TestCase):

    needs_phpcs = skipIf(phpcs_missing, 'Needs phpcs')

    fixtures = [
        'tests/fixtures/phpcs/no_errors.php',
        'tests/fixtures/phpcs/has_errors.php',
    ]

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

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