florianschanda / miss_hit

MATLAB Independent, Small & Safe, High Integrity Tools - code formatter and more
GNU General Public License v3.0
160 stars 21 forks source link

incorrect style violation #222

Closed jand271 closed 3 years ago

jand271 commented 3 years ago

MISS_HIT Component affected Please choose one from:

Your operating system and Python version

Describe the bug A function with an ignored input (e.g., to pass matlab's code checker) yields a style violation. A function parameter ~ should be ok.

For instance

function output = method(~)
output = 0
end

mh output

|         function method(~)
|                            ^ style: violates naming scheme for parameter
jand271 commented 3 years ago

It also appears I cannot suppress the rule with supresss_rule: "naming_parameters" in my miss_hit.cfg

florianschanda commented 3 years ago

I think this is an oversight on my side: ~ should be exempt from name checking. I will fix it.

florianschanda commented 3 years ago

This is now fixed, thanks again for the report. I will make a special bugfix release just for this issue.

jand271 commented 3 years ago

This is my miss_hit.cfg

project_root
suppress_rule: "copyright_notice"
suppress_rule: "naming_classes"
suppress_rule: "naming_functions"
suppress_rule: "naming_scripts"
supresss_rule: "naming_parameters"
line_length: 120

Which yields the following results.

$ mh_style --fix 
miss_hit.cfg: error: config file contains errors
In miss_hit.cfg, line 6
| supresss_rule: "naming_parameters"
| ^^^^^^^^^^^^^ error: expected valid style configuration name
.: error: cannot find project root because the config file contains errors: please add a config file with the 'project_root' directive
MISS_HIT Style Summary: 2 file(s) analysed, 3 error(s)

Am I missing something obvious? Why can't I suppress the rule? thanks

florianschanda commented 3 years ago

Yes :) You have:

supresss_rule: "naming_parameters"

Notice the spelling of suppress

The error message is not mega helpful, but I will try to find a good place in the config parser to improve it.

jand271 commented 3 years ago

oof...that's embarrassing lol. Thanks!!

florianschanda commented 3 years ago

The next version will have an improved error message:

In miss_hit.cfg, line 6
| supresss_rule: "naming_parameters"
| ^^^^^^^^^^^^^ error: expected valid style configuration name (did you mean suppress_rule?)