Use `all` optin rules facility for SwiftLint's own `.swiftlint.yml` (#4800)
This commit is contained in:
parent
0bd8a7aba6
commit
31510b662e
108
.swiftlint.yml
108
.swiftlint.yml
|
@ -8,76 +8,44 @@ analyzer_rules:
|
|||
- unused_declaration
|
||||
- unused_import
|
||||
opt_in_rules:
|
||||
- array_init
|
||||
- attributes
|
||||
- closure_end_indentation
|
||||
- closure_spacing
|
||||
- collection_alignment
|
||||
- contains_over_filter_count
|
||||
- contains_over_filter_is_empty
|
||||
- contains_over_first_not_nil
|
||||
- contains_over_range_nil_comparison
|
||||
- discouraged_none_name
|
||||
- discouraged_object_literal
|
||||
- empty_collection_literal
|
||||
- empty_count
|
||||
- empty_string
|
||||
- empty_xctest_method
|
||||
- enum_case_associated_values_count
|
||||
- explicit_init
|
||||
- extension_access_modifier
|
||||
- fallthrough
|
||||
- fatal_error_message
|
||||
- file_header
|
||||
- file_name
|
||||
- first_where
|
||||
- flatmap_over_map_reduce
|
||||
- identical_operands
|
||||
- joined_default_parameter
|
||||
- last_where
|
||||
- legacy_multiple
|
||||
- literal_expression_end_indentation
|
||||
- local_doc_comment
|
||||
- lower_acl_than_parent
|
||||
- modifier_order
|
||||
- nimble_operator
|
||||
- nslocalizedstring_key
|
||||
- number_separator
|
||||
- object_literal
|
||||
- operator_usage_whitespace
|
||||
- overridden_super_call
|
||||
- override_in_extension
|
||||
- pattern_matching_keywords
|
||||
- period_spacing
|
||||
- prefer_self_type_over_type_of_self
|
||||
- private_action
|
||||
- private_outlet
|
||||
- prohibited_interface_builder
|
||||
- prohibited_super_call
|
||||
- quick_discouraged_call
|
||||
- quick_discouraged_focused_test
|
||||
- quick_discouraged_pending_test
|
||||
- reduce_into
|
||||
- redundant_nil_coalescing
|
||||
- redundant_type_annotation
|
||||
- return_value_from_void_function
|
||||
- shorthand_optional_binding
|
||||
- single_test_class
|
||||
- sorted_first_last
|
||||
- sorted_imports
|
||||
- static_operator
|
||||
- strong_iboutlet
|
||||
- test_case_accessibility
|
||||
- toggle_bool
|
||||
- unavailable_function
|
||||
- unneeded_parentheses_in_closure_argument
|
||||
- unowned_variable_capture
|
||||
- untyped_error_in_catch
|
||||
- vertical_parameter_alignment_on_call
|
||||
- vertical_whitespace_closing_braces
|
||||
- vertical_whitespace_opening_braces
|
||||
- xct_specific_matcher
|
||||
- yoda_condition
|
||||
- all
|
||||
disabled_rules:
|
||||
- anonymous_argument_in_multiline_closure
|
||||
- closure_body_length
|
||||
- conditional_returns_on_newline
|
||||
- convenience_type
|
||||
- direct_return
|
||||
- discouraged_optional_collection
|
||||
- explicit_acl
|
||||
- explicit_enum_raw_value
|
||||
- explicit_top_level_acl
|
||||
- explicit_type_interface
|
||||
- file_types_order
|
||||
- force_unwrapping
|
||||
- function_default_parameter_at_end
|
||||
- implicit_return
|
||||
- implicitly_unwrapped_optional
|
||||
- indentation_width
|
||||
- missing_docs
|
||||
- multiline_arguments
|
||||
- multiline_arguments_brackets
|
||||
- multiline_function_chains
|
||||
- multiline_literal_brackets
|
||||
- multiline_parameters
|
||||
- multiline_parameters_brackets
|
||||
- no_extension_access_modifier
|
||||
- no_grouping_extension
|
||||
- no_magic_numbers
|
||||
- prefer_nimble
|
||||
- prefer_self_in_static_references
|
||||
- prefixed_toplevel_constant
|
||||
- required_deinit
|
||||
- self_binding
|
||||
- strict_fileprivate
|
||||
- switch_case_on_newline
|
||||
- trailing_closure
|
||||
- type_contents_order
|
||||
- vertical_whitespace_between_cases
|
||||
|
||||
attributes:
|
||||
always_on_line_above:
|
||||
|
|
|
@ -47,6 +47,7 @@ extension Configuration {
|
|||
Self.nestedConfigIsSelfByIdentifierLock.unlock()
|
||||
}
|
||||
|
||||
// swiftlint:disable:next discouraged_optional_boolean
|
||||
internal static func getIsNestedConfigurationSelf(forIdentifier identifier: String) -> Bool? {
|
||||
Self.nestedConfigIsSelfByIdentifierLock.lock()
|
||||
defer { Self.nestedConfigIsSelfByIdentifierLock.unlock() }
|
||||
|
|
|
@ -56,6 +56,7 @@ public extension Configuration {
|
|||
)
|
||||
}
|
||||
|
||||
// swiftlint:disable:next discouraged_optional_boolean
|
||||
internal func includesFile(atPath path: String) -> Bool? {
|
||||
guard isBuilt else { return nil }
|
||||
|
||||
|
|
|
@ -177,7 +177,8 @@ public struct Configuration {
|
|||
cachePath: String? = nil,
|
||||
ignoreParentAndChildConfigs: Bool = false,
|
||||
mockedNetworkResults: [String: String] = [:],
|
||||
useDefaultConfigOnFailure: Bool? = nil
|
||||
useDefaultConfigOnFailure: Bool? = nil // swiftlint:disable:this discouraged_optional_boolean
|
||||
|
||||
) {
|
||||
// Handle mocked network results if needed
|
||||
Self.FileGraph.FilePath.mockedNetworkResults = mockedNetworkResults
|
||||
|
|
|
@ -4,5 +4,5 @@ public struct Version {
|
|||
public let value: String
|
||||
|
||||
/// The current SwiftLint version.
|
||||
public static let current = Version(value: "0.50.3")
|
||||
public static let current = Self(value: "0.50.3")
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ private extension String {
|
|||
}
|
||||
|
||||
private extension Bool {
|
||||
// swiftlint:disable:next discouraged_optional_boolean
|
||||
static func constructUsingOnlyTrueAndFalse(from scalar: Node.Scalar) -> Bool? {
|
||||
switch scalar.string.lowercased() {
|
||||
case "true":
|
||||
|
|
|
@ -49,6 +49,7 @@ struct MissingDocsRule: OptInRule, ConfigurationProviderRule {
|
|||
}
|
||||
|
||||
typealias ConfigurationType = MissingDocsRuleConfiguration
|
||||
|
||||
var configuration: MissingDocsRuleConfiguration
|
||||
|
||||
static let description = RuleDescription(
|
||||
|
|
|
@ -30,6 +30,7 @@ struct Benchmark {
|
|||
}
|
||||
let entriesKeyValues: [(String, Double)] = entriesDict.sorted { $0.1 < $1.1 }
|
||||
let lines: [String] = entriesKeyValues.map { id, time -> String in
|
||||
// swiftlint:disable:next legacy_objc_type
|
||||
return "\(numberFormatter.string(from: NSNumber(value: time))!): \(id)"
|
||||
}
|
||||
let string: String = lines.joined(separator: "\n") + "\n"
|
||||
|
|
|
@ -20,11 +20,12 @@ struct LintOrAnalyzeArguments: ParsableArguments {
|
|||
var config = [String]()
|
||||
@Flag(name: [.long, .customLong("autocorrect")], help: "Correct violations whenever possible.")
|
||||
var fix = false
|
||||
|
||||
@Flag(help: """
|
||||
Should reformat the Swift files using the same mechanism used by Xcode (via SourceKit).
|
||||
Only applied with `--fix`/`--autocorrect`.
|
||||
""")
|
||||
var format = false
|
||||
var format = false // swiftlint:disable:this let_var_whitespace - the multiline @Flag breaks us
|
||||
@Flag(help: "Use an alternative algorithm to exclude paths for `excluded`, which may be faster in some cases.")
|
||||
var useAlternativeExcluding = false
|
||||
@Flag(help: "Read SCRIPT_INPUT_FILE* environment variables as files.")
|
||||
|
|
|
@ -123,7 +123,7 @@ struct LintableFilesVisitor {
|
|||
compilerInvocations = try loadCompilerInvocations(options)
|
||||
}
|
||||
|
||||
return LintableFilesVisitor(
|
||||
return Self(
|
||||
paths: options.paths, action: options.verb.bridge().capitalized,
|
||||
useSTDIN: options.useSTDIN, quiet: options.quiet,
|
||||
showProgressBar: options.progress,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#if canImport(os)
|
||||
import os.signpost
|
||||
|
||||
private let timelineLog = OSLog(subsystem: "io.realm.swiftlint", category: "Timeline")
|
||||
private let fileLog = OSLog(subsystem: "io.realm.swiftlint", category: "File")
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
@testable import SwiftLintFramework
|
||||
import XCTest
|
||||
|
||||
// swiftlint:disable:next balanced_xctest_lifecycle
|
||||
class ExpiringTodoRuleTests: XCTestCase {
|
||||
private lazy var config: Configuration = makeConfiguration()
|
||||
|
||||
|
@ -162,6 +163,7 @@ class ExpiringTodoRuleTests: XCTestCase {
|
|||
|
||||
let daysToAdvance: Int
|
||||
|
||||
// swiftlint:disable optional_enum_case_matching
|
||||
switch status {
|
||||
case .approachingExpiry?:
|
||||
daysToAdvance = ruleConfiguration.approachingExpiryThreshold
|
||||
|
@ -170,6 +172,7 @@ class ExpiringTodoRuleTests: XCTestCase {
|
|||
case .badFormatting?, nil:
|
||||
daysToAdvance = ruleConfiguration.approachingExpiryThreshold + 1
|
||||
}
|
||||
// swiftlint:enable optional_enum_case_matching
|
||||
|
||||
return Calendar.current
|
||||
.date(
|
||||
|
|
|
@ -12,6 +12,7 @@ class ExtendedNSStringTests: XCTestCase {
|
|||
"// do something\n" + // 16 characters
|
||||
"}\n" +
|
||||
"}"
|
||||
// swiftlint:disable:next legacy_objc_type
|
||||
let string = NSString(string: contents)
|
||||
// A character placed on 80 offset indicates a white-space before 'do' at 5th line.
|
||||
if let lineAndCharacter = StringView(string).lineAndCharacter(forCharacterOffset: 80) {
|
||||
|
|
|
@ -214,9 +214,11 @@ class IndentationWidthRuleTests: XCTestCase {
|
|||
private func countViolations(
|
||||
in example: Example,
|
||||
indentationWidth: Int? = nil,
|
||||
// swiftlint:disable discouraged_optional_boolean
|
||||
includeComments: Bool? = nil,
|
||||
includeCompilerDirectives: Bool? = nil,
|
||||
includeMultilineStrings: Bool? = nil,
|
||||
// swiftlint:enable discouraged_optional_boolean
|
||||
file: StaticString = #file,
|
||||
line: UInt = #line
|
||||
) -> Int {
|
||||
|
@ -246,9 +248,11 @@ class IndentationWidthRuleTests: XCTestCase {
|
|||
in string: String,
|
||||
equals expectedCount: Int,
|
||||
indentationWidth: Int? = nil,
|
||||
// swiftlint:disable discouraged_optional_boolean
|
||||
includeComments: Bool? = nil,
|
||||
includeCompilerDirectives: Bool? = nil,
|
||||
includeMultilineStrings: Bool? = nil,
|
||||
// swiftlint:enable discouraged_optional_boolean
|
||||
file: StaticString = #file,
|
||||
line: UInt = #line
|
||||
) {
|
||||
|
@ -271,9 +275,11 @@ class IndentationWidthRuleTests: XCTestCase {
|
|||
private func assertNoViolation(
|
||||
in string: String,
|
||||
indentationWidth: Int? = nil,
|
||||
// swiftlint:disable discouraged_optional_boolean
|
||||
includeComments: Bool? = nil,
|
||||
includeCompilerDirectives: Bool? = nil,
|
||||
includeMultilineStrings: Bool? = nil,
|
||||
// swiftlint:enable discouraged_optional_boolean
|
||||
file: StaticString = #file,
|
||||
line: UInt = #line
|
||||
) {
|
||||
|
@ -292,9 +298,11 @@ class IndentationWidthRuleTests: XCTestCase {
|
|||
private func assert1Violation(
|
||||
in string: String,
|
||||
indentationWidth: Int? = nil,
|
||||
// swiftlint:disable discouraged_optional_boolean
|
||||
includeComments: Bool? = nil,
|
||||
includeCompilerDirectives: Bool? = nil,
|
||||
includeMultilineStrings: Bool? = nil,
|
||||
// swiftlint:enable discouraged_optional_boolean
|
||||
file: StaticString = #file,
|
||||
line: UInt = #line
|
||||
) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
@testable import SwiftLintFramework
|
||||
import XCTest
|
||||
|
||||
// swiftlint:disable:next balanced_xctest_lifecycle
|
||||
class RequiredEnumCaseRuleConfigurationTests: XCTestCase {
|
||||
private typealias RuleConfiguration = RequiredEnumCaseRuleConfiguration
|
||||
private typealias RequiredCase = RuleConfiguration.RequiredCase
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
@testable import SwiftLintFramework
|
||||
import XCTest
|
||||
|
||||
// swiftlint:disable:next balanced_xctest_lifecycle
|
||||
class SwiftLintFileTests: XCTestCase {
|
||||
private let tempFile = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
|
||||
|
|
Loading…
Reference in New Issue