diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ee2f344..2b395ef 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,3 +26,7 @@ jobs: - name: Run NSIQCppStyle RULES tests timeout-minutes: 5 run: PYTHONPATH=./:./rules python -m unittest discover -s rules -p "*.py" + + - name: Run NSIQCppStyle App tests + timeout-minutes: 5 + run: python nsiqcppstyle_exe.py -f nsiqunittest/rules/comment_and_empty_lines.txt --ci nsiqunittest/src/simple_main.cpp diff --git a/nsiqcppstyle_exe.py b/nsiqcppstyle_exe.py index 102b2a0..0741889 100755 --- a/nsiqcppstyle_exe.py +++ b/nsiqcppstyle_exe.py @@ -374,7 +374,7 @@ def _ProcessFilterLine(self, filter, raw_line): if line.startswith("#") or len(line) == 0: # Comment or empty line, just return - return None + return filter if line.startswith("*"): if len(line[1:].strip()) != 0: filterName = line[1:].strip() @@ -567,6 +567,9 @@ def AddVarMap(self, keyValuePairString, where): def GetCliKeyValueMap(kvList): + if kvList == None: + return {} + varMap = {} for kv in kvList: kvPair = kv.split(":", 1) @@ -575,6 +578,7 @@ def GetCliKeyValueMap(kvList): f"Error!: No key found in {kv}. Please use KEY:VALUE style to provide key and value", ) varMap[kvPair[0]] = kvPair[1] + return varMap diff --git a/nsiqcppstyle_util.py b/nsiqcppstyle_util.py index 2a584b3..9553b28 100644 --- a/nsiqcppstyle_util.py +++ b/nsiqcppstyle_util.py @@ -66,6 +66,10 @@ def CmpObjects(a, b): def RemoveOuterQuotes(raw_string): final_string = raw_string.strip() - if final_string[0] == final_string[-1] and final_string[0] in [SINGLE_QUOTE, DOUBLE_QUOTE]: + if ( + len(final_string) >= 2 + and final_string[0] == final_string[-1] + and final_string[0] in [SINGLE_QUOTE, DOUBLE_QUOTE] + ): final_string = final_string[1:-1].strip() return final_string diff --git a/nsiqunittest/rules/comment_and_empty_lines.txt b/nsiqunittest/rules/comment_and_empty_lines.txt new file mode 100644 index 0000000..d8930b8 --- /dev/null +++ b/nsiqunittest/rules/comment_and_empty_lines.txt @@ -0,0 +1,11 @@ +# This filefilter is here to ensure that the app: +# - handles comments properly +# - handles empty lines correctly + +~ RULE_3_1_A_do_not_start_filename_with_underbar +~ RULE_3_3_A_start_function_name_with_lowercase_unix +~ RULE_3_3_B_start_private_function_name_with_underbar +~ RULE_4_5_B_use_braces_even_for_one_statement +~ RULE_7_2_B_do_not_use_goto_statement +~ RULE_9_1_A_do_not_use_hardcorded_include_path +~ RULE_9_2_D_use_reentrant_function diff --git a/nsiqunittest/src/simple_main.cpp b/nsiqunittest/src/simple_main.cpp new file mode 100644 index 0000000..c9b4d4d --- /dev/null +++ b/nsiqunittest/src/simple_main.cpp @@ -0,0 +1,4 @@ +int main(int argc, char* argv[]) +{ + return 1; +}