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 S3604 FP: Remove the member initializer, all constructors set an initial value for the member. #9200

Closed
st4tyc opened this issue Apr 24, 2024 · 1 comment
Assignees

Comments

@st4tyc
Copy link

st4tyc commented Apr 24, 2024

Description

S3604
Remove the member initializer, all constructors set an initial value for the member.
Member initializer values should not be redundant csharpsquid:S3604

Repro steps

 public class EventosPortalResult(string nome, DateTime dataInicio, DateTime dataFim, string endereco, string instagram, string facebook, string linkInscricao, string foto)
 {
     public string? Nome { get; set; } = nome;
     public DateTime DataInicio { get; set; } = dataInicio;
     public DateTime DataFim { get; set; } = dataFim;
     public string? Endereco { get; set; } = endereco;
     public string? Instagram { get; set; } = instagram;
     public string? LinkInscricao { get; set; } = linkInscricao;
      public string? Foto { get; set; } = foto;
}

Expected behavior

should not be raised.

Actual behavior

raises a warning.

Known workarounds

N/A

Related information

  • Community EditionVersion 10.3 (build 82913)
  • Visual Studio 2022
  • MSBuild / dotnet version: .NET 8
@st4tyc st4tyc changed the title Fix Sxxxx FP/FN: Issue title Fix S3604 FP/FN: Issue Remove the member initializer, all constructors set an initial value for the member. Apr 24, 2024
@st4tyc st4tyc changed the title Fix S3604 FP/FN: Issue Remove the member initializer, all constructors set an initial value for the member. Fix S3604 FP/FN: Remove the member initializer, all constructors set an initial value for the member. Apr 24, 2024
@pavel-mikula-sonarsource pavel-mikula-sonarsource changed the title Fix S3604 FP/FN: Remove the member initializer, all constructors set an initial value for the member. Fix S3604 FP: Remove the member initializer, all constructors set an initial value for the member. Apr 24, 2024
@gregory-paidis-sonarsource
Copy link
Contributor

Hey there,

If I understand correctly, this is an FP because of the primary constructor.
This has been fixed as part of 9.14 release.

The 10.3 SonarQube version you mentioned is unfortunately using the 9.13 version of the analyzer.
When you upgrade to a more recent version of SonarQube, this issue will not be raised.

If I missed something, please let me know.
Thanks for taking the time to raise this!

@gregory-paidis-sonarsource gregory-paidis-sonarsource closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2024
@gregory-paidis-sonarsource gregory-paidis-sonarsource closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2024
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

No branches or pull requests

2 participants