Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (101724 => 101725)
--- trunk/Tools/Scripts/webkitpy/style/checker.py 2011-12-02 01:03:37 UTC (rev 101724)
+++ trunk/Tools/Scripts/webkitpy/style/checker.py 2011-12-02 01:14:12 UTC (rev 101725)
@@ -39,7 +39,6 @@
from checkers.common import CarriageReturnChecker
from checkers.changelog import ChangeLogChecker
from checkers.cpp import CppChecker
-from checkers.jsonchecker import JSONChecker
from checkers.python import PythonChecker
from checkers.test_expectations import TestExpectationsChecker
from checkers.text import TextChecker
@@ -230,8 +229,6 @@
'h',
]
-_JSON_FILE_EXTENSION = 'json'
-
_PYTHON_FILE_EXTENSION = 'py'
_TEXT_FILE_EXTENSIONS = [
@@ -306,7 +303,6 @@
"""Return the set of all categories used by check-webkit-style."""
# Take the union across all checkers.
categories = CommonCategories.union(CppChecker.categories)
- categories = categories.union(JSONChecker.categories)
categories = categories.union(TestExpectationsChecker.categories)
categories = categories.union(ChangeLogChecker.categories)
@@ -449,12 +445,11 @@
# Alphabetize remaining types
CHANGELOG = 1
CPP = 2
- JSON = 3
- PYTHON = 4
- TEXT = 5
- WATCHLIST = 6
- XML = 7
- XCODEPROJ = 8
+ PYTHON = 3
+ TEXT = 4
+ WATCHLIST = 5
+ XML = 6
+ XCODEPROJ = 7
class CheckerDispatcher(object):
@@ -517,8 +512,6 @@
# reading from stdin, cpp_style tests should not rely on
# the extension.
return FileType.CPP
- elif file_extension == _JSON_FILE_EXTENSION:
- return FileType.JSON
elif file_extension == _PYTHON_FILE_EXTENSION:
return FileType.PYTHON
elif file_extension in _XML_FILE_EXTENSIONS:
@@ -549,8 +542,6 @@
file_extension = self._file_extension(file_path)
checker = CppChecker(file_path, file_extension,
handle_style_error, min_confidence)
- elif file_type == FileType.JSON:
- checker = JSONChecker(file_path, handle_style_error)
elif file_type == FileType.PYTHON:
checker = PythonChecker(file_path, handle_style_error)
elif file_type == FileType.XML:
Modified: trunk/Tools/Scripts/webkitpy/style/checker_unittest.py (101724 => 101725)
--- trunk/Tools/Scripts/webkitpy/style/checker_unittest.py 2011-12-02 01:03:37 UTC (rev 101724)
+++ trunk/Tools/Scripts/webkitpy/style/checker_unittest.py 2011-12-02 01:14:12 UTC (rev 101725)
@@ -53,7 +53,6 @@
from checker import StyleProcessorConfiguration
from checkers.changelog import ChangeLogChecker
from checkers.cpp import CppChecker
-from checkers.jsonchecker import JSONChecker
from checkers.python import PythonChecker
from checkers.text import TextChecker
from checkers.xml import XMLChecker
@@ -406,10 +405,6 @@
"""Assert that the dispatched checker is a CppChecker."""
self.assert_checker(file_path, CppChecker)
- def assert_checker_json(self, file_path):
- """Assert that the dispatched checker is a JSONChecker."""
- self.assert_checker(file_path, JSONChecker)
-
def assert_checker_python(self, file_path):
"""Assert that the dispatched checker is a PythonChecker."""
self.assert_checker(file_path, PythonChecker)
@@ -472,25 +467,6 @@
self.assertEquals(checker.file_extension, file_extension)
self.assertEquals(checker.file_path, file_path)
- def test_json_paths(self):
- """Test paths that should be checked as JSON."""
- paths = [
- "Source/WebCore/inspector/Inspector.json",
- "Tools/BuildSlaveSupport/build.webkit.org-config/config.json",
- ]
-
- for path in paths:
- self.assert_checker_json(path)
-
- # Check checker attributes on a typical input.
- file_base = "foo"
- file_extension = "json"
- file_path = file_base + "." + file_extension
- self.assert_checker_json(file_path)
- checker = self.dispatch(file_path)
- self.assertEquals(checker._handle_style_error,
- self.mock_handle_style_error)
-
def test_python_paths(self):
"""Test paths that should be checked as Python."""
paths = [
Deleted: trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py (101724 => 101725)
--- trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py 2011-12-02 01:03:37 UTC (rev 101724)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py 2011-12-02 01:14:12 UTC (rev 101725)
@@ -1,54 +0,0 @@
-# Copyright (C) 2011 Apple Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
-# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-"""Checks WebKit style for JSON files."""
-
-import re
-
-try:
- import json
-except ImportError:
- # python 2.5 compatibility
- import webkitpy.thirdparty.simplejson as json
-
-
-class JSONChecker(object):
- """Processes JSON lines for checking style."""
-
- categories = set(('json/syntax',))
-
- def __init__(self, file_path, handle_style_error):
- self._handle_style_error = handle_style_error
- self._handle_style_error.turn_off_line_filtering()
-
- def check(self, lines):
- try:
- json.loads('\n'.join(lines) + '\n')
- except ValueError, e:
- self._handle_style_error(self.line_number_from_json_exception(e), 'json/syntax', 5, e.message)
-
- @staticmethod
- def line_number_from_json_exception(error):
- match = re.search(r': line (?P<line>\d+) column \d+', error.message)
- if not match:
- return 0
- return int(match.group('line'))
Deleted: trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker_unittest.py (101724 => 101725)
--- trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker_unittest.py 2011-12-02 01:03:37 UTC (rev 101724)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker_unittest.py 2011-12-02 01:14:12 UTC (rev 101725)
@@ -1,118 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2010 Apple Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
-# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-"""Unit test for jsonchecker.py."""
-
-import unittest
-
-import jsonchecker
-
-
-class MockErrorHandler(object):
- def __init__(self, handle_style_error):
- self.turned_off_filtering = False
- self._handle_style_error = handle_style_error
-
- def turn_off_line_filtering(self):
- self.turned_off_filtering = True
-
- def __call__(self, line_number, category, confidence, message):
- self._handle_style_error(self, line_number, category, confidence, message)
-
-
-class JSONCheckerTest(unittest.TestCase):
- """Tests JSONChecker class."""
-
- def test_line_number_from_json_exception(self):
- tests = (
- (0, 'No JSON object could be decoded'),
- (2, 'Expecting property name: line 2 column 1 (char 2)'),
- (3, 'Expecting object: line 3 column 1 (char 15)'),
- (9, 'Expecting property name: line 9 column 21 (char 478)'),
- )
- for expected_line, message in tests:
- self.assertEqual(expected_line, jsonchecker.JSONChecker.line_number_from_json_exception(ValueError(message)))
-
- def assert_no_error(self, json_data):
- def handle_style_error(mock_error_handler, line_number, category, confidence, message):
- self.fail('Unexpected error: %d %s %d %s' % (line_number, category, confidence, message))
-
- error_handler = MockErrorHandler(handle_style_error)
- checker = jsonchecker.JSONChecker('foo.json', error_handler)
- checker.check(json_data.split('\n'))
- self.assertTrue(error_handler.turned_off_filtering)
-
- def assert_error(self, expected_line_number, expected_category, json_data):
- def handle_style_error(mock_error_handler, line_number, category, confidence, message):
- mock_error_handler.had_error = True
- self.assertEquals(expected_line_number, line_number)
- self.assertEquals(expected_category, category)
- self.assertIn(category, jsonchecker.JSONChecker.categories)
-
- error_handler = MockErrorHandler(handle_style_error)
- error_handler.had_error = False
-
- checker = jsonchecker.JSONChecker('foo.json', error_handler)
- checker.check(json_data.split('\n'))
- self.assertTrue(error_handler.had_error)
- self.assertTrue(error_handler.turned_off_filtering)
-
- def mock_handle_style_error(self):
- pass
-
- def test_conflict_marker(self):
- self.assert_error(0, 'json/syntax', '<<<<<<< HEAD\n{\n}\n')
-
- def test_single_quote(self):
- self.assert_error(2, 'json/syntax', "{\n'slaves': []\n}\n")
-
- def test_init(self):
- error_handler = MockErrorHandler(self.mock_handle_style_error)
- checker = jsonchecker.JSONChecker('foo.json', error_handler)
- self.assertEquals(checker._handle_style_error, error_handler)
-
- def test_missing_closing_brace(self):
- self.assert_error(3, 'json/syntax', '{\n"slaves": []\n')
-
- def test_no_error(self):
- self.assert_no_error("""{
- "slaves": [ { "name": "test-slave", "platform": "*" },
- { "name": "apple-xserve-4", "platform": "mac-snowleopard" }
- ],
-
- "builders": [ { "name": "SnowLeopard Intel Release (Build)", "type": "Build", "builddir": "snowleopard-intel-release",
- "platform": "mac-snowleopard", "configuration": "release", "architectures": ["x86_64"],
- "slavenames": ["apple-xserve-4"]
- }
- ],
-
- "schedulers": [ { "type": "PlatformSpecificScheduler", "platform": "mac-snowleopard", "branch": "trunk", "treeStableTimer": 45.0,
- "builderNames": ["SnowLeopard Intel Release (Build)", "SnowLeopard Intel Debug (Build)"]
- }
- ]
-}
-""")
-
-if __name__ == '__main__':
- unittest.main()