-
Notifications
You must be signed in to change notification settings - Fork 83
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
Added linting check using SwiftLint #417
Merged
Merged
Changes from all commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
6a5a4e2
Create pr_swift_lint
henrytwagner 4a8ea61
Rename pr_swift_lint to pr_swift_lint.yaml
henrytwagner 729f000
Testing current push
henrytwagner 6bd8084
Testing current Push
henrytwagner 42aca42
Update pr_swift_lint.yaml
henrytwagner 75ac683
Create .swiftlint.yaml
henrytwagner 54d8d7b
Update pr_swift_lint.yaml
henrytwagner 27197e5
Update pr_swift_lint.yaml
henrytwagner 8d24fce
Update pr_swift_lint.yaml
henrytwagner 26ca889
Rename .swiftlint.yaml to a.swiftlint.yaml.txt
henrytwagner 5fda9ba
Update pr_swift_lint.yaml
henrytwagner 0c18d78
Rename a.swiftlint.yaml.txt to .swiftlint.yaml
henrytwagner bfbaec7
Update pr_swift_lint.yaml
henrytwagner db81b0f
Update pr_swift_lint.yaml
henrytwagner 030967c
Update pr_swift_lint.yaml
henrytwagner df7ef72
Update pr_swift_lint.yaml
henrytwagner 9c61592
Update .swiftlint.yaml
henrytwagner e775a05
Update pr_swift_lint.yaml
henrytwagner 21dfc73
Update pr_swift_lint.yaml
henrytwagner 5e20889
Update pr_swift_lint.yaml
henrytwagner 3cba1fa
Update pr_swift_lint.yaml
henrytwagner 514f702
Update pr_swift_lint.yaml
henrytwagner 0c460e9
Update pr_swift_lint.yaml
henrytwagner a40beb0
Update pr_swift_lint.yaml
henrytwagner 4ea8bf5
Update pr_swift_lint.yaml
henrytwagner 03c7325
Update .swiftlint.yaml
henrytwagner e39758c
Update pr_swift_lint.yaml
henrytwagner 45454fc
Update pr_swift_lint.yaml
henrytwagner 25d3b3f
Update pr_swift_lint.yaml
henrytwagner 3228edb
Update pr_swift_lint.yaml
henrytwagner a6df895
Update pr_swift_lint.yaml
henrytwagner b3a86b8
Update pr_swift_lint.yaml
henrytwagner b436ded
Update pr_swift_lint.yaml
henrytwagner 7f6c9aa
Update pr_swift_lint.yaml
henrytwagner 7830b7f
Update pr_swift_lint.yaml
henrytwagner 627e88e
Update pr_swift_lint.yaml
henrytwagner 5ad8fc9
Update .swiftlint.yaml
henrytwagner 92972ef
Update pr_swift_lint.yaml
henrytwagner b7e216d
Update .swiftlint.yaml
henrytwagner 2a9bba9
Update pr_swift_lint.yaml
henrytwagner 145e80c
Update .swiftlint.yaml
henrytwagner 68989ea
Update pr_swift_lint.yaml
henrytwagner 21786bf
Update .swiftlint.yaml
henrytwagner a75f2ed
Update pr_swift_lint.yaml
henrytwagner f24b91d
Update pr_swift_lint.yaml
henrytwagner 5425ba0
Update pr_swift_lint.yaml
henrytwagner cfb6001
Update pr_swift_lint.yaml
henrytwagner 26bd9b0
Update pr_swift_lint.yaml
henrytwagner bb5798d
Update pr_swift_lint.yaml
henrytwagner cf0a7e2
Update pr_swift_lint.yaml
henrytwagner 38e4022
Update pr_swift_lint.yaml
henrytwagner e638793
Update pr_swift_lint.yaml
henrytwagner 7ff37df
Update pr_swift_lint.yaml
henrytwagner 076fb90
Update pr_swift_lint.yaml
henrytwagner ef05846
Update pr_swift_lint.yaml
henrytwagner 6239776
Update .swiftlint.yaml
henrytwagner d4748ce
Update pr_swift_lint.yaml
henrytwagner b338c83
Update pr_swift_lint.yaml
henrytwagner 55841f4
Update .swiftlint.yaml
henrytwagner 0dd0c95
Update .swiftlint.yaml
henrytwagner 877ac32
Update .swiftlint.yaml
henrytwagner c6a4fe3
Update .swiftlint.yaml
henrytwagner 354900c
Update .swiftlint.yaml
henrytwagner b42118e
Update .swiftlint.yaml
henrytwagner 842117d
Update .swiftlint.yaml
henrytwagner 553e7c2
Update .swiftlint.yaml
henrytwagner fa8d8fb
Update pr_swift_lint.yaml
henrytwagner bbb754c
Update pr_swift_lint.yaml
henrytwagner 3e6d8ca
Delete empty_file.txt
henrytwagner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SwiftLint Configuration File | ||
|
||
|
||
# To be tailored to reflect projects ideal linting configuration | ||
|
||
#disabled_rules: | ||
# ERRORS IN PROJECT CURRENTLY | ||
# - cyclomatic_complexity | ||
# - identifier_name | ||
# - function_body_length | ||
# - force_cast | ||
# - force_try | ||
# - line_length | ||
# - file_length | ||
# - type_body_length | ||
# WARNINGS IN PROJECT CURRENTLY (excluding those already listed as errors) | ||
# - trailing_comma | ||
# - todo | ||
# - orphaned_doc_comment | ||
# - opening_brace | ||
# - blanket_disable_command | ||
# - for_where | ||
# - trailing_whitespace | ||
# - vertical_whitespace | ||
# - void_function_in_ternary | ||
# - empty_enum_arguments | ||
# - closure_parameter_position | ||
|
||
|
||
# change individual rule configurations | ||
identifier_name: | ||
min_length: 1 | ||
max_length: | ||
warning: 40 | ||
error: 41 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: pr_swift_lint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For here, I'm expecting that there's a pre-prepared workflow that can be subbed in for parts of this, but is looking really good all the same :) |
||
on: | ||
pull_request_target: | ||
branches: | ||
- main | ||
types: | ||
- opened | ||
|
||
jobs: | ||
swift_format_check: | ||
runs-on: macos-latest | ||
|
||
name: Run Swift Lint | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Homebrew (if macOS does not have it) | ||
run: | | ||
if ! command -v brew &>/dev/null | ||
then | ||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | ||
fi | ||
|
||
- name: Install jq | ||
run: brew install jq | ||
|
||
- name: Install SwiftLint | ||
run: brew install swiftlint | ||
|
||
- name: Run SwiftLint | ||
run: | | ||
echo " " | ||
set +e | ||
swiftlint lint --reporter json --config /Users/runner/work/Scribe-iOS/Scribe-iOS/.github/workflows/.swiftlint.yaml > swiftlint-results.json | ||
|
||
# Verify the JSON output exists and is not empty | ||
if [ ! -f swiftlint-results.json ] || [ ! -s swiftlint-results.json ]; then | ||
echo "SwiftLint did not produce output or the output is empty." | ||
exit 1 | ||
fi | ||
|
||
echo " " | ||
|
||
# Formatting and printing warnings | ||
echo "WARNINGS:" | ||
warnings_count=$(jq -r '.[] | select(.severity == "Warning") | "\(.file):\(.line): warning: (\(.rule_id)) \(.reason)"' swiftlint-results.json | wc -l) | ||
jq -r '.[] | select(.severity == "Warning") | "\(.file):\(.line): warning: (\(.rule_id)) \(.reason)"' swiftlint-results.json | ||
|
||
if [ "$warnings_count" -eq 0 ]; then | ||
echo "No Warnings" | ||
fi | ||
|
||
echo " " | ||
|
||
# Formatting and printing errors | ||
echo "ERRORS:" | ||
errors_count=$(jq -r '.[] | select(.severity == "Error") | "\(.file):\(.line): error: (\(.rule_id)) \(.reason)"' swiftlint-results.json | wc -l) | ||
jq -r '.[] | select(.severity == "Error") | "\(.file):\(.line): error: (\(.rule_id)) \(.reason)"' swiftlint-results.json | ||
|
||
if [ "$errors_count" -eq 0 ]; then | ||
echo "No Errors" | ||
fi | ||
|
||
# Printing summary of counts | ||
echo " " | ||
|
||
echo "-------- Summary --------" | ||
echo "Total Warnings: $warnings_count" | ||
echo "Total Errors: $errors_count" | ||
|
||
echo " " | ||
|
||
if [ "$errors_count" -gt 0 ]; then | ||
echo "SwiftLint found errors." # Can change message to be more reflective of what needs to be conveyed | ||
exit 2 | ||
elif [ "$warnings_count" -gt 0 ]; then | ||
echo "SwiftLint found warnings." # Can change message to be more reflective of what needs to be conveyed | ||
# exit 1 #Uncomment to enforce warnings | ||
else | ||
echo "SwiftLint found no issues." # Can change message to be more reflective of what needs to be conveyed | ||
fi | ||
shell: bash |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really appreciate you adding all the config options in here and also documenting what will cause errors and warnings once they're turned on, @henrytwagner! Will really help us organize the work for this going forward 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll likely move this file to the project root, but for the purposes of this PR it's totally fine to have it here. I figure this is where ESLint and Prettier configs normally are. Will send a commit with this along later :)