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

Case sensitive file extensions #6500

Merged
merged 3 commits into from
Jan 15, 2021

Conversation

Javier-varez
Copy link
Contributor

Closes #6425

Looks for ends_with methods calls with case sensitive extension comparisons.

changelog: Add new lint that warns about case-sensitive file extension comparisons.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @llogiq (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 23, 2020
@Javier-varez
Copy link
Contributor Author

The Clippy Test check error seem to be unrelated to this change. Seems to be already fixed by matthiaskrgr/rust-clippy@2218dd6

@bors
Copy link
Collaborator

bors commented Jan 4, 2021

☔ The latest upstream changes (presumably #6538) made this pull request unmergeable. Please resolve the merge conflicts.

@giraffate
Copy link
Contributor

Can you do a rebase, not merge? We follow a rustc no-merge policy.

@Javier-varez
Copy link
Contributor Author

Sure! Sorry, it is my first contribution and I missed this.

@flip1995
Copy link
Member

flip1995 commented Jan 5, 2021

ping from triage @llogiq. This is awaiting your review.

@bors
Copy link
Collaborator

bors commented Jan 5, 2021

☔ The latest upstream changes (presumably #6542) made this pull request unmergeable. Please resolve the merge conflicts.

Closes rust-lang#6425

Looks for ends_with methods calls with case sensitive extensions.
This was left as default and caused a CI failure for the
case_sensitive_file_extension_comparison lint.
@llogiq
Copy link
Contributor

llogiq commented Jan 13, 2021

I like this lint in general. It may benefit from adding a suggestion, as the replacement code in the docs is probably not obvious to the layman. However, we can still do that in a later PR. I still have to check if the docs and messages follow our conventions, will do that later.


fn check_case_sensitive_file_extension_comparison(ctx: &LateContext<'_>, expr: &Expr<'_>) -> Option<Span> {
lazy_static! {
static ref RE: Regex = Regex::new(r"^\.([a-z0-9]{1,5}|[A-Z0-9]{1,5})$").unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

regex is a fairly heavy dependency for this fairly simple check.

@llogiq
Copy link
Contributor

llogiq commented Jan 15, 2021

Ok, we already use regex-syntax, so adding regex should perhaps not be a big deal, but if someone feels sufficiently nerdsniped, they can still remove the regex in a followup PR. I won't block this for the added dependency though.

@bors r+

@bors
Copy link
Collaborator

bors commented Jan 15, 2021

📌 Commit e56973a has been approved by llogiq

@bors
Copy link
Collaborator

bors commented Jan 15, 2021

⌛ Testing commit e56973a with merge 3577cf7...

@bors
Copy link
Collaborator

bors commented Jan 15, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: llogiq
Pushing 3577cf7 to master...

@bors bors merged commit 3577cf7 into rust-lang:master Jan 15, 2021
@flip1995 flip1995 mentioned this pull request Jan 30, 2021
bors added a commit that referenced this pull request Jan 30, 2021
No lazy static regex

r? `@llogiq`

#6500

regex is unnecessary for this lint (#6500 (comment))
lazy_static is unnecessary. The std lazy feature should be  used instead.

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggest handling case insensitivity on .ends_with(".ext")
6 participants