Skip to content
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

refactor(linter-config): remove dead code and deduplicate code #612

Merged
merged 5 commits into from
Oct 27, 2023

Conversation

Conaclos
Copy link
Member

@Conaclos Conaclos commented Oct 26, 2023

Summary

This PR removes dead code and deduplicate code for linter configuration.
Several visitors were never called and thus outdated. This was the case of Hooks::visit_array_member and Hooks::visit_map.

There is room for improvement:

  • I am not sure why we use visitors here while we create the config.
    We create a default config, and so we visit the config to initialize it.
    This looks like an abuse of the visitor pattern?

  • Methods such map_to_* don't use self.
    We should remove self from their parameters, this could simplify mutation of self fields (because we cannot both call map_to_* and mutate a field of self by passing it as visitor to map_to_*).

  • Instead of relying on visit_member_name to validate field names, we could directly validate them in visit_map.
    We have to match against existing fields in visit_map, thus we can detect unknown field here. This saves one check.

However, I prefer to keep this PR focused on removing dead code and deduplicate code.

NOTE: A significant part of the diff comes from the new generated code.

Test Plan

CI should pass.

@Conaclos Conaclos temporarily deployed to Website deployment October 26, 2023 22:08 — with GitHub Actions Inactive
@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter A-Tooling Area: internal tools L-JavaScript Language: JavaScript and super languages labels Oct 26, 2023
@github-actions
Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 49701 49701 0
Passed 48642 48642 0
Failed 1059 1059 0
Panics 0 0 0
Coverage 97.87% 97.87% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6322 6322 0
Passed 2036 2036 0
Failed 4286 4286 0
Panics 0 0 0
Coverage 32.20% 32.20% 0.00%

ts/babel

Test result main count This PR count Difference
Total 662 662 0
Passed 592 592 0
Failed 70 70 0
Panics 0 0 0
Coverage 89.43% 89.43% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 17646 17646 0
Passed 13454 13454 0
Failed 4190 4190 0
Panics 2 2 0
Coverage 76.24% 76.24% 0.00%

@Conaclos Conaclos temporarily deployed to Website deployment October 26, 2023 22:19 — with GitHub Actions Inactive
@ematipico
Copy link
Member

It would be great if the description of the PR would also explain the PR itself: the dead code part 😅

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Thank you for looking after this, that's a significant improvement!

crates/biome_js_analyze/src/options.rs Outdated Show resolved Hide resolved
@Conaclos Conaclos temporarily deployed to Website deployment October 27, 2023 10:19 — with GitHub Actions Inactive
@Conaclos
Copy link
Member Author

It would be great if the description of the PR would also explain the PR itself: the dead code part 😅

Good point! I added some precision. Most of the dead code comes from never called visitor methods.

@Conaclos Conaclos merged commit 55a7aee into main Oct 27, 2023
18 checks passed
@Conaclos Conaclos deleted the conaclos/refactor/config branch October 27, 2023 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter A-Project Area: project A-Tooling Area: internal tools L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants