Teach style checker about preprocessor directive indentation rules
authorpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Sep 2012 18:26:20 +0000 (18:26 +0000)
committerpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Sep 2012 18:26:20 +0000 (18:26 +0000)
commitfe4681734c96f4cd16879ca7214edb0db71d82c5
tree42c8f3c1308f86d4650a13879fa74d0697388864
parent4d93b5018ff97480a2475c54e9267373347344cf
Teach style checker about preprocessor directive indentation rules
https://bugs.webkit.org/show_bug.cgi?id=96874

Reviewed by Adam Barth.

Preprocessor directives (#ifdef, #include, #define, etc.) should not be indented.
This is not explicit in our style guide but is generally followed in our code.
Searching for violations in our codebase shows these are rarely indented:
    #include - indented in 6 files
    #ifdef - indented in 0 files
    #ifndef - indented in 1 file
    #define - indented in 11 files
    #if - indented in 7 files

* Scripts/webkitpy/style/checkers/cpp.py:
(check_directive_indentation):

    This is the simple test where we look for spaces followed by a #.

(check_style):
* Scripts/webkitpy/style/checkers/cpp_unittest.py:

    A few tests needed to be modified because they had unintentionally indented
    preprocessor directives.

(CppStyleTest.test_build_class.Foo):
(CppStyleTest.test_build_class):
(CppStyleTest.test_build_class.DERIVE_FROM_GOO):
(WebKitStyleTest.test_line_breaking):
(WebKitStyleTest.test_directive_indentation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@128782 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Tools/ChangeLog
Tools/Scripts/webkitpy/style/checkers/cpp.py
Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py