Skip to content

Commit

Permalink
concatenate base class and implemented interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
shemogumbe committed Nov 9, 2024
1 parent 30b5b88 commit 27e9c46
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ public override void WriteCodeElement(ClassDeclaration codeElement, LanguageWrit
}

var abcClass = !codeElement.Implements.Any() ? string.Empty : $"{codeElement.Implements.Select(static x => x.Name).Aggregate((x, y) => x + ", " + y)}";
var derivation = codeElement.Inherits is CodeType inheritType &&
var baseClass = codeElement.Inherits is CodeType inheritType &&
conventions.GetTypeString(inheritType, codeElement) is string inheritSymbol &&
!string.IsNullOrEmpty(inheritSymbol) ?
inheritSymbol :
abcClass;
string.Empty;
var derivation = string.IsNullOrEmpty(baseClass) ? abcClass : string.IsNullOrEmpty(abcClass) ? baseClass : $"{baseClass}, {abcClass}";

Check warning on line 44 in src/Kiota.Builder/Writers/Python/CodeClassDeclarationWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Extract this nested ternary operation into an independent statement. (https://rules.sonarsource.com/csharp/RSPEC-3358)

Check warning on line 44 in src/Kiota.Builder/Writers/Python/CodeClassDeclarationWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Extract this nested ternary operation into an independent statement. (https://rules.sonarsource.com/csharp/RSPEC-3358)
writer.WriteLine($"class {codeElement.Name}({derivation}):");
writer.IncreaseIndent();
if (codeElement.Parent is CodeClass parent)
Expand Down

0 comments on commit 27e9c46

Please sign in to comment.