miss_hit icon indicating copy to clipboard operation
miss_hit copied to clipboard

new rule: imports, globals and persistent before code

Open niklasnylen opened this issue 4 years ago • 2 comments

What kind of feature is this?

  • New feature in MISS_HIT

MISS_HIT component affected

  • Style checker

Describe the solution you'd like Global and persistent variables shall be declared first in functions.

niklasnylen avatar Feb 24 '20 09:02 niklasnylen

However they need to be after any argument validation blocks, so a function should be ordered like this:

  1. Argument validation blocks (only in matlab 2019b)
  2. imports
  3. global
  4. persistent
  5. function body
  6. nested functions

florianschanda avatar Feb 24 '20 11:02 florianschanda

@niklasnylen an update this ticket (and similar ones that would do code re-structuring beyond adding whitespace and deleting stuff).

I plan to create another tool mh_reformat that is a much more advanced code reformatting tool. It does not produce messages like mh_style; but instead just pretty prints code.

I suspect I will also remove the autofixing from mh_style once this works. In the future mh_style will only complain :)

The reason for this is largely technical / and developer (i.e. me) sanity. The code that does the fixing has become so complicated that adding new functionality is just not practical any more. :/

florianschanda avatar Dec 04 '20 07:12 florianschanda