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

Fix S1144: False positive for partial methods/classes #710

Closed
gkello opened this issue Aug 22, 2017 · 1 comment
Closed

Fix S1144: False positive for partial methods/classes #710

gkello opened this issue Aug 22, 2017 · 1 comment
Assignees
Labels
Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@gkello
Copy link

gkello commented Aug 22, 2017

Description

In case of partial classes/methods, in case when partial method is declared and used in one file but implemented in other file, the implementation gets false positive S1144 detected.

In case the both class parts are in same C# file the issue is not detected.

Repro steps

file Partial.generated.cs

namespace SonarCheck
{
    public partial class Partial
    {
        public void DoWork()
        {
            Initialize();
        }
        partial void Initialize();
    }
}

file Partial.custom.cs

namespace SonarCheck
{
    partial class Partial
    {
        partial void Initialize()
        {
        }
    }
}

Expected behavior

No issues detected

Actual behavior

For Partial.custom.cs file, an issue is detected:

Warning	S1144	Remove the unused private method 'Initialize'.

Known workarounds

Related information

  • SonarAnalyzer.CSharp 6.3.0.2862
  • Visual Studio Professional 2017, version 15.3.1
@michalb-sonar
Copy link
Contributor

Thanks for reporting @gkello! I can reproduce the problem, we'll address it.

Interestingly, on my machine issue is reported even if the partial definitions are in the same file.

@michalb-sonar michalb-sonar added Area: Rules Type: Bug Exceptions and blocking issues during analysis. Type: False Positive Rule IS triggered when it shouldn't be. labels Aug 28, 2017
@michalb-sonar michalb-sonar changed the title S1144 false positive for partial methods/classes Fix S1144: False positive for partial methods/classes Aug 28, 2017
@Evangelink Evangelink removed the Type: Bug Exceptions and blocking issues during analysis. label Oct 18, 2017
@michalb-sonar michalb-sonar added this to the 6.8 milestone Jan 3, 2018
@michalb-sonar michalb-sonar self-assigned this Jan 8, 2018
@ghost ghost removed the Status: Needs Review label Jan 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

No branches or pull requests

3 participants