當前位置: 首頁>>代碼示例>>Python>>正文


Python phpcs.Phpcs類代碼示例

本文整理匯總了Python中lintreview.tools.phpcs.Phpcs的典型用法代碼示例。如果您正苦於以下問題:Python Phpcs類的具體用法?Python Phpcs怎麽用?Python Phpcs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Phpcs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_process_files_with_config

    def test_process_files_with_config(self):
        config = {"standard": "Zend"}
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(8, len(problems), "Changing standards changes error counts")
開發者ID:kevinjqiu,項目名稱:lint-review,代碼行數:8,代碼來源:test_phpcs.py

示例2: test_execute_fixer

    def test_execute_fixer(self):
        tool = Phpcs(self.problems, {'fixer': True})

        original = read_file(self.fixtures[1])
        tool.execute_fixer(self.fixtures)

        updated = read_and_restore_file(self.fixtures[1], original)
        assert original != updated, 'File content should change.'
        eq_(0, len(self.problems.all()), 'No errors should be recorded')
開發者ID:esoergel,項目名稱:lint-review,代碼行數:9,代碼來源:test_phpcs.py

示例3: test_process_files_with_config

    def test_process_files_with_config(self):
        config = {
            'standard': 'Zend'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(3, len(problems), 'Changing standards changes error counts')
開發者ID:halfcrazy,項目名稱:lint-review,代碼行數:10,代碼來源:test_phpcs.py

示例4: test_execute_fixer__no_problems_remain

    def test_execute_fixer__no_problems_remain(self):
        tool = Phpcs(self.problems, {'fixer': True})

        # The fixture file can have all problems fixed by phpcs
        original = read_file(self.fixtures[1])
        tool.execute_fixer(self.fixtures)
        tool.process_files(self.fixtures)

        read_and_restore_file(self.fixtures[1], original)
        eq_(0, len(self.problems.all()), 'All errors should be autofixed')
開發者ID:esoergel,項目名稱:lint-review,代碼行數:10,代碼來源:test_phpcs.py

示例5: test_process_files__with_ignore

    def test_process_files__with_ignore(self):
        config = {
            'standard': 'PSR2',
            'ignore': 'tests/fixtures/phpcs/*'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(0, len(problems), 'ignore option should exclude files')
開發者ID:esoergel,項目名稱:lint-review,代碼行數:11,代碼來源:test_phpcs.py

示例6: test_process_files__with_exclude

    def test_process_files__with_exclude(self):
        config = {
            'standard': 'PSR2',
            'exclude': 'Generic.WhiteSpace.DisallowTabIndent'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(1, len(problems), 'exclude option should reduce errors.')
開發者ID:esoergel,項目名稱:lint-review,代碼行數:11,代碼來源:test_phpcs.py

示例7: test_create_command__with_path_based_standard

 def test_create_command__with_path_based_standard(self):
     config = {"standard": "test/CodeStandards"}
     tool = Phpcs(self.problems, config, "/some/path")
     result = tool.create_command(["some/file.php"])
     expected = [
         "phpcs",
         "--report=checkstyle",
         "--standard=/some/path/test/CodeStandards",
         "--extensions=php",
         "some/file.php",
     ]
     eq_(result, expected)
開發者ID:kevinjqiu,項目名稱:lint-review,代碼行數:12,代碼來源:test_phpcs.py

示例8: test_create_command__with_path_based_standard

 def test_create_command__with_path_based_standard(self):
     config = {
         'standard': 'test/CodeStandards'
     }
     tool = Phpcs(self.problems, config, '/some/path')
     result = tool.create_command(['some/file.php'])
     expected = [
         'phpcs',
         '--report=checkstyle',
         '--standard=/some/path/test/CodeStandards',
         '--extensions=php',
         'some/file.php'
     ]
     eq_(result, expected)
開發者ID:alexBaizeau,項目名稱:lint-review,代碼行數:14,代碼來源:test_phpcs.py

示例9: test_process_files__with_invalid_exclude

    def test_process_files__with_invalid_exclude(self):
        config = {
            'standard': 'PSR2',
            'exclude': 'Derpity.Derp'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all()
        eq_(1, len(problems), 'A failure comment should be logged.')

        error = problems[0].body
        ok_('Your PHPCS configuration output the following error' in error)
        ok_('Derpity.Derp' in error)
開發者ID:esoergel,項目名稱:lint-review,代碼行數:14,代碼來源:test_phpcs.py

示例10: test_create_command__with_path_based_standard

 def test_create_command__with_path_based_standard(self):
     config = {
         'standard': 'test/CodeStandards',
         'tab_width': 4,
     }
     tool = Phpcs(self.problems, config, root_dir)
     result = tool.create_command(['some/file.php'])
     expected = [
         'phpcs',
         '--report=checkstyle',
         '--standard=/src/test/CodeStandards',
         '--extensions=php',
         '--tab-width=4',
         '/src/some/file.php'
     ]
     self.assertEqual(result, expected)
開發者ID:markstory,項目名稱:lint-review,代碼行數:16,代碼來源:test_phpcs.py

示例11: test_create_command__ignore_option_as_list

 def test_create_command__ignore_option_as_list(self):
     config = {
         'standard': 'PSR2',
         'extensions': ['php', 'ctp'],
         'exclude': ['rule1', 'rule2'],
         'ignore': ['tests/fixtures/phpcs/*', 'tests/fixtures/eslint/*']
     }
     tool = Phpcs(self.problems, config, root_dir)
     result = tool.create_command(['some/file.php'])
     expected = [
         'phpcs',
         '--report=checkstyle',
         '--standard=PSR2',
         '--ignore=tests/fixtures/phpcs/*,tests/fixtures/eslint/*',
         '--exclude=rule1,rule2',
         '--extensions=php,ctp',
         '/src/some/file.php'
     ]
     self.assertEqual(result, expected)
開發者ID:markstory,項目名稱:lint-review,代碼行數:19,代碼來源:test_phpcs.py

示例12: test_create_command__with_path_based_standard

 def test_create_command__with_path_based_standard(self):
     command = 'vendor/bin/phpcs'
     if phpcs_missing:
         command = 'phpcs'
     config = {
         'standard': 'test/CodeStandards',
         'tab_width': 4,
     }
     tool = Phpcs(self.problems, config, '/some/path')
     result = tool.create_command(['some/file.php'])
     expected = [
         command,
         '--report=checkstyle',
         '--standard=/some/path/test/CodeStandards',
         '--extensions=php',
         '--tab-width=4',
         'some/file.php'
     ]
     eq_(result, expected)
開發者ID:halfcrazy,項目名稱:lint-review,代碼行數:19,代碼來源:test_phpcs.py

示例13: test_create_command__ignore_option_as_list

 def test_create_command__ignore_option_as_list(self):
     config = {
         'standard': 'PSR2',
         'extensions': ['php', 'ctp'],
         'exclude': ['rule1', 'rule2'],
         'ignore': ['tests/fixtures/phpcs/*', 'tests/fixtures/eslint/*']
     }
     tool = Phpcs(self.problems, config)
     result = tool.create_command(['some/file.php'])
     command = 'vendor/bin/phpcs'
     if phpcs_missing:
         command = 'phpcs'
     expected = [
         command,
         '--report=checkstyle',
         '--standard=PSR2',
         '--ignore=tests/fixtures/phpcs/*,tests/fixtures/eslint/*',
         '--exclude=rule1,rule2',
         '--extensions=php,ctp',
         'some/file.php'
     ]
     eq_(result, expected)
開發者ID:esoergel,項目名稱:lint-review,代碼行數:22,代碼來源:test_phpcs.py

示例14: setUp

 def setUp(self):
     self.problems = Problems()
     self.tool = Phpcs(self.problems)
開發者ID:halfcrazy,項目名稱:lint-review,代碼行數:3,代碼來源:test_phpcs.py

示例15: Testphpcs

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'))

    @needs_phpcs
    def test_check_dependencies(self):
        self.assertTrue(self.tool.check_dependencies())

    @needs_phpcs
    def test_process_files__one_file_pass(self):
        self.tool.process_files([self.fixtures[0]])
        eq_([], self.problems.all(self.fixtures[0]))

    @needs_phpcs
    def test_process_files__one_file_fail(self):
        self.tool.process_files([self.fixtures[1]])
        problems = self.problems.all(self.fixtures[1])
        eq_(3, len(problems))

        fname = self.fixtures[1]
        expected = Comment(
            fname,
            14,
            14,
            'Opening brace should be on a new line')
        eq_(expected, problems[0])

        expected = Comment(
            fname,
            16,
            16,
            "Spaces must be used to indent lines; tabs are not allowed")
        eq_(expected, problems[2])

    @needs_phpcs
    def test_process_files_two_files(self):
        self.tool.process_files(self.fixtures)

        eq_([], self.problems.all(self.fixtures[0]))

        problems = self.problems.all(self.fixtures[1])
        eq_(3, len(problems))

    @needs_phpcs
    def test_process_files_with_config(self):
        config = {
            'standard': 'Zend'
        }
        tool = Phpcs(self.problems, config)
        tool.process_files([self.fixtures[1]])

        problems = self.problems.all(self.fixtures[1])

        eq_(3, len(problems), 'Changing standards changes error counts')

    def test_create_command__with_path_based_standard(self):
        command = 'vendor/bin/phpcs'
        if phpcs_missing:
            command = 'phpcs'
        config = {
            'standard': 'test/CodeStandards',
            'tab_width': 4,
        }
        tool = Phpcs(self.problems, config, '/some/path')
        result = tool.create_command(['some/file.php'])
        expected = [
            command,
            '--report=checkstyle',
            '--standard=/some/path/test/CodeStandards',
            '--extensions=php',
            '--tab-width=4',
            'some/file.php'
        ]
        eq_(result, expected)
開發者ID:halfcrazy,項目名稱:lint-review,代碼行數:90,代碼來源:test_phpcs.py


注:本文中的lintreview.tools.phpcs.Phpcs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。