Skip to content

Commit

Permalink
Merge pull request #103 from siemens/sonar_fixes
Browse files Browse the repository at this point in the history
Fixing 3 sonarqube smells and 1 sonar bug
  • Loading branch information
karthika-g authored Nov 21, 2023
2 parents 8a31811 + fd4b61e commit e111853
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/LCT.Common/FileOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Bom CombineComponentsFromExistingBOM(Bom components, string filePath)

comparisonData.Components = comparisonData.Components?.GroupBy(x => new { x.Name, x.Version }).Select(y => y.First()).ToList();

if (comparisonData.Dependencies.Count > 0)
if (comparisonData.Dependencies != null && comparisonData.Dependencies.Count > 0)
{
comparisonData.Dependencies.AddRange(components.Dependencies);
}
Expand Down
2 changes: 1 addition & 1 deletion src/LCT.Common/FileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public TomlTable ParseTomlFile(string filePath)
table = TOML.Parse(reader);
return table;
}
catch(Exception ex)
catch(TomlParseException)
{
return new TomlTable();
}
Expand Down
2 changes: 1 addition & 1 deletion src/LCT.PackageIdentifier/ConanProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private static void GetDependecyDetails(List<Component> componentsForBOM, List<C
private static void GetPackagesForBom(ref List<Component> lstComponentForBOM, ref int noOfDevDependent, List<ConanPackage> nodePackages)
{
var rootNode = nodePackages.FirstOrDefault();
if (!rootNode.Dependencies.Any() || rootNode.Dependencies == null)
if (rootNode != null && (!rootNode.Dependencies.Any() || rootNode.Dependencies == null))
{
throw new ArgumentNullException(nameof(nodePackages), "Dependency(requires) node name details not present in the root node.");
}
Expand Down
2 changes: 2 additions & 0 deletions src/LCT.PackageIdentifier/NugetDevDependencyParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public static NugetDevDependencyParser Instance
}
}

#pragma warning disable CA1822 // Mark members as static
public List<Container> Parse(string configFile)
#pragma warning restore CA1822 // Mark members as static
{
List<Container> containerList = new();

Expand Down

0 comments on commit e111853

Please sign in to comment.