Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
| 2 # | 2 # |
| 3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. | 3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. |
| 4 # Copyright (C) 2009 Torch Mobile Inc. | 4 # Copyright (C) 2009 Torch Mobile Inc. |
| 5 # Copyright (C) 2009 Apple Inc. All rights reserved. | 5 # Copyright (C) 2009 Apple Inc. All rights reserved. |
| 6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) | 6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) |
| 7 # | 7 # |
| 8 # Redistribution and use in source and binary forms, with or without | 8 # Redistribution and use in source and binary forms, with or without |
| 9 # modification, are permitted provided that the following conditions are | 9 # modification, are permitted provided that the following conditions are |
| 10 # met: | 10 # met: |
| (...skipping 2551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2562 | 2562 |
| 2563 duplicate_header = include in include_state | 2563 duplicate_header = include in include_state |
| 2564 if duplicate_header: | 2564 if duplicate_header: |
| 2565 error(line_number, 'build/include', 4, | 2565 error(line_number, 'build/include', 4, |
| 2566 '"%s" already included at %s:%s' % | 2566 '"%s" already included at %s:%s' % |
| 2567 (include, filename, include_state[include])) | 2567 (include, filename, include_state[include])) |
| 2568 else: | 2568 else: |
| 2569 include_state[include] = line_number | 2569 include_state[include] = line_number |
| 2570 | 2570 |
| 2571 header_type = _classify_include(filename, include, is_system, include_state) | 2571 header_type = _classify_include(filename, include, is_system, include_state) |
| 2572 primary_header_exists = _does_primary_header_exist(filename) | 2572 primary_header_exists = _does_primary_header_exist(filename) |
|
dcheng
2017/03/17 05:37:29
I think this can be removed (and possibly header_t
alancutter (OOO until 2018)
2017/03/19 23:12:48
Yep, removed.
| |
| 2573 include_state.header_types[line_number] = header_type | 2573 include_state.header_types[line_number] = header_type |
| 2574 | 2574 |
| 2575 # Only proceed if this isn't a duplicate header. | |
| 2576 if duplicate_header: | |
| 2577 return | |
| 2578 | |
| 2579 # We want to ensure that headers appear in the right order: | |
| 2580 # 1) for implementation files: primary header, blank line, alphabetically so rted | |
| 2581 # 2) for header files: alphabetically sorted | |
| 2582 # The include_state object keeps track of the last type seen | |
| 2583 # and complains if the header types are out of order or missing. | |
| 2584 error_message = include_state.check_next_include_order(header_type, | |
| 2585 file_extension == 'h' , | |
| 2586 primary_header_exists ) | |
| 2587 | |
| 2588 # Check to make sure we have a blank line after primary header. | |
| 2589 if not error_message and header_type == _PRIMARY_HEADER: | |
| 2590 next_line = clean_lines.raw_lines[line_number + 1] | |
| 2591 if not is_blank_line(next_line): | |
| 2592 error(line_number, 'build/include_order', 4, | |
| 2593 'You should add a blank line after implementation file\'s own header.') | |
| 2594 | |
| 2595 if error_message: | |
| 2596 if file_extension == 'h': | |
| 2597 error(line_number, 'build/include_order', 4, | |
| 2598 '%s Should be: alphabetically sorted.' % | |
| 2599 error_message) | |
| 2600 else: | |
| 2601 error(line_number, 'build/include_order', 4, | |
| 2602 '%s Should be: primary header, blank line, and then alphabetic ally sorted.' % | |
| 2603 error_message) | |
| 2604 | |
| 2605 | 2575 |
| 2606 def check_language(filename, clean_lines, line_number, file_extension, include_s tate, | 2576 def check_language(filename, clean_lines, line_number, file_extension, include_s tate, |
| 2607 file_state, error): | 2577 file_state, error): |
| 2608 """Checks rules from the 'C++ language rules' section of cppguide.html. | 2578 """Checks rules from the 'C++ language rules' section of cppguide.html. |
| 2609 | 2579 |
| 2610 Some of these rules are hard to test (function overloading, using | 2580 Some of these rules are hard to test (function overloading, using |
| 2611 uint32 inappropriately), but we do the best we can. | 2581 uint32 inappropriately), but we do the best we can. |
| 2612 | 2582 |
| 2613 Args: | 2583 Args: |
| 2614 filename: The name of the current file. | 2584 filename: The name of the current file. |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3583 | 3553 |
| 3584 def check(self, lines): | 3554 def check(self, lines): |
| 3585 _process_lines(self.file_path, self.file_extension, lines, | 3555 _process_lines(self.file_path, self.file_extension, lines, |
| 3586 self.handle_style_error, self.min_confidence) | 3556 self.handle_style_error, self.min_confidence) |
| 3587 | 3557 |
| 3588 | 3558 |
| 3589 # FIXME: Remove this function (requires refactoring unit tests). | 3559 # FIXME: Remove this function (requires refactoring unit tests). |
| 3590 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None): | 3560 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None): |
| 3591 checker = CppChecker(filename, file_extension, error, min_confidence, fs) | 3561 checker = CppChecker(filename, file_extension, error, min_confidence, fs) |
| 3592 checker.check(lines) | 3562 checker.check(lines) |
| OLD | NEW |