@@ -1619,8 +1619,7 @@ def Check(self, error, filename, linenum):
1619
1619
if self .lines_in_function > trigger :
1620
1620
error_level = int (math .log2 (self .lines_in_function / base_trigger ))
1621
1621
# 50 => 0, 100 => 1, 200 => 2, 400 => 3, 800 => 4, 1600 => 5, ...
1622
- if error_level > 5 :
1623
- error_level = 5
1622
+ error_level = min (error_level , 5 )
1624
1623
error (filename , linenum , 'readability/fn_size' , error_level ,
1625
1624
'Small and focused functions are preferred:'
1626
1625
f' { self .current_function } has { self .lines_in_function } non-comment lines'
@@ -1758,8 +1757,8 @@ def _ShouldPrintError(category, confidence, filename, linenum):
1758
1757
for one_filter in _Filters ():
1759
1758
filter_cat , filter_file , filter_line = _ParseFilterSelector (one_filter [1 :])
1760
1759
category_match = category .startswith (filter_cat )
1761
- file_match = filter_file == "" or filter_file == filename
1762
- line_match = filter_line == linenum or filter_line == - 1
1760
+ file_match = filter_file in ( "" , filename )
1761
+ line_match = filter_line in ( linenum , - 1 )
1763
1762
1764
1763
if one_filter .startswith ('-' ):
1765
1764
if category_match and file_match and line_match :
@@ -3343,7 +3342,7 @@ def Update(self, filename, clean_lines, linenum, error):
3343
3342
if _MATCH_ASM .match (line ):
3344
3343
self .stack [- 1 ].inline_asm = _BLOCK_ASM
3345
3344
3346
- elif token == ';' or token == ')' :
3345
+ elif token in { ';' , ')' } :
3347
3346
# If we haven't seen an opening brace yet, but we already saw
3348
3347
# a semicolon, this is probably a forward declaration. Pop
3349
3348
# the stack for these.
@@ -3673,8 +3672,7 @@ def CheckForFunctionLengths(filename, clean_lines, linenum,
3673
3672
# If the name is all caps and underscores, figure it's a macro and
3674
3673
# ignore it, unless it's TEST or TEST_F.
3675
3674
function_name = match_result .group (1 ).split ()[- 1 ]
3676
- if function_name == 'TEST' or function_name == 'TEST_F' or (
3677
- not re .match (r'[A-Z_]+$' , function_name )):
3675
+ if function_name in {'TEST' , 'TEST_F' } or not re .match (r'[A-Z_]+$' , function_name ):
3678
3676
starting_func = True
3679
3677
3680
3678
if starting_func :
@@ -3752,7 +3750,7 @@ def CheckComment(line, filename, linenum, next_line_start, error):
3752
3750
middle_whitespace = match .group (3 )
3753
3751
# Comparisons made explicit for correctness
3754
3752
# -- pylint: disable=g-explicit-bool-comparison
3755
- if middle_whitespace != ' ' and middle_whitespace != '' :
3753
+ if middle_whitespace not in { ' ' , '' } :
3756
3754
error (filename , linenum , 'whitespace/todo' , 2 ,
3757
3755
'TODO(my_username) should be followed by a space' )
3758
3756
@@ -4972,7 +4970,7 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
4972
4970
# (of lines ending in double quotes, commas, equals, or angle brackets)
4973
4971
# because the rules for how to indent those are non-trivial.
4974
4972
if (not re .search (r'[",=><] *$' , prev ) and
4975
- (initial_spaces == 1 or initial_spaces == 3 ) and
4973
+ (initial_spaces in { 1 , 3 } ) and
4976
4974
not re .match (scope_or_label_pattern , cleansed_line ) and
4977
4975
not (clean_lines .raw_lines [linenum ] != line and
4978
4976
re .match (r'^\s*""' , line ))):
@@ -5137,8 +5135,7 @@ def _ClassifyInclude(fileinfo, include, used_angle_brackets, include_order="defa
5137
5135
target_dir_pub = os .path .normpath (target_dir + '/../public' )
5138
5136
target_dir_pub = target_dir_pub .replace ('\\ ' , '/' )
5139
5137
if target_base == include_base and (
5140
- include_dir == target_dir or
5141
- include_dir == target_dir_pub ):
5138
+ include_dir in (target_dir , target_dir_pub )):
5142
5139
return _LIKELY_MY_HEADER
5143
5140
5144
5141
# If the target and include share some initial basename
@@ -6819,7 +6816,7 @@ def ParseArguments(args):
6819
6816
output_format = val
6820
6817
elif opt == '--quiet' :
6821
6818
quiet = True
6822
- elif opt == '--verbose' or opt == '--v' :
6819
+ elif opt in { '--verbose' , '--v' } :
6823
6820
verbosity = int (val )
6824
6821
elif opt == '--filter' :
6825
6822
filters = val
0 commit comments