Skip to content

Commit b17025c

Browse files
authored
feat(ci): Add the EditorConfig style checker to CI (endless-sky#6815)
* Add editorconfig style checker CI. * Fix every editorconfig style violation. * Fix editorconfig file and (almost) all the violations found. * Fix comments. * Fix remaining style violations. * Correct my previous mistake. * Address review comments. * Address review comments. * Fix remaining style violations.
1 parent a128490 commit b17025c

21 files changed

+137
-122
lines changed

.ecrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"Exclude": ["\\.mp3$", "test_datafile.cpp", "\\Shader.cpp$", "Font.cpp", "Mask.cpp"]
3+
}

.editorconfig

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ trim_trailing_whitespace = false
1111
indent_style = tab
1212

1313
# Code files
14-
[*.{cpp,h,rc,hpp}, SConstruct, SConscript]
14+
[{*.{cpp,h,rc,hpp}, SConstruct, SConscript}]
1515
indent_style = tab
16+
# Except any third-party libraries
17+
[catch.hpp]
18+
indent_style = unset
1619

1720
# Markdown
1821
[*.md]

.github/path-filters.yml

+35-35
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
data:
2-
- 'changelog*'
3-
- 'copyright*'
4-
- credits.txt
5-
- icon.png
6-
- keys.txt
7-
- license.txt
8-
- 'data/**/*'
9-
- 'images/**/*'
10-
- 'sounds/**/*'
2+
- 'changelog*'
3+
- 'copyright*'
4+
- credits.txt
5+
- icon.png
6+
- keys.txt
7+
- license.txt
8+
- 'data/**/*'
9+
- 'images/**/*'
10+
- 'sounds/**/*'
1111

1212
game_code: &build
13-
- 'source/**'
13+
- 'source/**'
1414

1515
macos:
16-
- 'XCode/**'
17-
- '**/*.xcodeproj'
18-
- 'icons/endless-sky.iconset/**'
19-
- 'utils/fetch_sdl2_framework.sh'
20-
- 'utils/set_dylibs_rpath.sh'
21-
- *build
16+
- 'XCode/**'
17+
- '**/*.xcodeproj'
18+
- 'icons/endless-sky.iconset/**'
19+
- 'utils/fetch_sdl2_framework.sh'
20+
- 'utils/set_dylibs_rpath.sh'
21+
- *build
2222

2323
windows:
24-
- '**/*.cbp'
25-
- EndlessSky.workspace
26-
- SConstruct
27-
- .winmake
28-
- *build
24+
- '**/*.cbp'
25+
- EndlessSky.workspace
26+
- SConstruct
27+
- .winmake
28+
- *build
2929

3030
linux:
31-
- SConstruct
32-
- *build
31+
- SConstruct
32+
- *build
3333

3434
unit_tests:
35-
- 'tests/unit/**/*.h'
36-
- 'tests/unit/**/*.hpp'
37-
- 'tests/unit/**/*.cpp'
35+
- 'tests/unit/**/*.h'
36+
- 'tests/unit/**/*.hpp'
37+
- 'tests/unit/**/*.cpp'
3838

3939
integration_tests:
40-
- 'utils/test_parse.*'
41-
- 'tests/integration/run_tests*'
42-
- 'data/tests/**'
43-
- 'tests/integration/universes/**'
40+
- 'utils/test_parse.*'
41+
- 'tests/integration/run_tests*'
42+
- 'data/tests/**'
43+
- 'tests/integration/universes/**'
4444

4545
codespell:
46-
- .codespell.exclude
46+
- .codespell.exclude
4747

4848
xcode_files:
49-
- 'EndlessSky.xcodeproj/**'
50-
- 'utils/check_xcode.sh'
49+
- 'EndlessSky.xcodeproj/**'
50+
- 'utils/check_xcode.sh'
5151

5252
codeblocks_files:
53-
- '*.cbp'
54-
- 'utils/check_codeblocks.sh'
53+
- '*.cbp'
54+
- 'utils/check_codeblocks.sh'

.github/workflows/ci.yml

+9
Original file line numberDiff line numberDiff line change
@@ -506,3 +506,12 @@ jobs:
506506
builtin: clear,en-GB_to_en-US
507507
path: data/
508508
exclude_file: .codespell.exclude
509+
510+
511+
512+
style-check:
513+
runs-on: ubuntu-latest
514+
steps:
515+
- uses: actions/checkout@v2
516+
- uses: editorconfig-checker/action-editorconfig-checker@main
517+
- run: editorconfig-checker

data/remnant/remnant 1 introduction.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3741,4 +3741,4 @@ mission "Remnant: Expanded Horizons Storms 1"
37413741
` She looks at you quizzically for a moment, and then her display shifts to a mass of symbols. She skims briefly. "I have never even heard of such a unit. Apparently it is a very old one, though. Our records say that it had largely stopped being used by early in the 21st century. Well, I learned something new today." The display and its field of symbols vanishes as she slings her backpack over her shoulder.`
37423742
label stormend
37433743
` "Thanks for the ride, Captain. I have to get working on this data, but if you are interested in helping some more, I hope to have more research expeditions planned soon."`
3744-
3744+

source/AI.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3629,7 +3629,7 @@ void AI::MovePlayer(Ship &ship, const PlayerInfo &player, Command &activeCommand
36293629
{
36303630
PrepareForHyperspace(ship, command);
36313631
command |= Command::JUMP;
3632-
3632+
36333633
// Don't jump yet if the player is holding jump key or fleet jump is active and
36343634
// escorts are not ready to jump yet.
36353635
if(activeCommands.Has(Command::WAIT) || (autoPilot.Has(Command::FLEET_JUMP) && !EscortsReadyToJump(ship)))

source/Fleet.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void Fleet::RemoveInvalidVariants()
265265
auto removeIt = remove_if(firstInvalid, variants.end(), IsInvalidVariant);
266266
int count = distance(removeIt, variants.end());
267267
variants.erase(removeIt, variants.end());
268-
268+
269269
Files::LogError("Warning: " + (fleetName.empty() ? "unnamed fleet" : "fleet \"" + fleetName + "\"")
270270
+ ": Removing " + to_string(count) + " invalid " + (count > 1 ? "variants" : "variant")
271271
+ " (" + to_string(total - variants.TotalWeight()) + " of " + to_string(total) + " weight)");

source/GameEvent.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void GameEvent::Save(DataWriter &out) const
126126
{
127127
if(isDisabled)
128128
return;
129-
129+
130130
out.Write("event");
131131
out.BeginChild();
132132
{
@@ -218,7 +218,7 @@ void GameEvent::Apply(PlayerInfo &player)
218218
{
219219
if(isDisabled)
220220
return;
221-
221+
222222
// Serialize the current reputation with other governments.
223223
player.SetReputationConditions();
224224

source/InfoPanelState.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void InfoPanelState::SelectMany(int start, int end)
7070
{
7171
for(int i = start; i < end; ++i)
7272
allSelected.insert(i);
73-
73+
7474
if(selectedIndex == -1)
7575
selectedIndex = *allSelected.begin();
7676
}
@@ -146,11 +146,11 @@ bool InfoPanelState::ReorderShips(const set<int> &fromIndices, int toIndex)
146146
{
147147
if(fromIndices.empty() || static_cast<unsigned>(toIndex) >= ships.size())
148148
return false;
149-
149+
150150
// When shifting ships up in the list, move to the desired index. If
151151
// moving down, move after the selected index.
152152
int direction = (*fromIndices.begin() < toIndex) ? 1 : 0;
153-
153+
154154
// Remove the ships from last to first, so that each removal leaves all the
155155
// remaining indices in the set still valid.
156156
vector<shared_ptr<Ship>> removed;
@@ -159,11 +159,11 @@ bool InfoPanelState::ReorderShips(const set<int> &fromIndices, int toIndex)
159159
// The "it" pointer doesn't point to the beginning of the list, so it is
160160
// safe to decrement it here.
161161
--it;
162-
162+
163163
// Bail out if any invalid indices are encountered.
164164
if(static_cast<unsigned>(*it) >= ships.size())
165165
return false;
166-
166+
167167
removed.insert(removed.begin(), ships[*it]);
168168
ships.erase(ships.begin() + *it);
169169
// If this index is before the insertion point, removing it causes the
@@ -174,13 +174,13 @@ bool InfoPanelState::ReorderShips(const set<int> &fromIndices, int toIndex)
174174
// Make sure the insertion index is within the list.
175175
toIndex = min<int>(toIndex + direction, ships.size());
176176
ships.insert(ships.begin() + toIndex, removed.begin(), removed.end());
177-
177+
178178
// Change the selected indices so they still refer to the block of ships
179179
// that just got moved.
180180
int lastIndex = toIndex + allSelected.size();
181181
DeselectAll();
182182
SelectMany(toIndex, lastIndex);
183-
183+
184184
// The ships are no longer sorted.
185185
SetCurrentSort(nullptr);
186186
return true;

source/InfoPanelState.h

+15-15
Original file line numberDiff line numberDiff line change
@@ -23,56 +23,56 @@ class Ship;
2323

2424

2525
// This class is responsible for storing the state
26-
// between PlayerInfoPanel and ShipInfoPanel so that
26+
// between PlayerInfoPanel and ShipInfoPanel so that
2727
// things like scroll position, selection and sort are
2828
// saved when the user is switching between the panels.
2929
class InfoPanelState {
3030
public:
3131
using ShipComparator = bool (const std::shared_ptr <Ship>&, const std::shared_ptr <Ship>&);
32-
32+
3333
InfoPanelState(PlayerInfo &player);
34-
34+
3535
int SelectedIndex() const;
3636
void SetSelectedIndex(int newSelectedIndex);
37-
37+
3838
const std::set<int> &AllSelected() const;
3939
void SetSelected(const std::set<int> &selected);
4040
void Select(int index);
4141
void SelectOnly(int index);
4242
void SelectMany(int start, int end);
4343
bool Deselect(int index);
4444
void DeselectAll();
45-
45+
4646
bool CanEdit() const;
47-
47+
4848
int Scroll() const;
4949
void SetScroll(int newScroll);
50-
50+
5151
std::vector<std::shared_ptr<Ship>> &Ships();
5252
const std::vector<std::shared_ptr<Ship>> &Ships() const;
5353
bool ReorderShips(const std::set<int> &fromIndices, int toIndex);
54-
54+
5555
ShipComparator *CurrentSort() const;
5656
void SetCurrentSort(ShipComparator *s);
57-
58-
57+
58+
5959
private:
6060
// Most recent selected ship index.
6161
int selectedIndex = -1;
62-
62+
6363
// Indices of selected ships.
6464
std::set<int> allSelected;
65-
65+
6666
// A copy of PlayerInfo.ships for viewing and manipulating.
6767
std::vector<std::shared_ptr<Ship>> ships;
68-
68+
6969
// When the player is landed, they are able to
7070
// change their flagship and reorder their fleet.
7171
const bool canEdit = false;
72-
72+
7373
// Index of the ship at the top of the fleet listing.
7474
int scroll = 0;
75-
75+
7676
// Keep track of whether the ships are sorted.
7777
ShipComparator *currentSort = nullptr;
7878
};

0 commit comments

Comments
 (0)