florianschanda / miss_hit

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

support octave != and ! operators #232

Closed Remi-Gau closed 2 years ago

Remi-Gau commented 2 years ago

What kind of feature is this?

MISS_HIT is behaving as it should but I wonder if there should a way to ignore octave-kernel files

Your MATLAB/Octave environment

Using the octave kernel for jupyter notebook in virtual environment installed in the same folder as my project.

├── binder
├── notebooks
├── src
├── tests
├── demos
├── docs
├── env
├── miss_hit.cfg
├── lib
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
├── requirements.txt
└── version.txt
env/lib/python3.8/site-packages/octave_kernel

Relevant part of my requirements.txt:

jupyterlab
octave_kernel

MISS_HIT component affected

More or less all of them?

Here is an example for mh_style.

╰─(env) ⠠⠵ mh_style
In env/lib/python3.8/site-packages/octave_kernel/_make_figures.m, line 1
| function _make_figures(plot_dir, fmt, name, wid, hgt, res, start_ind)
|          ^ lex error: unexpected character '_'

Describe the solution you'd like

I can try to do this locally in the config:

exclude_dir: "env"

But this leads to failure in CI or on my colleagues machine, if they have no virtual env set up or if they named it differently.

I could try to set up a config in the env folder with enable: false but this might then require me to do that every time there I use the octave kernel in a project.

Would there be a smart way to ignore this systematically or to not throw an error if the excluded directory does not exist?

florianschanda commented 2 years ago

Could you try using

octave: true

In the config file for that directory? I think the starting-with-underscore things should be supported already

florianschanda commented 2 years ago

Also, I really want to support more Octave, so of there is anything missing / inconvenient please let me know

Remi-Gau commented 2 years ago

So this allows miss_hit to deal with some of the files in there.

mh_lint reports this, though I think they are valid Octave files.

╰─(env) ⠠⠵ mh_lint
In lib/python3.8/site-packages/octave_kernel/_make_figures.m, line 59
|   if (length(get(h, 'children')) != 1)
|                                  ^^^^^ error: expected KET, found BANG instead
In lib/python3.8/site-packages/octave_kernel/@pause/pause.m, line 26
|         if (!ispc())
|             ^^^^^^^^ error: expected IDENTIFIER, found BANG instead
In lib/python3.8/site-packages/octave_kernel/@sleep/sleep.m, line 13
|         if (!ispc())
|             ^^^^^^^^ error: expected IDENTIFIER, found BANG instead
In lib/python3.8/site-packages/octave_kernel/@usleep/usleep.m, line 17
|         if (!ispc())
|             ^^^^^^^^ error: expected IDENTIFIER, found BANG instead
MISS_HIT Lint Summary: 7 file(s) analysed, 4 error(s)

I think that for now I will just manually add an "enable: false" in my env folder because I don't want miss hit to go and lint installed packages.

florianschanda commented 2 years ago

Ah, yes. Octave has some extra operators that I need to support.

I'll rename this ticket to support at the very least these; which I think is better than enable: false

florianschanda commented 2 years ago

This is now fixed correctly. I've checked out https://github.com/Calysto/octave_kernel and ran mh_lint --octave and get no errors or warnings.

You should be able to remove your workaround now.

Remi-Gau commented 2 years ago

Awesome !