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

Improve S3247: Rule should recommend pattern matching for new C# instead of as #2120

Closed
3 tasks
Evangelink opened this issue Nov 23, 2018 · 0 comments · Fixed by #9490
Closed
3 tasks

Improve S3247: Rule should recommend pattern matching for new C# instead of as #2120

Evangelink opened this issue Nov 23, 2018 · 0 comments · Fixed by #9490
Assignees
Labels
Area: C# C# rules related issues. Sprint: Hardening Fix FPs/FNs/improvements Type: Rule rework Change rule behavior
Milestone

Comments

@Evangelink
Copy link
Contributor

Evangelink commented Nov 23, 2018

Description

Currently, when the rule detects a is check in an if followed by a cast, it raises an issue recommending to Replace this type-check-and-cast sequence with an 'as' and a null check.. While this is still relevant it makes more sense for modern applications to suggest to use pattern matching instead.

Repro steps

https://sonarcloud.io/project/issues?id=sonarlint-visualstudio&issues=AWMB0jMemtQEh111EJCu&open=AWMB0jMemtQEh111EJCu

TODO

  • Rule should be updated
  • RSPEC should be updated
  • Tests should be updated

When implementing this rule consider also #223

@Evangelink Evangelink added Type: Improvement Area: C# C# rules related issues. labels Nov 23, 2018
@Evangelink Evangelink added this to the Rules milestone Nov 23, 2018
@pavel-mikula-sonarsource pavel-mikula-sonarsource removed this from the Rules milestone Dec 4, 2019
@sebastien-marichal sebastien-marichal added the Sprint: Hardening Fix FPs/FNs/improvements label Jun 26, 2024
@sebastien-marichal sebastien-marichal self-assigned this Jun 28, 2024
@sebastien-marichal sebastien-marichal changed the title Update S3247: Rule should recommend pattern matching for new C# instead of as Improve S3247: Rule should recommend pattern matching for new C# instead of as Jul 1, 2024
@sebastien-marichal sebastien-marichal added this to the 9.29 milestone Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Sprint: Hardening Fix FPs/FNs/improvements Type: Rule rework Change rule behavior
Projects
None yet
4 participants