Skip to content

Commit dbf76a1

Browse files
authored
Merge pull request #927 from softworkz/submit_whitespace2
Fix formatting and add GitHub Action to check trailing whitespace
2 parents 7889057 + 8e7892e commit dbf76a1

File tree

108 files changed

+384
-345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+384
-345
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Trailing Whitespace Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
check-trailing-whitespace:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Check for trailing whitespace
20+
run: |
21+
echo "Checking for trailing whitespace in changed files..."
22+
23+
# Get the base branch
24+
BASE_SHA="${{ github.event.pull_request.base.sha }}"
25+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
26+
27+
# Get list of changed files (excluding deleted files)
28+
CHANGED_FILES=$(git diff --name-only --diff-filter=d "$BASE_SHA" "$HEAD_SHA")
29+
30+
if [ -z "$CHANGED_FILES" ]; then
31+
echo "No files to check."
32+
exit 0
33+
fi
34+
35+
# File patterns to check (text files)
36+
PATTERNS="\.cs$|\.csproj$|\.sln$|\.ts$|\.html$|\.css$|\.scss$"
37+
38+
# Directories and file patterns to exclude
39+
EXCLUDE_PATTERNS="(^|\/)(\.|node_modules|bin|obj|artifacts|packages|\.vs|\.nuke\/temp)($|\/)"
40+
41+
ERRORS_FOUND=0
42+
TEMP_FILE=$(mktemp)
43+
44+
while IFS= read -r file; do
45+
# Skip if file doesn't exist (shouldn't happen with --diff-filter=d, but just in case)
46+
if [ ! -f "$file" ]; then
47+
continue
48+
fi
49+
50+
# Check if file matches patterns to check
51+
if ! echo "$file" | grep -qE "$PATTERNS"; then
52+
continue
53+
fi
54+
55+
# Check if file should be excluded
56+
if echo "$file" | grep -qE "$EXCLUDE_PATTERNS"; then
57+
continue
58+
fi
59+
60+
# Find trailing whitespace lines, excluding XML doc placeholder lines that are exactly "/// " (one space)
61+
MATCHES=$(grep -n '[[:space:]]$' "$file" | grep -vE '^[0-9]+:[[:space:]]*/// $' || true)
62+
63+
if [ -n "$MATCHES" ]; then
64+
echo "❌ Trailing whitespace found in: $file"
65+
echo "$MATCHES" | head -10
66+
TOTAL=$(echo "$MATCHES" | wc -l)
67+
if [ "$TOTAL" -gt 10 ]; then
68+
echo " ... and $(($TOTAL - 10)) more lines"
69+
fi
70+
echo "1" >> "$TEMP_FILE"
71+
fi
72+
done <<< "$CHANGED_FILES"
73+
74+
ERRORS_FOUND=$(wc -l < "$TEMP_FILE" 2>/dev/null || echo "0")
75+
rm -f "$TEMP_FILE"
76+
77+
if [ "$ERRORS_FOUND" -gt 0 ]; then
78+
echo ""
79+
echo "❌ Found trailing whitespace in $ERRORS_FOUND file(s)."
80+
echo "Please remove trailing whitespace from the files listed above."
81+
exit 1
82+
else
83+
echo "✅ No trailing whitespace found in changed files."
84+
exit 0
85+
fi

nuke/ReleaseNotesParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private IReadOnlyList<ReleaseNotes> ParseComplexFormat(string[] lines)
8585

8686
// Parse content.
8787
var notes = new List<string>();
88-
88+
8989
while (true)
9090
{
9191
// Sanity checks.

src/ElectronNET.API/API/ApiBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// ReSharper disable InconsistentNaming
2+
23
namespace ElectronNET.API
34
{
45
using Common;
@@ -17,6 +18,7 @@ protected enum SocketTaskEventNameTypes
1718
DashesLowerFirst,
1819
NoDashUpperFirst
1920
}
21+
2022
protected enum SocketTaskMessageNameTypes
2123
{
2224
DashesLowerFirst,
@@ -370,4 +372,4 @@ public bool Unregister<T>(Action<T> receiver)
370372
}
371373
}
372374
}
373-
}
375+
}

src/ElectronNET.API/API/App.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public event Action WindowAllClosed
5858
private event Action _windowAllClosed;
5959

6060
/// <summary>
61-
/// Emitted before the application starts closing its windows.
61+
/// Emitted before the application starts closing its windows.
6262
/// <para/>
6363
/// Note: If application quit was initiated by <see cref="AutoUpdater.QuitAndInstall"/> then <see cref="BeforeQuit"/>
6464
/// is emitted after emitting close event on all windows and closing them.
@@ -399,7 +399,6 @@ internal static App Instance
399399
private static object _syncRoot = new object();
400400

401401

402-
403402
/// <summary>
404403
/// Try to close all windows. The <see cref="BeforeQuit"/> event will be emitted first. If all windows are successfully
405404
/// closed, the <see cref="WillQuit"/> event will be emitted and by default the application will terminate. This method
@@ -558,7 +557,7 @@ public void SetPath(PathName name, string path)
558557
}
559558

560559
/// <summary>
561-
/// The version of the loaded application. If no version is found in the application’s package.json file,
560+
/// The version of the loaded application. If no version is found in the application’s package.json file,
562561
/// the version of the current bundle or executable is returned.
563562
/// </summary>
564563
/// <returns>The version of the loaded application.</returns>
@@ -1245,7 +1244,7 @@ public Task<string> UserAgentFallbackAsync
12451244
return Task.Run(() =>
12461245
{
12471246
var taskCompletionSource = new TaskCompletionSource<string>();
1248-
1247+
12491248
BridgeConnector.Socket.Once<string>("appGetUserAgentFallbackCompleted", taskCompletionSource.SetResult);
12501249
BridgeConnector.Socket.Emit("appGetUserAgentFallback");
12511250

@@ -1295,4 +1294,4 @@ public void Once(string eventName, Action action)
12951294
public async Task Once(string eventName, Action<object> action)
12961295
=> await Events.Instance.Once(ModuleName, eventName, action).ConfigureAwait(false);
12971296
}
1298-
}
1297+
}

src/ElectronNET.API/API/AutoUpdater.cs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace ElectronNET.API
1010
/// <summary>
1111
/// Enable apps to automatically update themselves. Based on electron-updater.
1212
/// </summary>
13-
public sealed class AutoUpdater: ApiBase
13+
public sealed class AutoUpdater : ApiBase
1414
{
1515
protected override SocketTaskEventNameTypes SocketTaskEventNameType => SocketTaskEventNameTypes.DashesLowerFirst;
1616
protected override SocketTaskMessageNameTypes SocketTaskMessageNameType => SocketTaskMessageNameTypes.DashesLowerFirst;
@@ -49,7 +49,7 @@ public bool AutoInstallOnAppQuit
4949
}
5050

5151
/// <summary>
52-
/// *GitHub provider only.* Whether to allow update to pre-release versions.
52+
/// *GitHub provider only.* Whether to allow update to pre-release versions.
5353
/// Defaults to "true" if application version contains prerelease components (e.g. "0.12.1-alpha.1", here "alpha" is a prerelease component), otherwise "false".
5454
///
5555
/// If "true", downgrade will be allowed("allowDowngrade" will be set to "true").
@@ -67,7 +67,7 @@ public bool AllowPrerelease
6767
}
6868

6969
/// <summary>
70-
/// *GitHub provider only.*
70+
/// *GitHub provider only.*
7171
/// Get all release notes (from current version to latest), not just the latest (Default is false).
7272
/// </summary>
7373
public bool FullChangelog
@@ -122,7 +122,7 @@ public Task<SemVer> CurrentVersionAsync
122122
}
123123

124124
/// <summary>
125-
/// Get the update channel. Not applicable for GitHub.
125+
/// Get the update channel. Not applicable for GitHub.
126126
/// Doesn’t return channel from the update configuration, only if was previously set.
127127
/// </summary>
128128
[Obsolete("Use the asynchronous version ChannelAsync instead")]
@@ -135,7 +135,7 @@ public string Channel
135135
}
136136

137137
/// <summary>
138-
/// Get the update channel. Not applicable for GitHub.
138+
/// Get the update channel. Not applicable for GitHub.
139139
/// Doesn’t return channel from the update configuration, only if was previously set.
140140
/// </summary>
141141
public Task<string> ChannelAsync
@@ -147,7 +147,7 @@ public Task<string> ChannelAsync
147147
}
148148

149149
/// <summary>
150-
/// Set the update channel. Not applicable for GitHub.
150+
/// Set the update channel. Not applicable for GitHub.
151151
/// </summary>
152152
public string SetChannel
153153
{
@@ -199,7 +199,7 @@ public event Action OnCheckingForUpdate
199199
}
200200

201201
/// <summary>
202-
/// Emitted when there is an available update.
202+
/// Emitted when there is an available update.
203203
/// The update is downloaded automatically if AutoDownload is true.
204204
/// </summary>
205205
public event Action<UpdateInfo> OnUpdateAvailable
@@ -332,11 +332,11 @@ public Task<UpdateCheckResult> CheckForUpdatesAndNotifyAsync()
332332
}
333333

334334
/// <summary>
335-
/// Restarts the app and installs the update after it has been downloaded.
336-
/// It should only be called after `update-downloaded` has been emitted.
337-
///
338-
/// Note: QuitAndInstall() will close all application windows first and only emit `before-quit` event on `app` after that.
339-
/// This is different from the normal quit event sequence.
335+
/// Restarts the app and installs the update after it has been downloaded.
336+
/// It should only be called after `update-downloaded` has been emitted.
337+
///
338+
/// Note: QuitAndInstall() will close all application windows first and only emit `before-quit` event on `app` after that.
339+
/// This is different from the normal quit event sequence.
340340
/// </summary>
341341
/// <param name="isSilent">*windows-only* Runs the installer in silent mode. Defaults to `false`.</param>
342342
/// <param name="isForceRunAfter">Run the app after finish even on silent install. Not applicable for macOS. Ignored if `isSilent` is set to `false`.</param>
@@ -374,9 +374,5 @@ public Task<string> GetFeedURLAsync()
374374

375375
return tcs.Task;
376376
}
377-
378-
379377
}
380-
}
381-
382-
378+
}

src/ElectronNET.API/API/BrowserView.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ namespace ElectronNET.API
88
/// It is like a child window, except that it is positioned relative to its owning window.
99
/// It is meant to be an alternative to the webview tag.
1010
/// </summary>
11-
public class BrowserView: ApiBase
11+
public class BrowserView : ApiBase
1212
{
1313
protected override SocketTaskEventNameTypes SocketTaskEventNameType => SocketTaskEventNameTypes.DashesLowerFirst;
1414
protected override SocketTaskMessageNameTypes SocketTaskMessageNameType => SocketTaskMessageNameTypes.DashesLowerFirst;
15+
1516
/// <summary>
1617
/// Gets the identifier.
1718
/// </summary>
@@ -69,5 +70,4 @@ public void SetBackgroundColor(string color)
6970
BridgeConnector.Socket.Emit("browserView-setBackgroundColor", Id, color);
7071
}
7172
}
72-
}
73-
73+
}

0 commit comments

Comments
 (0)