Skip to content

Spot some issues with elvis.config (non-existing modules, non-existing rules) #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bormilan
Copy link
Collaborator

Description

I made a little refactor on the elvis_config:validate using maybe. Feel free to roast it; I'm still experiencing this feature and its capabilities.

I skipped the validation of the rule configs in this step. (Should I implement it too, or is it okay to leave it for later?)

Now this solution can:
- spot if a non-existent module was given in the elvis.config
- spot is a nonexistent rule(for an existing module) was given in the elvis.config
- spot any other issues that were implemented in the past

I have a test that I commented out because I'm not sure what it was intended to test 😅 (I marked it in the files)
I see that it skips to load a module called user_defined_rules, but I'm not sure whether I need to keep this test or change it to expect my new error message.

Also, I want to add more tests, so feel free to suggest some if you have some cases.

Closes #389;.

@bormilan
Copy link
Collaborator Author

I'm planning on adding:
- spot non-existent rulesets
- spot invalid rule config
- spot non-existent dirs
- spot non-existent filter

I don't know whether I should do all in this PR or cut it into smaller tasks

@paulo-ferraz-oliveira
Copy link
Collaborator

paulo-ferraz-oliveira commented Apr 25, 2025

I made a little refactor on the elvis_config:validate using maybe. Feel free to roast it; I'm still experiencing this feature and its capabilities.

I think it's Ok to keep, since it's now part of the language and inside our support scope, but I did leave a comment on maybe how to improve the current implementation's readability.

I skipped the validation of the rule configs in this step. (Should I implement it too, or is it okay to leave it for later?)

For me it's Ok to leave for later; just open a ticket 😄

I have a test that I commented out because I'm not sure what it was intended to test 😅 (I marked it in the files) I see that it skips to load a module called user_defined_rules, but I'm not sure whether I need to keep this test or change it to expect my new error message.

Yeah, I commented on this. I'd keep the test if it wasn't failing, and add a comment on its intention if you can find it in Git history. Just removing it (or commenting it out) while implementing a new feature seems odd.

I like the general direction, and have left a few comments.

Edit: I tweaked the PR title since it'll be used for the generated changelog. Feel free to re-tweak if we decide on changing scope.

@paulo-ferraz-oliveira paulo-ferraz-oliveira changed the title refactor(#389): Error handling at wrong rules in elvis.config Spot some issues with elvis.config (non-existing modules, non-existing rules) Apr 25, 2025
@bormilan
Copy link
Collaborator Author

Currently, I just don't know how to fix builds.

If I make a vm.args with the content of -enable-feature maybe_expr and run the ERL_FLAGS="-args_file config/vm.args" rebar3 test command, the build will run successfully.

But since it's a file path, in the Windows builds, I need to change it, so I need to find a way to change the CI a little bit to execute rebar commands with the proper ERL_FLAGS.

@elbrujohalcon
Copy link
Member

Yeah, @bormilan … I don't know what's the deal with ex_doc and maybe… but I would be super-pragmatic and… just don't run ex_doc in OTP25. Period. Even more, we can just not run ex_doc in anything lower than the latest version we use for CI (i.e. 27).

@elbrujohalcon elbrujohalcon added this to the 4.1.0 milestone May 20, 2025
@paulo-ferraz-oliveira
Copy link
Collaborator

@elbrujohalcon, should we flag old_configuration_format as deprecated in the scope of this change (or later, if you prefer to separate stuff)? We can also remove it while keeping the documentation for historical purposes...

@elbrujohalcon
Copy link
Member

elbrujohalcon commented May 21, 2025

@paulo-ferraz-oliveira yeah, let's remove it. But maybe outside this PR, just so this PR can be merged with the fix for CI pipelines :)

Copy link
Member

@elbrujohalcon elbrujohalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the PR is good as it is, but I left a tiny nit-picky comment for tests.
I also didn't check around to see what we usually use, but if we use pattern-matching everywhere instead of ct:fail/1,2, do ignore my comment.

elbrujohalcon added a commit that referenced this pull request May 21, 2025
* elbrujohalcon.293.single_maybe_clause- New Rule: No Single Match Maybe

* elbrujohalcon.293.single_maybe_clause- Fix doc path

* elbrujohalcon.293.single_maybe_clause- Fix doc path

* elbrujohalcon.293.single_maybe_clause- Fix macro

* elbrujohalcon.293.single_maybe_clause- add feature flag

* elbrujohalcon.293.single_maybe_clause- Adjust line numbers

* elbrujohalcon.293.single_maybe_clause- Update docs to the latest style trend ✨

* elbrujohalcon.293.single_maybe_clause- Manually cherry-pick changes from #397

* Revert task name change
@bormilan
Copy link
Collaborator Author

I'm planning on adding: - spot non-existent rulesets - spot invalid rule config - spot non-existent dirs - spot non-existent filter

I don't know whether I should do all in this PR or cut it into smaller tasks

I will open a ticket(or more) later in this week, or maybe a discussion first, about these.

@paulo-ferraz-oliveira
Copy link
Collaborator

@bormilan, you have merge rights, correct? If so, it feels like you can go ahead and merge this.

@elbrujohalcon
Copy link
Member

Well… now you have to resolve the conflicts, @bormilan … but after that go ahead and (if CI is green) merge the thing.

@bormilan bormilan force-pushed the 389-error-handling branch 7 times, most recently from 04da22e to 27a42db Compare May 23, 2025 11:17
@bormilan bormilan force-pushed the 389-error-handling branch from 27a42db to fd468bd Compare May 23, 2025 11:18
@bormilan
Copy link
Collaborator Author

It's strange that the test, verify_no_single_match_maybe, is failing for me locally.
I need to add the ERL_FLAG... to the command to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proper error handling at wrong rules in elvis.config
3 participants