Skip to content

Commit

Permalink
sonar qube fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adityanarayanp committed Dec 7, 2023
1 parent a3b0af4 commit 0eb259e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
5 changes: 1 addition & 4 deletions src/LCT.SW360PackageCreator/ConanPackageDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ namespace LCT.SW360PackageCreator

public class ConanPackageDownloader: IPackageDownloader
{
static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private readonly List<DownloadedSourceInfo> m_downloadedSourceInfos = new List<DownloadedSourceInfo>();
private const string Source = "source";
public async Task<string> DownloadPackage(ComparisonBomData component, string localPathforDownload)
{
string path = Download(component, localPathforDownload);
await Task.Delay(10);
return path;
}
private string Download(ComparisonBomData component, string downloadPath)
private static string Download(ComparisonBomData component, string downloadPath)
{
return "";
}
Expand Down
28 changes: 11 additions & 17 deletions src/LCT.SW360PackageCreator/URLHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class UrlHelper : IUrlHelper, IDisposable
private readonly HttpClient httpClient = new HttpClient();
public static string GithubUrl { get; set; } = string.Empty;
public static UrlHelper Instance { get; } = new UrlHelper();
public CommonAppSettings CommonAppSettings =new CommonAppSettings();
public CommonAppSettings CommonAppSettings { get; } = new CommonAppSettings();

private bool _disposed;

Expand Down Expand Up @@ -162,7 +162,7 @@ public string GetSourceUrlForNpmPackage(string componentName, string version)
/// <param name="componentName"></param>
/// <param name="version"></param>
/// <returns>string</returns>
public async Task<string> GetSourceUrlForConanPackage(string componentName, string version)
public async Task<string> GetSourceUrlForConanPackage(string componentName, string componenVersion)
{

var downLoadUrl = $"{CommonAppSettings.SourceURLConan}" + componentName + "/all/conandata.yml";
Expand All @@ -178,7 +178,7 @@ public async Task<string> GetSourceUrlForConanPackage(string componentName, stri
response.EnsureSuccessStatusCode();
var jsonObject = await response.Content.ReadAsStringAsync();
packageSourcesInfo = deserializer.Deserialize<Sources>(jsonObject);
if (packageSourcesInfo.SourcesData.TryGetValue(version, out var release))
if (packageSourcesInfo.SourcesData.TryGetValue(componenVersion, out var release))
{
if (release.Url.GetType().Name.ToLowerInvariant() == "string")
{
Expand All @@ -187,26 +187,20 @@ public async Task<string> GetSourceUrlForConanPackage(string componentName, stri
else
{
List<object> urlList = (List<object>)release.Url;
componentSrcURL = urlList.FirstOrDefault() != null ? urlList.FirstOrDefault().ToString() : "";
componentSrcURL = urlList.FirstOrDefault()?.ToString() ?? "";
}
}
}
catch (Exception)
catch (HttpRequestException ex)
{

var response = new HttpResponseMessage(HttpStatusCode.NotFound)
{
Content = new StringContent(string.Format("Problem Getting Information from Conan Server For = {0}", componentName)),
ReasonPhrase = "Problem Occured while connecting to conan Server"
};
Logger.Warn($"Identification of SRC url failed for {componentName}, " +
$"Exclude if it is an internal component or manually update the SRC url");
Logger.Debug($"GetSourceUrlForConanPackage()", ex);
}
finally
{
_httpClient.Dispose();
catch (ArgumentNullException ex)
{
Logger.Debug($"GetSourceUrlForConanPackage()", ex);
}



}
return componentSrcURL;
}
Expand Down

0 comments on commit 0eb259e

Please sign in to comment.