Skip to content

Commit

Permalink
SwiftLint plugin (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx authored Dec 18, 2023
1 parent 861b8a7 commit d07e18b
Show file tree
Hide file tree
Showing 396 changed files with 3,028 additions and 2,791 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: SwiftLint
uses: docker://norionomura/swiftlint:0.53.0
uses: docker://norionomura/swiftlint:0.54.0_swift-5.9.0
with:
args: swiftlint --reporter github-actions-logging --strict

Expand Down
80 changes: 70 additions & 10 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,82 @@
allow_zero_lintable_files: true

disabled_rules:
- trailing_whitespace
- no_space_in_method_call
- multiple_closures_with_trailing_closure
- block_based_kvo
- compiler_protocol_init
- unused_setter_value
- line_length
- type_name
- implicit_getter
- function_parameter_count
- trailing_comma
- nesting
- opening_brace

opt_in_rules:
- file_header
- explicit_init

custom_rules:
explicit_non_final_class:
included: ".*\\.swift"
name: "Implicitly non-final class"
regex: "^\\s*(class) (?!func|var)"
capture_group: 0
match_kinds:
- keyword
message: "Classes should be `final` by default, use explicit `internal` or `public` for non-final classes."
severity: error
enforce_os_log_wrapper:
included: ".*\\.swift"
name: "Use `import Common` for os_log instead of `import os.log`"
regex: "^(import (?:os\\.log|os|OSLog))$"
capture_group: 0
message: "os_log wrapper ensures log args are @autoclosures (computed when needed) and to be able to use String Interpolation."
severity: error

line_length:
warning: 150
ignores_comments: true
analyzer_rules: # Rules run by `swiftlint analyze`
- explicit_self

# Rule Config
identifier_name:
min_length: 1
max_length: 1000
file_length:
warning: 1200
error: 1200
type_body_length:
warning: 500
error: 500
large_tuple:
warning: 4
error: 5
file_header:
required_pattern: |
\/\/
\/\/ SWIFTLINT_CURRENT_FILENAME
\/\/
\/\/ Copyright © \d{4} DuckDuckGo\. All rights reserved\.
\/\/
\/\/ Licensed under the Apache License, Version 2\.0 \(the \"License\"\);
\/\/ you may not use this file except in compliance with the License\.
\/\/ You may obtain a copy of the License at
\/\/
\/\/ http:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0
\/\/
\/\/ Unless required by applicable law or agreed to in writing, software
\/\/ distributed under the License is distributed on an \"AS IS\" BASIS,
\/\/ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
\/\/ See the License for the specific language governing permissions and
\/\/ limitations under the License\.
\/\/
type_name:
min_length: 3
max_length:
warning: 80
error: 100

# General Config
excluded:
- Package.swift
- .build
- scripts/
- Sources/RemoteMessaging/Model/AnyDecodable.swift
- Sources/Common/Concurrency/AsyncStream.swift

Loading

0 comments on commit d07e18b

Please sign in to comment.