Skip to content

Commit 1a94d95

Browse files
committed
CodeQA (pls, this is the last one)
1 parent fdfe725 commit 1a94d95

File tree

16 files changed

+79
-197
lines changed

16 files changed

+79
-197
lines changed

.github/workflows/qodana-scan-pr.yml

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,67 +3,8 @@ on:
33
pull_request:
44
branches:
55
- main
6-
- preview
7-
- stable
86
paths-ignore:
97
- '**.md'
108
- 'Hi3Helper.Core/Lang/**.json'
119
- 'Docs/**'
12-
- '**/packages.lock.json'
13-
14-
jobs:
15-
qodana:
16-
runs-on: windows-latest
17-
18-
permissions:
19-
actions: read
20-
contents: write
21-
pull-requests: write
22-
checks: write
23-
security-events: write
24-
25-
strategy:
26-
matrix:
27-
configuration: [Release] # No need to distribute Debug builds
28-
platform: [x64]
29-
framework: [net9.0-windows10.0.22621.0]
30-
31-
env:
32-
Configuration: ${{ matrix.configuration }}
33-
Platform: ${{ matrix.platform }}
34-
DOTNET_INSTALL_DIR: '.\.dotnet'
35-
DOTNET_VERSION: '9.x'
36-
DOTNET_QUALITY: 'ga'
37-
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
38-
39-
steps:
40-
# skip all the steps if the head repo is not the same as the main repo
41-
# https://github.com/orgs/community/discussions/26829#discussioncomment-3253575
42-
- uses: actions/checkout@v4
43-
if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
44-
with:
45-
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
46-
fetch-depth: 0 # a full history is required for pull request analysis
47-
submodules: recursive # many many submodules
48-
49-
- name: Install .NET
50-
uses: actions/setup-dotnet@v4
51-
with:
52-
dotnet-version: ${{ env.DOTNET_VERSION }}
53-
dotnet-quality: ${{ env.DOTNET_QUALITY }}
54-
cache: true
55-
cache-dependency-path: CollapseLauncher/packages.lock.json
56-
57-
- name: 'Qodana Scan'
58-
if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
59-
uses: JetBrains/qodana-action@latest
60-
with:
61-
args: --ide,QDNET
62-
pr-mode: true
63-
env:
64-
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} # read the steps about it below
65-
66-
- uses: github/codeql-action/upload-sarif@v3
67-
if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
68-
with:
69-
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
10+
- '**/packages.lock.json'

.github/workflows/qodana-scan.yml

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,7 @@ on:
33
workflow_dispatch:
44
schedule:
55
- cron: '0 0 * * 0,3,5' # At 00:00 on Sunday, Wednesday, and Friday.
6-
# pull_request:
7-
# branches:
8-
# - main
9-
10-
jobs:
11-
qodana:
12-
runs-on: windows-latest
13-
strategy:
14-
matrix:
15-
configuration: [Release] # No need to distribute Debug builds
16-
platform: [x64]
17-
framework: [net9.0-windows10.0.22621.0]
18-
19-
env:
20-
Configuration: ${{ matrix.configuration }}
21-
Platform: ${{ matrix.platform }}
22-
DOTNET_INSTALL_DIR: '.\.dotnet'
23-
DOTNET_VERSION: '9.x'
24-
DOTNET_QUALITY: 'ga'
25-
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
26-
27-
permissions:
28-
actions: read
29-
contents: write
30-
pull-requests: write
31-
checks: write
32-
security-events: write
33-
34-
steps:
35-
- uses: actions/checkout@v4
36-
with:
37-
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
38-
submodules: recursive # many many submodules
39-
40-
# - name: Install winget
41-
# uses: Cyberboss/install-winget@v1
42-
43-
# - name: Install Qodana CLI
44-
# uses: crazy-max/ghaction-chocolatey@v3
45-
# with:
46-
# args: install qodana --pre --confirm
47-
48-
# - name: Verify Qodana
49-
# run: |
50-
# Import-Module "$env:ChocolateyInstall/helpers/chocolateyInstaller.psm1"
51-
# refreshenv
52-
# qodana --version
53-
54-
- name: Install .NET
55-
uses: actions/setup-dotnet@v4
56-
with:
57-
dotnet-version: ${{ env.DOTNET_VERSION }}
58-
dotnet-quality: ${{ env.DOTNET_QUALITY }}
59-
cache: true
60-
cache-dependency-path: CollapseLauncher/packages.lock.json
61-
62-
# - name: Qodana Scan
63-
# run: |
64-
# Import-Module "$env:ChocolateyInstall/helpers/chocolateyInstaller.psm1"
65-
# refreshenv
66-
# qodana scan --ide QDNET-EAP -o ${{ runner.temp }}\qodana\results --cache-dir ${{ runner.temp }}\qodana\cache
67-
68-
- name: Qodana Scan
69-
uses: JetBrains/qodana-action@v2024.3.3
70-
continue-on-error: true
71-
with:
72-
args: --ide,QDNET
73-
pr-mode: false
74-
env:
75-
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
76-
77-
- uses: github/codeql-action/upload-sarif@v3
78-
if: always()
79-
continue-on-error: true
80-
with:
81-
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
6+
pull_request:
7+
branches:
8+
- preview
9+
- stable

CollapseLauncher/App.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ namespace CollapseLauncher
2222
{
2323
public partial class App
2424
{
25-
public static bool IsAppKilled { get; set; } = false;
25+
// TODO: #671 This App.IsAppKilled will be replaced with cancellable-awaitable event
26+
// to ensure no hot-exit being called before all background tasks
27+
// hasn't being cancelled.
28+
// public static bool IsAppKilled { get; set; } = false;
2629

2730
public App()
2831
{

CollapseLauncher/Classes/GameManagement/Versioning/GameVersionBase.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using CollapseLauncher.Interfaces;
2-
using Microsoft.UI.Xaml;
32
// ReSharper disable IdentifierTypo
43
// ReSharper disable InconsistentNaming
54
// ReSharper disable StringLiteralTypo
@@ -10,13 +9,8 @@ namespace CollapseLauncher.GameManagement.Versioning
109
{
1110
internal partial class GameVersionBase : IGameVersion
1211
{
13-
#region Properties
14-
protected UIElement ParentUIElement { get; set; }
15-
#endregion
16-
17-
protected GameVersionBase(UIElement parentUIElement, RegionResourceProp gameRegionProp, string gameName, string gameRegion)
12+
protected GameVersionBase(RegionResourceProp gameRegionProp, string gameName, string gameRegion)
1813
{
19-
ParentUIElement = parentUIElement;
2014
GameApiProp = gameRegionProp;
2115
GameName = gameName;
2216
GameRegion = gameRegion;

CollapseLauncher/Classes/GameManagement/Versioning/Genshin/VersionCheck.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
using CollapseLauncher.GameManagement.Versioning;
2-
using Microsoft.UI.Xaml;
32
using System.Collections.Generic;
43
using System.IO;
54
// ReSharper disable IdentifierTypo
65

76
namespace CollapseLauncher.GameVersioning
87
{
98
internal sealed class GameTypeGenshinVersion(
10-
UIElement parentUIElement,
119
RegionResourceProp gameRegionProp,
1210
string gameName,
1311
string gamePreset)
14-
: GameVersionBase(parentUIElement, gameRegionProp, gameName, gamePreset)
12+
: GameVersionBase(gameRegionProp, gameName, gamePreset)
1513
{
1614
#region Const
1715
private const string GlobalExecName = "GenshinImpact.exe";

CollapseLauncher/Classes/GameManagement/Versioning/Honkai/VersionCheck.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
using CollapseLauncher.GameManagement.Versioning;
2-
using Microsoft.UI.Xaml;
32
using System;
43
// ReSharper disable IdentifierTypo
54

65
namespace CollapseLauncher.GameVersioning
76
{
87
internal sealed class GameTypeHonkaiVersion(
9-
UIElement parentUIElement,
108
RegionResourceProp gameRegionProp,
119
string gameName,
1210
string gameRegion)
13-
: GameVersionBase(parentUIElement, gameRegionProp, gameName, gameRegion)
11+
: GameVersionBase(gameRegionProp, gameName, gameRegion)
1412
{
1513
#region Statics
1614
private static readonly Version senadinaVersion = new(7, 3, 0);

CollapseLauncher/Classes/GameManagement/Versioning/StarRail/VersionCheck.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Hi3Helper;
44
using Hi3Helper.EncTool.Parser.AssetMetadata;
55
using Hi3Helper.EncTool.Proto.StarRail;
6-
using Microsoft.UI.Xaml;
76
using System;
87
using System.Text;
98

@@ -15,8 +14,8 @@ internal sealed class GameTypeStarRailVersion : GameVersionBase
1514
public SRMetadata StarRailMetadataTool { get; set; }
1615
#endregion
1716

18-
public GameTypeStarRailVersion(UIElement parentUIElement, RegionResourceProp gameRegionProp, string gameName, string gameRegion)
19-
: base(parentUIElement, gameRegionProp, gameName, gameRegion)
17+
public GameTypeStarRailVersion(RegionResourceProp gameRegionProp, string gameName, string gameRegion)
18+
: base(gameRegionProp, gameName, gameRegion)
2019
{
2120
// Initialize Star Rail metadata tool
2221
if (GamePreset.ProtoDispatchKey != null)

CollapseLauncher/Classes/GameManagement/Versioning/Zenless/VersionCheck.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using CollapseLauncher.GameManagement.Versioning;
22
using CollapseLauncher.Helper.Metadata;
33
using Hi3Helper;
4-
using Microsoft.UI.Xaml;
54
using System;
65
using System.Buffers;
76
using System.Buffers.Binary;
@@ -115,8 +114,8 @@ void DisableRepairAndCacheInstance(PresetConfig config)
115114
}
116115
#endregion
117116

118-
public GameTypeZenlessVersion(UIElement parentUIElement, RegionResourceProp gameRegionProp, PresetConfig gamePreset, string gameName, string gameRegion)
119-
: base(parentUIElement, gameRegionProp, gameName, gameRegion)
117+
public GameTypeZenlessVersion(RegionResourceProp gameRegionProp, PresetConfig gamePreset, string gameName, string gameRegion)
118+
: base(gameRegionProp, gameName, gameRegion)
120119
{
121120
// Try check for reinitializing game version.
122121
InitializeSleepy(gamePreset);

CollapseLauncher/Classes/GamePresetProperty.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,28 @@ internal GamePresetProperty(UIElement uiElementParent, RegionResourceProp apiRes
4848
switch (gamePreset.GameType)
4949
{
5050
case GameNameType.Honkai:
51-
GameVersion = new GameTypeHonkaiVersion(uiElementParent, ApiResourceProp, gameName, gameRegion);
51+
GameVersion = new GameTypeHonkaiVersion(ApiResourceProp, gameName, gameRegion);
5252
GameSettings = new HonkaiSettings(GameVersion);
5353
GameCache = new HonkaiCache(uiElementParent, GameVersion);
5454
GameRepair = new HonkaiRepair(uiElementParent, GameVersion, GameCache, GameSettings);
5555
GameInstall = new HonkaiInstall(uiElementParent, GameVersion, GameCache);
5656
break;
5757
case GameNameType.StarRail:
58-
GameVersion = new GameTypeStarRailVersion(uiElementParent, ApiResourceProp, gameName, gameRegion);
58+
GameVersion = new GameTypeStarRailVersion(ApiResourceProp, gameName, gameRegion);
5959
GameSettings = new StarRailSettings(GameVersion);
6060
GameCache = new StarRailCache(uiElementParent, GameVersion);
6161
GameRepair = new StarRailRepair(uiElementParent, GameVersion);
6262
GameInstall = new StarRailInstall(uiElementParent, GameVersion);
6363
break;
6464
case GameNameType.Genshin:
65-
GameVersion = new GameTypeGenshinVersion(uiElementParent, ApiResourceProp, gameName, gameRegion);
65+
GameVersion = new GameTypeGenshinVersion(ApiResourceProp, gameName, gameRegion);
6666
GameSettings = new GenshinSettings(GameVersion);
6767
GameCache = null;
6868
GameRepair = new GenshinRepair(uiElementParent, GameVersion, GameVersion.GameApiProp.data!.game!.latest!.decompressed_path);
6969
GameInstall = new GenshinInstall(uiElementParent, GameVersion);
7070
break;
7171
case GameNameType.Zenless:
72-
GameVersion = new GameTypeZenlessVersion(uiElementParent, ApiResourceProp, gamePreset, gameName, gameRegion);
72+
GameVersion = new GameTypeZenlessVersion(ApiResourceProp, gamePreset, gameName, gameRegion);
7373
GameSettings = new ZenlessSettings(GameVersion);
7474
GameCache = new ZenlessCache(uiElementParent, GameVersion, (GameSettings as ZenlessSettings)!);
7575
GameRepair = new ZenlessRepair(uiElementParent, GameVersion, (GameSettings as ZenlessSettings)!);

CollapseLauncher/Classes/GamePropertyVault.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ private static async void CleanupUnusedGameProperty()
7979
public static async Task AttachNotificationForCurrentGame(int hashID = int.MinValue)
8080
{
8181
if (hashID < 0) hashID = CurrentGameHashID;
82-
if (Vault.TryGetValue(hashID, out var gameProperty))
82+
if (Vault.TryGetValue(hashID, out GamePresetProperty? gameProperty))
8383
{
8484
if (gameProperty is { GameInstall.IsRunning: true })
8585
{
86-
var bgNotification = Locale.Lang._BackgroundNotification;
86+
Locale.LocalizationParams.LangBackgroundNotification? bgNotification = Locale.Lang._BackgroundNotification;
8787
string actTitle = string.Format(await gameProperty.GameVersion.GetGameState() switch
8888
{
8989
GameInstallStateEnum.InstalledHavePreload => bgNotification.CategoryTitle_DownloadingPreload,
@@ -108,7 +108,7 @@ public static void DetachNotificationForCurrentGame(int hashID = int.MinValue)
108108
[SuppressMessage("ReSharper", "PartialTypeWithSinglePart")]
109109
internal partial class PageStatics
110110
{
111-
internal static CommunityToolsProperty CommunityToolsProperty { get; set; } = new()
111+
internal static CommunityToolsProperty? CommunityToolsProperty { get; set; } = new()
112112
{
113113
OfficialToolsDictionary = new Dictionary<GameNameType, List<CommunityToolsEntry>>(),
114114
CommunityToolsDictionary = new Dictionary<GameNameType, List<CommunityToolsEntry>>()

0 commit comments

Comments
 (0)