Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor FXIOS-10205 [Swiftlint] Enable implicitly_unwrapped_optional rule but keep it disabled for test files using nested Swiftlint configurations #24031

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ only_rules: # Only enforce these rules, ignore all others
- accessibility_trait_for_button
- force_cast
- closure_body_length
- implicitly_unwrapped_optional

# These rules were originally opted into. Disabling for now to get
# Swiftlint up and running.
Expand Down
9 changes: 9 additions & 0 deletions BrowserKit/Tests/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Swiftlint configuration overloads that will be applied to all files
# in this folder and all its children recursively, unless another
# nested configuration takes over.
# https://github.com/realm/SwiftLint#nested-configurations.

disabled_rules:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thanks for the work on this issue 🙌 I'll let my colleagues do the final review!

# Many test use implicitly unwrapped optional properties that
# initialized in setUp and reset in tearDown.
- implicitly_unwrapped_optional
2 changes: 1 addition & 1 deletion firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15861,7 +15861,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\nMODIFIED_FILES=$(git diff --name-only --diff-filter=ACM | grep -e '\\.swift$')\n\nif which swiftlint > /dev/null; then\n for file in $MODIFIED_FILES; do\n swiftlint lint \"${SRCROOT}/../${file}\" --config \"${SRCROOT}/../.swiftlint.yml\"\n done\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\" \nfi\n";
shellScript = "if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\nMODIFIED_FILES=$(git diff --name-only --diff-filter=ACM | grep -e '\\.swift$')\n\nif which swiftlint > /dev/null; then\n\n # Move to the location of the root Swiftlint config file in\n # order to use nested configurations\n cd ${SWIFTLINT_ROOT}\n \n for file in $MODIFIED_FILES; do\n swiftlint lint \"${SRCROOT}/../${file}\"\n done\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\" \nfi\n";
Copy link
Collaborator

@FilippoZazzeroni FilippoZazzeroni Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small change the rest looks great 🎉 . i'd have:

// move out of the for loop
cd $SWIFTLINT_ROOT
for loop {}

I'd also reduce the comment a bit and add it directly to the cd $SWIFTLINT_ROOT saying that this instruction is needed here in order to have nested swiftlint configurations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done!

};
E6639F191BF11E3A002D0853 /* Conditionally Add Settings Bundle */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
9 changes: 9 additions & 0 deletions firefox-ios/firefox-ios-tests/Tests/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Swiftlint configuration overloads that will be applied to all files
# in this folder and all its children recursively, unless another
# nested configuration takes over.
# https://github.com/realm/SwiftLint#nested-configurations.

disabled_rules:
# Many test use implicitly unwrapped optional properties that
# initialized in setUp and reset in tearDown.
- implicitly_unwrapped_optional