1
1
#
2
- # Copyright (c) 2006-2023 , RT-Thread Development Team
2
+ # Copyright (c) 2006-2022 , RT-Thread Development Team
3
3
#
4
4
# SPDX-License-Identifier: Apache-2.0
5
5
#
16
16
import chardet
17
17
import logging
18
18
import datetime
19
- import subprocess
20
19
21
20
def init_logger ():
22
21
log_format = "[%(filename)s %(lineno)d %(levelname)s] %(message)s "
@@ -221,21 +220,6 @@ def check(self):
221
220
222
221
return check_result
223
222
224
- class CPPCheck :
225
- def __init__ (self , file_list ):
226
- self .file_list = file_list
227
-
228
- def check (self ):
229
- file_list_filtered = [file for file in self .file_list if file .endswith (('.c' , '.cpp' , '.cc' , '.cxx' ))]
230
- logging .info ("Start to static code analysis." )
231
- check_result = True
232
- for file in file_list_filtered :
233
- result = subprocess .run (['cppcheck' , '--enable=warning' , 'performance' , 'portability' , '--inline-suppr' , '--error-exitcode=1' , '--force' , file ], stdout = subprocess .PIPE , stderr = subprocess .PIPE )
234
- logging .info (result .stdout .decode ())
235
- logging .info (result .stderr .decode ())
236
- if result .stderr :
237
- check_result = False
238
- return check_result
239
223
240
224
@click .group ()
241
225
@click .pass_context
@@ -266,7 +250,7 @@ def cli(ctx):
266
250
)
267
251
def check (check_license , repo , branch ):
268
252
"""
269
- check files license, format and static code analysis(cppcheck) .
253
+ check files license and format .
270
254
"""
271
255
init_logger ()
272
256
# get modified files list
@@ -279,15 +263,13 @@ def check(check_license, repo, branch):
279
263
# check modified files format
280
264
format_check = FormatCheck (file_list )
281
265
format_check_result = format_check .check ()
282
- cpp_check = CPPCheck (file_list )
283
- cpp_check_result = cpp_check .check ()
284
266
license_check_result = True
285
267
if check_license :
286
268
license_check = LicenseCheck (file_list )
287
269
license_check_result = license_check .check ()
288
270
289
- if not format_check_result or not cpp_check_result or not license_check_result :
290
- logging .error ("file format check or license check or static code analysis(cppcheck) fail." )
271
+ if not format_check_result or not license_check_result :
272
+ logging .error ("file format check or license check fail." )
291
273
sys .exit (1 )
292
274
logging .info ("check success." )
293
275
sys .exit (0 )
0 commit comments