Checks for improper use of DISALLOW* macros. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. nesting_state: A NestingState instance which maintains information about
(filename, clean_lines, linenum, nesting_state, error)
| 2967 | |
| 2968 | |
| 2969 | def CheckAccess(filename, clean_lines, linenum, nesting_state, error): |
| 2970 | """Checks for improper use of DISALLOW* macros. |
| 2971 | |
| 2972 | Args: |
| 2973 | filename: The name of the current file. |
| 2974 | clean_lines: A CleansedLines instance containing the file. |
| 2975 | linenum: The number of the line to check. |
| 2976 | nesting_state: A NestingState instance which maintains information about |
| 2977 | the current stack of nested blocks being parsed. |
| 2978 | error: The function to call with any errors found. |
| 2979 | """ |
| 2980 | line = clean_lines.elided[linenum] # get rid of comments and strings |
| 2981 | |
| 2982 | matched = Match((r'\s*(DISALLOW_COPY_AND_ASSIGN|' |
| 2983 | r'DISALLOW_IMPLICIT_CONSTRUCTORS)'), line) |
| 2984 | if not matched: |
| 2985 | return |
| 2986 | if nesting_state.stack and isinstance(nesting_state.stack[-1], _ClassInfo): |
| 2987 | if nesting_state.stack[-1].access != 'private': |
| 2988 | error(filename, linenum, 'readability/constructors', 3, |
| 2989 | '%s must be in the private: section' % matched.group(1)) |
| 2990 | |
| 2991 | else: |
| 2992 | # Found DISALLOW* macro outside a class declaration, or perhaps it |
| 2993 | # was used inside a function when it should have been part of the |
| 2994 | # class declaration. We could issue a warning here, but it |
| 2995 | # probably resulted in a compiler error already. |
| 2996 | pass |
| 2997 | |
| 2998 | |
| 2999 | def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): |
no test coverage detected