-
Notifications
You must be signed in to change notification settings - Fork 303
Add build/namespaces_names error #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -307,6 +307,7 @@ | |||||||||||||
| 'build/include_what_you_use', | ||||||||||||||
| 'build/namespaces_headers', | ||||||||||||||
| 'build/namespaces_literals', | ||||||||||||||
| 'build/namespaces_names', | ||||||||||||||
| 'build/namespaces', | ||||||||||||||
| 'build/printf_format', | ||||||||||||||
| 'build/storage_class', | ||||||||||||||
|
|
@@ -5484,6 +5485,19 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, | |||||||||||||
| 'https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces' | ||||||||||||||
| ' for more information.') | ||||||||||||||
|
|
||||||||||||||
| # Check namespace names for correct naming, according to | ||||||||||||||
| # https://google.github.io/styleguide/cppguide.html#Namespace_Names | ||||||||||||||
| # namespace names are "all lower-case, with words separated by underscores" | ||||||||||||||
| match = re.match(r'.*namespace\s+([^{=;]+)\s+[{;=]', line) | ||||||||||||||
| if match: | ||||||||||||||
| name = match.group(1) | ||||||||||||||
| if name != "" and not re.match(r'^((inline )?[a-z_]+(::)?)+$', name): | ||||||||||||||
| error(filename, linenum, 'build/namespaces_names', 4, | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This is decidedly not a building issue. This entire check is also not suited for the language rules−checking function. (I recommend you move this to a new function, which should also solve the lint errors. |
||||||||||||||
| 'Namespace names must be all lower-case, with words separated ' | ||||||||||||||
| 'by underscores. See ' | ||||||||||||||
| 'https://google.github.io/styleguide/cppguide.html#Namespace_Names' | ||||||||||||||
| ' for more information.') | ||||||||||||||
|
Comment on lines
+5496
to
+5499
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We never link to the style guide if it's pretty obvious, and there's a comma splice here. |
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| def CheckGlobalStatic(filename, clean_lines, linenum, error): | ||||||||||||||
| """Check for unsafe global or static objects. | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4578,6 +4578,34 @@ def testUnnamedNamespacesInNonHeaders(self): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.TestLanguageRulesCheck('foo.' + extension, 'namespace {', '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.TestLanguageRulesCheck('foo.' + extension, 'namespace foo {', '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def testNamespaceNames(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for extension in ['h', 'hpp', 'hxx', 'h++', 'cuh']: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.TestLanguageRulesCheck( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'foo.' + extension, 'namespace CamelCase {}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Namespace names must be all lower-case, with words separated by underscores. ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'See https://google.github.io/styleguide/cppguide.html#Namespace_Names ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'for more information. [build/namespaces_names] [4]') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.TestLanguageRulesCheck( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'foo.' + extension, 'inline namespace Uppercase {', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Namespace names must be all lower-case, with words separated by underscores. ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'See https://google.github.io/styleguide/cppguide.html#Namespace_Names ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'for more information. [build/namespaces_names] [4]') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.TestLanguageRulesCheck( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'foo.' + extension, 'namespace Uppercase = std', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Namespace names must be all lower-case, with words separated by underscores. ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'See https://google.github.io/styleguide/cppguide.html#Namespace_Names ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'for more information. [build/namespaces_names] [4]') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.TestLanguageRulesCheck( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'foo.' + extension, 'namespace a::inline b::inline C {', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Namespace names must be all lower-case, with words separated by underscores. ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'See https://google.github.io/styleguide/cppguide.html#Namespace_Names ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'for more information. [build/namespaces_names] [4]') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4584
to
+4602
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Ditto |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.TestLanguageRulesCheck('foo.' + extension, 'namespace lower_case {}', '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.TestLanguageRulesCheck('foo.' + extension, 'namespace a::b::c {}', '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.TestLanguageRulesCheck('foo.' + extension, 'namespace a::b::inline c {}', '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.TestLanguageRulesCheck('foo.' + extension, 'namespace lower_case = Uppercase', '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.TestLanguageRulesCheck('foo.' + extension, 'inline namespace a::inline b {}}', '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def testBuildClass(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Test that the linter can parse to the end of class definitions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # and that it will report when it can't. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,8 +2,9 @@ src/* | |||||
| 1 | ||||||
| 3 | ||||||
| Done processing src/interface-descriptors.h | ||||||
| Total errors found: 2 | ||||||
| Total errors found: 3 | ||||||
|
|
||||||
| src/interface-descriptors.h:5: #ifndef header guard has wrong style, please use: SAMPLES_V8_SAMPLE_SRC_INTERFACE_DESCRIPTORS_H_ [build/header_guard] [5] | ||||||
| src/interface-descriptors.h:1255: #endif line should be "#endif // SAMPLES_V8_SAMPLE_SRC_INTERFACE_DESCRIPTORS_H_" [build/header_guard] [5] | ||||||
| src/interface-descriptors.h:15: Namespace names must be all lower-case, with words separated by underscores. See https://google.github.io/styleguide/cppguide.html#Namespace_Names for more information. [build/namespaces_names] [4] | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be much better if the detection was based on nesting_state. The could changed by #235 should provide an example.