From 552867d99bd59a6d877ee40d711e2ab555eadb2f Mon Sep 17 00:00:00 2001 From: Mykola Yurchenko Date: Sun, 14 Apr 2019 00:02:36 -0400 Subject: [PATCH] Adjust CI Linter Check Parameters (#99) - Change line limit to 120 chars - Add linting of .cpp and .h files - Fix minor style issues from the linter adjustment Commit log: * Enfore 120 line length in linter * Change default linelen * Fix some line length changes * Style fix * Add lint for cpp .h files --- CPPLINT.cfg | 2 +- ci/helper-functions.sh | 2 +- examples/speed_tester/speed_tester.c | 3 ++- onvm/onvm_mgr/main.c | 3 ++- style/gwclint.py | 6 +++--- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CPPLINT.cfg b/CPPLINT.cfg index 41265bb6e..36c3851ea 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -1 +1 @@ -linelength=100 +linelength=120 diff --git a/ci/helper-functions.sh b/ci/helper-functions.sh index 0d2039aa1..2e7d63484 100644 --- a/ci/helper-functions.sh +++ b/ci/helper-functions.sh @@ -99,7 +99,7 @@ check_exit_code(){ # runs the linter run_linter() { - for fn in $(git ls-files *.c | grep -v "cJSON" | grep -v "ndpi"); do + for fn in $(git ls-files *.c *.cpp *.h | grep -v "cJSON" | grep -v "ndpi"); do python style/gwclint.py --verbose=5 $fn 2>&1 | grep -v "Done" | grep -v "Total errors found: 0" >> $1 done } diff --git a/examples/speed_tester/speed_tester.c b/examples/speed_tester/speed_tester.c index 0291afeac..390c5a77c 100644 --- a/examples/speed_tester/speed_tester.c +++ b/examples/speed_tester/speed_tester.c @@ -361,7 +361,8 @@ run_advanced_rings(struct onvm_nf_info *nf_info) { printf("Time to live exceeded, shutting down\n"); keep_running = 0; } - if (nf_info->pkt_limit && unlikely(nf->stats.rx >= (uint64_t) nf_info->pkt_limit * PKT_TTL_MULTIPLIER)) { + if (nf_info->pkt_limit && unlikely(nf->stats.rx >= + (uint64_t) nf_info->pkt_limit * PKT_TTL_MULTIPLIER)) { printf("Packet limit exceeded, shutting down\n"); keep_running = 0; } diff --git a/onvm/onvm_mgr/main.c b/onvm/onvm_mgr/main.c index 0c5f715f6..b3464eada 100644 --- a/onvm/onvm_mgr/main.c +++ b/onvm/onvm_mgr/main.c @@ -106,7 +106,8 @@ master_thread_main(void) { if (stats_destination != ONVM_STATS_NONE) onvm_stats_display_all(sleeptime, verbosity_level); - if (time_to_live && unlikely((rte_get_tsc_cycles() - start_time) * TIME_TTL_MULTIPLIER / rte_get_timer_hz() >= time_to_live)) { + if (time_to_live && unlikely((rte_get_tsc_cycles() - start_time) * TIME_TTL_MULTIPLIER / + rte_get_timer_hz() >= time_to_live)) { printf("Time to live exceeded, shutting down\n"); main_keep_running = 0; } diff --git a/style/gwclint.py b/style/gwclint.py index 9d24e7303..a968bb817 100644 --- a/style/gwclint.py +++ b/style/gwclint.py @@ -124,7 +124,7 @@ linelength=digits This is the allowed line length for the project. The default value is - 80 characters. + 120 characters. Examples: --linelength=120 @@ -496,7 +496,7 @@ # The allowed line length of files. # This is set by --linelength flag. -_line_length = 80 +_line_length = 120 # The allowed extensions for file names # This is set by --extensions flag. @@ -4455,7 +4455,7 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, 'Lines should very rarely be longer than %i characters' % extended_length) elif line_width > _line_length: - error(filename, linenum, 'whitespace/line_length', 2, + error(filename, linenum, 'whitespace/line_length', 5, 'Lines should be <= %i characters long' % _line_length) if (cleansed_line.count(';') > 1 and