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

Remove useless assignments #11774

Merged
merged 1 commit into from
Jan 29, 2022
Merged

Remove useless assignments #11774

merged 1 commit into from
Jan 29, 2022

Conversation

IgorPolyakov
Copy link
Contributor

@IgorPolyakov IgorPolyakov commented Jan 27, 2022

Hey! this is my first crystal contribution. I ran the source code through the ameba analyzer (ttps://github.com/crystal-ameba/ameba) and fixed a few lines.

If it's helpful I can correct others comments.

The pull request is in the draft stage, if anything needs to be fixed, I'd love some feedback.

Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

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

LGTM, just a minor suggestion.

Comment on lines 450 to 451
encoding, _split_one, rest = encoded.partition('\'')
_lang, _split_two, value = rest.partition('\'')
Copy link
Member

Choose a reason for hiding this comment

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

I think we can just use underscore without names to make the relevant variable names pop out more.

Suggested change
encoding, _split_one, rest = encoded.partition('\'')
_lang, _split_two, value = rest.partition('\'')
encoding, _, rest = encoded.partition('\'')
_, _, value = rest.partition('\'')

Maybe keep _lang as a label, but I'd certainly toss out the separator names.

Copy link
Contributor

@HertzDevil HertzDevil Jan 27, 2022

Choose a reason for hiding this comment

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

_lang would still be unused. Does Ameba intentionally skip over variables starting with an underscore? (I know that Elixir does, for example.)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think the purpose of variable names with underscore prefix is to indicate that variable is unused, but still give it a label to document context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed split word, and use the lang with the _ prefix, linter doesn't worry about this line now

@IgorPolyakov IgorPolyakov marked this pull request as ready for review January 27, 2022 18:36
@straight-shoota straight-shoota added this to the 1.4.0 milestone Jan 28, 2022
@straight-shoota straight-shoota changed the title remove useless assignment Remove useless assignments Jan 29, 2022
@straight-shoota straight-shoota merged commit 20ae66a into crystal-lang:master Jan 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants