Skip to content

Conversation

@Hweinstock
Copy link
Contributor

@Hweinstock Hweinstock commented Oct 24, 2024

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.

@github-actions
Copy link

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.

@Hweinstock Hweinstock marked this pull request as ready for review October 24, 2024 20:15
@Hweinstock Hweinstock requested a review from a team as a code owner October 24, 2024 20:15
@Hweinstock Hweinstock marked this pull request as draft October 24, 2024 20:17
@Hweinstock Hweinstock marked this pull request as ready for review October 24, 2024 20:33
if (languageId === undefined || defaultLanguages.includes(languageId)) {
return new Set<string>()
}
switch (languageId) {
Copy link
Contributor

@hayemaxi hayemaxi Oct 25, 2024

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.

Copy link
Contributor Author

@Hweinstock Hweinstock Oct 25, 2024

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.

@justinmk3 justinmk3 merged commit 800f536 into aws:master Oct 25, 2024
23 of 24 checks passed
@Hweinstock Hweinstock deleted the languageDedupe branch October 25, 2024 18:55
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.

4 participants