- In general the config files follow a simply sytax:
+ In general the config files follow a simply syntax:
key: value The key is some identifier like
tab_width, and the value is the configuration for that
key. Integers are written directly, and strings are enclosed
@@ -581,6 +581,8 @@
Consistent semicolons ("end_of_statements")
effectively bans commas and requires semicolons + newline at
the end of most statements. The exceptions are things like
'return' or the end of compound statements such as 'if'.
+ Fixing missing semicolons can be disabled with
+ "no_fix_missing_semicolon".
diff --git a/make.ps1 b/make.ps1
new file mode 100644
index 0000000..22a5704
--- /dev/null
+++ b/make.ps1
@@ -0,0 +1,70 @@
+[CmdletBinding()]
+param (
+ [switch]$PreCommitChecks,
+ [switch]$Copyright,
+ [switch]$Doc,
+ [switch]$Test,
+ [switch]$Lint,
+ [switch]$Style
+)
+
+
+$AllParams =@($PreCommitChecks, $Copyright, $Doc, $Test, $Lint, $Style)
+
+if ($AllParams -notcontains $true) {
+ $Doc = $true
+ $Test = $true
+ $Lint = $true
+ $Style = $true
+}
+
+if ($Lint) {
+ $Style = $true
+}
+
+if ($PreCommitChecks) {
+ $Copyright = $true
+ $Doc = $true
+ $Test = $true
+ $Lint = $true
+}
+
+$ErrorActionPreference = "Stop"
+
+if ($Copyright) {
+ python hook_scripts\copyright_year.py
+}
+
+if ($Doc) {
+ Push-Location util
+ python update_docs.py
+ python update_versions.py
+ Pop-Location
+}
+
+if ($Test) {
+ Push-Location tests
+ python run.py
+ Pop-Location
+}
+
+if ($Style) {
+ python -m pycodestyle miss_hit_core miss_hit mh_bmc mh_copyright mh_debug_enumerate_simulink_blocks mh_debug_parser mh_diff mh_lint mh_metric mh_sl_unpack mh_style mh_trace
+}
+
+if ($Lint) {
+ python -m pylint --rcfile=pylint3.cfg --reports=no miss_hit_core miss_hit mh_bmc mh_copyright mh_debug_enumerate_simulink_blocks mh_debug_parser mh_diff mh_lint mh_metric mh_sl_unpack mh_style mh_trace
+}
+
+if ($Package) {
+ git clean -xdf
+ Copy-Item -Path setup_gpl.py -Destination setup.py
+ New-Item -Path "miss_hit_core/resources/assets" -ItemType Directory
+ Copy-Item -Path docs/style.css -Destination miss_hit_core/resources
+ Copy-Item -Path docs/assets/* -Destination miss_hit_core/resources/assets
+ python setup.py sdist bdist_wheel
+ Remove-Item -Path "miss_hit_core/resources" -Recurse
+ Copy-Item -Path setup_agpl.py -Destination setup.py
+ python setup.py sdist bdist_wheel
+ Remove-Item -Path setup.py
+}
diff --git a/miss_hit_core/config.py b/miss_hit_core/config.py
index 96669d5..143344c 100644
--- a/miss_hit_core/config.py
+++ b/miss_hit_core/config.py
@@ -356,6 +356,10 @@ class Function_Metric(Code_Metric):
"end_of_statements" : Style_Rule(
"Ensures consistent ending of statements."),
+ "no_fix_missing_semicolon" : Style_Rule(
+ "Allows statement to not end in a semicolon if"
+ " 'end_of_statements' is enabled."),
+
"builtin_shadow" : Style_Rule(
"Checks that assignments do not overwrite builtin functions such as"
" true, false, or pi."),
diff --git a/miss_hit_core/m_parser.py b/miss_hit_core/m_parser.py
index f13985f..0f6c3dc 100644
--- a/miss_hit_core/m_parser.py
+++ b/miss_hit_core/m_parser.py
@@ -439,11 +439,12 @@ def match_eos(self, n_ast, semi = "", allow_nothing = False):
else:
assert terminator_tokens[0].kind == "NEWLINE"
- self.mh.style_issue(ending_token.location,
- "end statement with a semicolon",
- "end_of_statements",
- True)
- ending_token.fix.add_semicolon_after = True
+ if not self.cfg.active("no_fix_missing_semicolon"):
+ self.mh.style_issue(ending_token.location,
+ "end statement with a semicolon",
+ "end_of_statements",
+ True)
+ ending_token.fix.add_semicolon_after = True
if first_newline is None:
fixed = False
diff --git a/tests/style/no_fix_missing_semicolon/expected_out.html b/tests/style/no_fix_missing_semicolon/expected_out.html
new file mode 100644
index 0000000..d87f825
--- /dev/null
+++ b/tests/style/no_fix_missing_semicolon/expected_out.html
@@ -0,0 +1,23 @@
+
+
+
+
+
+
MISS_HIT Report
+
+
+
+
+
+Issues identified
+
+test.m
+test.m: style: violates naming scheme for scripts
+
+
+
+
+
+
+
+
diff --git a/tests/style/no_fix_missing_semicolon/expected_out.txt b/tests/style/no_fix_missing_semicolon/expected_out.txt
new file mode 100644
index 0000000..773a4ee
--- /dev/null
+++ b/tests/style/no_fix_missing_semicolon/expected_out.txt
@@ -0,0 +1,18 @@
+=== PLAIN MODE ===
+test.m: style: violates naming scheme for scripts [naming_scripts]
+In test.m, line 5
+| baz = 4, bar = 5;
+| ^ style: end this with a semicolon instead of a comma [fixed] [end_of_statements]
+In test.m, line 5
+| baz = 4, bar = 5;
+| ^ style: end statement with a newline [fixed] [end_of_statements]
+In test.m, line 9
+| bas = 5, foo = 9
+| ^ style: end this with a semicolon instead of a comma [fixed] [end_of_statements]
+In test.m, line 9
+| bas = 5, foo = 9
+| ^ style: end statement with a newline [fixed] [end_of_statements]
+MISS_HIT Style Summary: 1 file(s) analysed, 5 style issue(s)
+
+=== HTML MODE ===
+MISS_HIT Style Summary: 1 file(s) analysed, 5 style issue(s)
diff --git a/tests/style/no_fix_missing_semicolon/miss_hit.cfg b/tests/style/no_fix_missing_semicolon/miss_hit.cfg
new file mode 100644
index 0000000..531042b
--- /dev/null
+++ b/tests/style/no_fix_missing_semicolon/miss_hit.cfg
@@ -0,0 +1 @@
+enable_rule: "no_fix_missing_semicolon"
diff --git a/tests/style/no_fix_missing_semicolon/test.m b/tests/style/no_fix_missing_semicolon/test.m
new file mode 100644
index 0000000..94c6d61
--- /dev/null
+++ b/tests/style/no_fix_missing_semicolon/test.m
@@ -0,0 +1,8 @@
+% (c) Copyright 2019 Zenuity AB
+
+% Should end in semicolons
+foo = 1;
+baz = 4, bar = 5;
+% foo and spoon should reamin without a semicolon
+spoon
+bas = 5, foo = 9
diff --git a/tests/style/no_fix_missing_semicolon/test.m_fixed b/tests/style/no_fix_missing_semicolon/test.m_fixed
new file mode 100644
index 0000000..d3b0228
--- /dev/null
+++ b/tests/style/no_fix_missing_semicolon/test.m_fixed
@@ -0,0 +1,10 @@
+% (c) Copyright 2019 Zenuity AB
+
+% Should end in semicolons
+foo = 1;
+baz = 4;
+bar = 5;
+% foo and spoon should reamin without a semicolon
+spoon
+bas = 5;
+foo = 9