cpp-lln-lab / CPP_PTB

a set of function to make it easier to create behavioral, EEG, fMRI experiment with psychtoolbox
https://cpp-ptb.readthedocs.io/en/latest/index.html#
MIT License
12 stars 13 forks source link

apply miss_hit linter #33

Closed Remi-Gau closed 3 years ago

Remi-Gau commented 3 years ago

@marcobarilari you were asking for some styling tool that would help you know where to put spaces and so on.

This PR is the results of just typing this in the command line. Many of things this linter is not happy with are automatically fixed. Others throw a warning.

mh_style.py . --fix

From this project: https://florianschanda.github.io/miss_hit/style_checker.html

The main difference vizually is that it indents the functions by default, but the matlab editor can do that too if you set it up that way.

I am tempted to start adding this linter to our matlab projects so we don't have to think about formating.

@CerenB @marcobarilari What do you think?

marcobarilari commented 3 years ago

Can I apply it to real life? From a quick view, it looks fantastic. I'll go deeper later but first question a stupid question, can I ask it what changes I would like to do/don't apply?

I see it is placing the ; no matter what, in some cases might be useless and matlab would complain

Remi-Gau commented 3 years ago

Can I apply it to real life? From a quick view, it looks fantastic. I'll go deeper later but first question a stupid question, can I ask it what changes I would like to do/don't apply?

It will only fix things automatically if you pass the --fix argument.

I see it is placing the ; no matter what, in some cases might be useless and matlab would complain

You can tweak the rules by creating a miss_hit.cfg config file.

The one i have created contains this to limit the amount of warnings and also capture our camelCase rule for the function names. It cannot check variable names (yet?).

line_length: 100
regex_function_name: "[a-z]+(([A-Z]|[0-9]){1}[a-z]+)*"
suppress_rule: "copyright_notice"

if you want to prevent the auto-fix of semi-colons then add: suppress_rule: end_of_statements

Remi-Gau commented 3 years ago

Unless I hear screams of outrage I will make Miss_Hit the official linter tool for this repo in 24 hours.

Will try to see if I can add to the Travis continuous integration so we get it checked automatically when we open a PR and push.