From da651148e1102b6907dd881063233e959bcfce37 Mon Sep 17 00:00:00 2001 From: Lucas <29230467+Somfic@users.noreply.github.com> Date: Thu, 10 Aug 2023 02:49:00 +0200 Subject: [PATCH] Added Qodana to CI/CD --- .github/workflows/qodana_code_quality.yml | 20 ++++++++++++++++ EliteAPI.Tests/Conventions.cs | 4 ++-- EliteAPI.Tests/JournalManual.cs | 2 +- Examples/Example.Web/Program.cs | 16 +++++++++++-- qodana.yaml | 29 +++++++++++++++++++++++ 5 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/qodana_code_quality.yml create mode 100644 qodana.yaml diff --git a/.github/workflows/qodana_code_quality.yml b/.github/workflows/qodana_code_quality.yml new file mode 100644 index 00000000..f9a78fb4 --- /dev/null +++ b/.github/workflows/qodana_code_quality.yml @@ -0,0 +1,20 @@ +name: Qodana +on: + workflow_dispatch: + pull_request: + push: + branches: + - dev + - main + +jobs: + qodana: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: 'Qodana Scan' + uses: JetBrains/qodana-action@v2023.2 + env: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} \ No newline at end of file diff --git a/EliteAPI.Tests/Conventions.cs b/EliteAPI.Tests/Conventions.cs index d40c56f9..fa43e7a4 100644 --- a/EliteAPI.Tests/Conventions.cs +++ b/EliteAPI.Tests/Conventions.cs @@ -81,7 +81,7 @@ public void Properties(PropertyInfo property) static IImmutableList GetProperties() { var eventParser = new EventParser(Mock.Of()); - eventParser.Use();; + eventParser.Use(); var events = new Events.Events(Mock.Of>(), eventParser); events.Register(); @@ -102,7 +102,7 @@ static IImmutableList GetTypes() { var eventParser = new EventParser(Mock.Of()); eventParser.Use(); - ; + var events = new Events.Events(Mock.Of>(), eventParser); events.Register(); diff --git a/EliteAPI.Tests/JournalManual.cs b/EliteAPI.Tests/JournalManual.cs index 054806cc..268e4421 100644 --- a/EliteAPI.Tests/JournalManual.cs +++ b/EliteAPI.Tests/JournalManual.cs @@ -29,7 +29,7 @@ public class JournalManual public void Setup() { var eventParser = new EventParser(Mock.Of()); - eventParser.Use();; + eventParser.Use(); _events = new Events.Events(Mock.Of>(), eventParser); _events.Register(); } diff --git a/Examples/Example.Web/Program.cs b/Examples/Example.Web/Program.cs index 73d47aed..e868d59c 100644 --- a/Examples/Example.Web/Program.cs +++ b/Examples/Example.Web/Program.cs @@ -21,8 +21,20 @@ .GetRequiredService(); Console.WriteLine("Getting route ... "); -var response = await spansh.Routes.Neutron(new NeutronRequest("Sol", "Colonia")); +var response = await spansh.Routes.Trade(new TradeRequest("Shinrarta Dezhra", "Jameson Memorial", 50, 720)); response.On( - ok: r => Console.WriteLine(string.Join(" > ", r.SystemJumps.Select(x => x.System))), + ok: route => + { + foreach (var stop in route) + { + Console.WriteLine(stop.System.Name + " - " + stop.System.Station); + foreach (var commodity in stop.Commodities) + { + Console.WriteLine($" - {commodity.Name} {commodity.Amount}x (+{commodity.TotalProfit:N0}cr)"); + } + + Console.WriteLine(); + } + }, error: e => Console.WriteLine(e.Message)); \ No newline at end of file diff --git a/qodana.yaml b/qodana.yaml new file mode 100644 index 00000000..99a40de6 --- /dev/null +++ b/qodana.yaml @@ -0,0 +1,29 @@ +#-------------------------------------------------------------------------------# +# Qodana analysis is configured by qodana.yaml file # +# https://www.jetbrains.com/help/qodana/qodana-yaml.html # +#-------------------------------------------------------------------------------# +version: "1.0" + +#Specify inspection profile for code analysis +profile: + name: qodana.starter + +#Enable inspections +#include: +# - name: + +#Disable inspections +#exclude: +# - name: +# paths: +# - + +#Execute shell command before Qodana execution (Applied in CI/CD pipeline) +#bootstrap: sh ./prepare-qodana.sh + +#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline) +#plugins: +# - id: #(plugin id can be found at https://plugins.jetbrains.com) + +#Specify Qodana linter for analysis (Applied in CI/CD pipeline) +linter: jetbrains/qodana-dotnet:latest