-
Notifications
You must be signed in to change notification settings - Fork 437
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(cw): avoid duplicating language list. #5859
Conversation
This pull request modifies code in src/ but no tests were added/updated. Confirm whether tests should be added or ensure the PR description explains why tests are not required. |
'abap', | ||
].includes(languageId) | ||
) { | ||
if (languageId === undefined || defaultLanguages.includes(languageId)) { | ||
return new Set<string>() | ||
} | ||
switch (languageId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of scope, but man this switch statement is brutal. Could probably cut the character count by more than half by using pass-through and not typing new Set<string>
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I thought the same thing lol. These functions are basically just a giant map of languages to alternative names and policies.
Problem
This is the longest case of code duplication in the repo from
jscpd
(46 lines!).Solution
Remove the duplication case, remove redundant if statement.
The switch statements could also be refactored into something with significantly less code in the future. Want to keep this PR focused on reducing code duplication.
License: I confirm that my contribution is made under the terms of the Apache 2.0 license.