1- # Copyright 2014-2024 the openage authors. See copying.md for legal info.
1+ # Copyright 2014-2025 the openage authors. See copying.md for legal info.
22
33"""
44Entry point for the code compliance checker.
@@ -18,16 +18,24 @@ def parse_args():
1818 """ Returns the raw argument namespace. """
1919
2020 cli = argparse .ArgumentParser ()
21- cli .add_argument ("--fast" , action = "store_true" ,
22- help = "do all checks that can be performed quickly" )
23- cli .add_argument ("--all" , action = "store_true" ,
24- help = "do all checks, even the really slow ones" )
21+ check_types = cli .add_mutually_exclusive_group ()
22+ check_types .add_argument ("--fast" , action = "store_true" ,
23+ help = "do all checks that can be performed quickly" )
24+ check_types .add_argument ("--merge" , action = "store_true" ,
25+ help = "do all checks that are required before merges to master" )
26+ check_types .add_argument ("--all" , action = "store_true" ,
27+ help = "do all checks, even the really slow ones" )
28+
2529 cli .add_argument ("--only-changed-files" , metavar = 'GITREF' ,
2630 help = ("slow checks are only done on files that have "
2731 "changed since GITREF." ))
2832 cli .add_argument ("--authors" , action = "store_true" ,
2933 help = ("check whether all git authors are in copying.md. "
3034 "repo must be a git repository." ))
35+ cli .add_argument ("--clang-tidy" , action = "store_true" ,
36+ help = ("Check the C++ code with clang-tidy. Make sure you have build the "
37+ "project with ./configure --clang-tidy or have set "
38+ "CMAKE_CXX_CLANG_TIDY for your CMake build." ))
3139 cli .add_argument ("--cppstyle" , action = "store_true" ,
3240 help = "check the cpp code style" )
3341 cli .add_argument ("--cython" , action = "store_true" ,
@@ -57,8 +65,6 @@ def parse_args():
5765 help = "increase program verbosity" )
5866 cli .add_argument ("-q" , "--quiet" , action = "count" , default = 0 ,
5967 help = "decrease program verbosity" )
60- cli .add_argument ("--clangtidy" , action = "store_true" ,
61- help = "Check the C++ code with clang-tidy." )
6268
6369 args = cli .parse_args ()
6470 process_args (args , cli .error )
@@ -78,7 +84,7 @@ def process_args(args, error):
7884 # set up log level
7985 log_setup (args .verbose - args .quiet )
8086
81- if args .fast or args .all :
87+ if args .fast or args .merge or args . all :
8288 # enable "fast" tests
8389 args .authors = True
8490 args .cppstyle = True
@@ -88,17 +94,19 @@ def process_args(args, error):
8894 args .filemodes = True
8995 args .textfiles = True
9096
91- if args .all :
92- # enable tests that take a bit longer
93-
97+ if args .merge or args .all :
98+ # enable tests that are required before merging to master
9499 args .pystyle = True
95100 args .pylint = True
96101 args .test_git_change_years = True
97- args .clangtidy = True
102+
103+ if args .all :
104+ # enable tests that take a bit longer
105+ args .clang_tidy = True
98106
99107 if not any ((args .headerguards , args .legal , args .authors , args .pystyle ,
100108 args .cppstyle , args .cython , args .test_git_change_years ,
101- args .pylint , args .filemodes , args .textfiles , args .clangtidy )):
109+ args .pylint , args .filemodes , args .textfiles , args .clang_tidy )):
102110 error ("no checks were specified" )
103111
104112 has_git = bool (shutil .which ('git' ))
@@ -130,7 +138,8 @@ def process_args(args, error):
130138 if args .pylint :
131139 if not importlib .util .find_spec ('pylint' ):
132140 error ("pylint python module required for linting" )
133- if args .clangtidy :
141+
142+ if args .clang_tidy :
134143 if not shutil .which ('clang-tidy' ):
135144 error ("--clang-tidy requires clang-tidy to be installed" )
136145
@@ -270,7 +279,7 @@ def find_all_issues(args, check_files=None):
270279 from .modes import find_issues
271280 yield from find_issues (check_files , ('openage' , 'buildsystem' ,
272281 'libopenage' , 'etc/gdb_pretty' ))
273- if args .clangtidy :
282+ if args .clang_tidy :
274283 from .clangtidy import find_issues
275284 yield from find_issues (check_files , ('libopenage' , ))
276285
0 commit comments