Skip to content

Commit

Permalink
Accolades sur le "if liste null". Plus respectueux des bonnes pratiqu…
Browse files Browse the repository at this point in the history
…es (voir issue Sonar java:S121)
  • Loading branch information
kevin.buntrock committed Oct 1, 2024
1 parent a263ddf commit 65e02f9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion TopModel.Generator.Jpa/JpaModelPropertyGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ public void WriteGetter(JavaWriter fw, Class classe, string tag, IProperty prope
var type = _config.GetType(ap, _classes, useClassForAssociation: useClassForAssociation).Split('<').First();
if (_newableTypes.TryGetValue(type, out var newableType))
{
fw.WriteLine(indentLevel + 1, $"if(this.{propertyName} == null)");
fw.WriteLine(indentLevel + 1, $"if(this.{propertyName} == null) {{");
fw.AddImport($"java.util.{newableType}");
fw.WriteLine(indentLevel + 2, $"this.{propertyName} = new {newableType}<>();");
fw.WriteLine(indentLevel + 1, $"}}");

Check warning on line 131 in TopModel.Generator.Jpa/JpaModelPropertyGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 131 in TopModel.Generator.Jpa/JpaModelPropertyGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 131 in TopModel.Generator.Jpa/JpaModelPropertyGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 131 in TopModel.Generator.Jpa/JpaModelPropertyGenerator.cs

View workflow job for this annotation

GitHub Actions / build

}
}

Expand Down

0 comments on commit 65e02f9

Please sign in to comment.