From eed56ce3f54cbe060e54cd9357e5cfa6cbf89bb9 Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes Date: Mon, 6 Nov 2017 11:21:39 +0000 Subject: [PATCH 001/119] Prepare for initial release --- README.md | 2 +- build.sbt | 14 ++++++++++++-- src/main/resources/docs/patterns.json | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0af3f87..60a3bb5 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![Build Status](https://circleci.com/gh/fnxpt/codacy-swiftlint.svg?style=shield&circle-token=:circle-token)](https://circleci.com/gh/fnxpt/codacy-swiftlint) +[![Build Status](https://circleci.com/gh/codacy/codacy-swiftlint.svg?style=shield&circle-token=:circle-token)](https://circleci.com/gh/codacy/codacy-swiftlint) # Codacy Swiftlint diff --git a/build.sbt b/build.sbt index e2e92d7..01dfd54 100755 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,6 @@ import com.typesafe.sbt.packager.docker.{Cmd, ExecCmd} +import scala.util.parsing.json.JSON +import scala.io.Source name := """codacy-swiftlint""" @@ -26,7 +28,15 @@ version in Docker := "1.0.0-SNAPSHOT" organization := "com.codacy" -val swiftlintVersion = "0.23.1" +lazy val toolVersion = SettingKey[String]("Retrieve the version of the underlying tool from patterns.json") + +toolVersion := { + val jsonFile = (resourceDirectory in Compile).value / "docs" / "patterns.json" + val toolMap = JSON.parseFull(Source.fromFile(jsonFile).getLines().mkString) + .getOrElse(throw new Exception("patterns.json is not a valid json")) + .asInstanceOf[Map[String, String]] + toolMap.getOrElse[String]("version", throw new Exception("Failed to retrieve 'version' from patterns.json")) +} val installAll = s"""apt-get update && @@ -50,7 +60,7 @@ daemonUser in Docker := dockerUser daemonGroup in Docker := dockerGroup -dockerBaseImage := "mkujalowicz/swiftlint:0.23.0" +dockerBaseImage := s"mkujalowicz/swiftlint:${toolVersion.value}" dockerCommands := dockerCommands.value.flatMap { case cmd@Cmd("WORKDIR", _) => List(cmd, diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index 4043fc8..d7a2ede 100755 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1,5 +1,6 @@ { "name": "swiftlint", + "version": "0.23.0", "patterns": [ { "patternId": "attributes", From 71b780fe9bff4dca541f9e00c94a13fd4260e633 Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes Date: Mon, 6 Nov 2017 16:28:02 +0000 Subject: [PATCH 002/119] Testing --- .../scala/codacy/swiftlint/SwiftLint.scala | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index 3c50f0b..a423cad 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -1,5 +1,6 @@ package codacy.swiftlint +import java.io.File import java.nio.file.{Path, Paths} import codacy.docker.api._ @@ -66,6 +67,8 @@ object SwiftLint extends Tool { |message: ${e.getMessage} |stdout: ${resultFromTool.stdout.mkString(Properties.lineSeparator)} |stderr: ${resultFromTool.stderr.mkString(Properties.lineSeparator)} + |configFile: + |${cfgOpt.fold("")(p => scala.io.Source.fromFile(new File(p)).getLines().mkString("\n"))} """.stripMargin Failure(new Exception(msg)) } @@ -105,18 +108,17 @@ object SwiftLint extends Tool { * ] */ - Try((outputJson).as[List[SwiftLintFile]]).map { violations => - violations.flatMap { - case violation => - List( - Result.Issue( - Source.File(violation.file), - Result.Message(violation.reason), - Pattern.Id(violation.rule_id), - Source.Line(violation.line) - ) - ) - } - } - } + Try(outputJson.as[List[SwiftLintFile]]).map { violations => + violations.flatMap { violation => + List( + Result.Issue( + Source.File(violation.file), + Result.Message(violation.reason), + Pattern.Id(violation.rule_id), + Source.Line(violation.line) + ) + ) + } + } + } } From 895ed75fde6942d911bc657d9c3d6e20aafd7bb5 Mon Sep 17 00:00:00 2001 From: Marlon Tojal Date: Tue, 20 Mar 2018 10:26:29 +0000 Subject: [PATCH 003/119] attempt to fix build --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index e2e92d7..c24acbe 100755 --- a/build.sbt +++ b/build.sbt @@ -26,7 +26,7 @@ version in Docker := "1.0.0-SNAPSHOT" organization := "com.codacy" -val swiftlintVersion = "0.23.1" +val swiftlintVersion = "0.25.0" val installAll = s"""apt-get update && @@ -50,7 +50,7 @@ daemonUser in Docker := dockerUser daemonGroup in Docker := dockerGroup -dockerBaseImage := "mkujalowicz/swiftlint:0.23.0" +dockerBaseImage := "norionomura/swiftlint" dockerCommands := dockerCommands.value.flatMap { case cmd@Cmd("WORKDIR", _) => List(cmd, From fd9361bcb1456e00791e9c0856a955232eee6a2b Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 20 Mar 2018 11:01:19 +0000 Subject: [PATCH 004/119] fix explicit_type_interface file --- .../docs/tests/explicit_type_interface.swift | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/resources/docs/tests/explicit_type_interface.swift b/src/main/resources/docs/tests/explicit_type_interface.swift index be60069..f9e4342 100644 --- a/src/main/resources/docs/tests/explicit_type_interface.swift +++ b/src/main/resources/docs/tests/explicit_type_interface.swift @@ -5,23 +5,23 @@ //#Issue: {"severity": "Info", "line": 21, "patternId": "explicit_type_interface"} //#Issue: {"severity": "Info", "line": 26, "patternId": "explicit_type_interface"} - class Foo { - var myVar = 0 +class Foo { + var myVar = 0 + +} - } +class Foo { + let mylet = 0 + +} - class Foo { - let mylet = 0 - } +class Foo { + static var myStaticVar = 0 +} - class Foo { - static var myStaticVar = 0 - } - - - class Foo { - class var myClassVar = 0 - } +class Foo { + class var myClassVar = 0 +} From 86ec3cc70a7f5652ef1f278bb4273618d58a118c Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 20 Mar 2018 12:02:44 +0000 Subject: [PATCH 005/119] update tool version --- src/main/resources/docs/patterns.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index d7a2ede..98f9acc 100755 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1,6 +1,6 @@ { "name": "swiftlint", - "version": "0.23.0", + "version": "0.25.0", "patterns": [ { "patternId": "attributes", From d9c6cf22cc5caaffe686cf9dd57f78acb9393501 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 20 Mar 2018 14:42:49 +0000 Subject: [PATCH 006/119] add missing rules --- .../docs/description/description.json | 210 +++++++++ src/main/resources/docs/patterns.json | 175 +++++++ .../resources/docs/tests/array_init.swift | 48 ++ .../docs/tests/block_based_kvo.swift | 19 + .../tests/contains_over_first_not_nil.swift | 32 ++ .../docs/tests/discouraged_direct_init.swift | 44 ++ .../tests/discouraged_object_literal.swift | 11 + .../tests/discouraged_optional_boolean.swift | 445 ++++++++++++++++++ .../resources/docs/tests/explicit_acl.swift | 27 ++ .../docs/tests/explicit_enum_raw_value.swift | 38 ++ .../resources/docs/tests/fallthrough.swift | 12 + .../resources/docs/tests/is_disjoint.swift | 11 + .../docs/tests/joined_default_parameter.swift | 12 + .../docs/tests/let_var_whitespace.swift | 42 ++ .../literal_expression_end_indentation.swift | 25 + .../docs/tests/multiline_arguments.swift | 29 ++ ...tiple_closures_with_trailing_closure.swift | 15 + .../docs/tests/no_grouping_extension.swift | 26 + .../docs/tests/override_in_extension.swift | 16 + .../tests/pattern_matching_keywords.swift | 43 ++ .../tests/prefixed_toplevel_constant.swift | 38 ++ .../resources/docs/tests/private_action.swift | 78 +++ .../docs/tests/private_over_fileprivate.swift | 12 + .../docs/tests/quick_discouraged_call.swift | 161 +++++++ .../quick_discouraged_focused_test.swift | 65 +++ .../quick_discouraged_pending_test.swift | 81 ++++ .../docs/tests/required_enum_case.swift | 23 + .../docs/tests/single_test_class.swift | 48 ++ .../docs/tests/sorted_first_last.swift | 66 +++ .../docs/tests/strict_fileprivate.swift | 42 ++ .../tests/superfluous_disable_command.swift | 1 + .../docs/tests/switch_case_alignment.swift | 34 ++ .../docs/tests/trailing_closure.swift | 22 + .../docs/tests/unneeded_break_in_switch.swift | 34 ++ ...eded_parentheses_in_closure_argument.swift | 25 + .../docs/tests/xctfail_message.swift | 14 + .../resources/docs/tests/yoda_condition.swift | 33 ++ 37 files changed, 2057 insertions(+) create mode 100644 src/main/resources/docs/tests/array_init.swift create mode 100644 src/main/resources/docs/tests/block_based_kvo.swift create mode 100644 src/main/resources/docs/tests/contains_over_first_not_nil.swift create mode 100644 src/main/resources/docs/tests/discouraged_direct_init.swift create mode 100644 src/main/resources/docs/tests/discouraged_object_literal.swift create mode 100644 src/main/resources/docs/tests/discouraged_optional_boolean.swift create mode 100644 src/main/resources/docs/tests/explicit_acl.swift create mode 100644 src/main/resources/docs/tests/explicit_enum_raw_value.swift create mode 100644 src/main/resources/docs/tests/fallthrough.swift create mode 100644 src/main/resources/docs/tests/is_disjoint.swift create mode 100644 src/main/resources/docs/tests/joined_default_parameter.swift create mode 100644 src/main/resources/docs/tests/let_var_whitespace.swift create mode 100644 src/main/resources/docs/tests/literal_expression_end_indentation.swift create mode 100644 src/main/resources/docs/tests/multiline_arguments.swift create mode 100644 src/main/resources/docs/tests/multiple_closures_with_trailing_closure.swift create mode 100644 src/main/resources/docs/tests/no_grouping_extension.swift create mode 100644 src/main/resources/docs/tests/override_in_extension.swift create mode 100644 src/main/resources/docs/tests/pattern_matching_keywords.swift create mode 100644 src/main/resources/docs/tests/prefixed_toplevel_constant.swift create mode 100644 src/main/resources/docs/tests/private_action.swift create mode 100644 src/main/resources/docs/tests/private_over_fileprivate.swift create mode 100644 src/main/resources/docs/tests/quick_discouraged_call.swift create mode 100644 src/main/resources/docs/tests/quick_discouraged_focused_test.swift create mode 100644 src/main/resources/docs/tests/quick_discouraged_pending_test.swift create mode 100644 src/main/resources/docs/tests/required_enum_case.swift create mode 100644 src/main/resources/docs/tests/single_test_class.swift create mode 100644 src/main/resources/docs/tests/sorted_first_last.swift create mode 100644 src/main/resources/docs/tests/strict_fileprivate.swift create mode 100644 src/main/resources/docs/tests/superfluous_disable_command.swift create mode 100644 src/main/resources/docs/tests/switch_case_alignment.swift create mode 100644 src/main/resources/docs/tests/trailing_closure.swift create mode 100644 src/main/resources/docs/tests/unneeded_break_in_switch.swift create mode 100644 src/main/resources/docs/tests/unneeded_parentheses_in_closure_argument.swift create mode 100644 src/main/resources/docs/tests/xctfail_message.swift create mode 100644 src/main/resources/docs/tests/yoda_condition.swift diff --git a/src/main/resources/docs/description/description.json b/src/main/resources/docs/description/description.json index dd412f5..879988d 100755 --- a/src/main/resources/docs/description/description.json +++ b/src/main/resources/docs/description/description.json @@ -526,5 +526,215 @@ "title": "Weak Delegate", "timeToFix": 5, "description": "Delegates should be weak to avoid reference cycles." + }, + { + "patternId": "array_init", + "title": "Array Init", + "timeToFix": 5, + "description": "Prefer using Array(seq) than seq.map { $0 } to convert a sequence into an Array." + }, + { + "patternId": "block_based_kvo", + "title": "Block Based KVO", + "timeToFix": 5, + "description": "Prefer the new block based KVO API with keypaths when using Swift 3.2 or later." + }, + { + "patternId": "contains_over_first_not_nil", + "title": "Contains over first not nil", + "timeToFix": 5, + "description": "Prefer 'contains' over 'first(where:) != nil'" + }, + { + "patternId": "discouraged_direct_init", + "title": "Discouraged Direct Initialization", + "timeToFix": 5, + "description": "Discouraged direct initialization of types that can be harmful." + }, + { + "patternId": "discouraged_object_literal", + "title": "Discouraged Object Literal", + "timeToFix": 5, + "description": "Prefer initializers over object literals." + }, + { + "patternId": "discouraged_optional_boolean", + "title": "Discouraged Optional Boolean", + "timeToFix": 5, + "description": "Prefer non-optional booleans over optional booleans." + }, + { + "patternId": "explicit_acl", + "title": "Explicit ACL", + "timeToFix": 5, + "description": "All declarations should specify Access Control Level keywords explicitly." + }, + { + "patternId": "explicit_enum_raw_value", + "title": "Explicit Enum Raw Value", + "timeToFix": 5, + "description": "Enums should be explicitly assigned their raw values." + }, + { + "patternId": "fallthrough", + "title": "Fallthrough", + "timeToFix": 5, + "description": "Fallthrough should be avoided." + }, + { + "patternId": "is_disjoint", + "title": "Is Disjoint", + "timeToFix": 5, + "description": "Prefer using 'Set.isDisjoint(with:)' over 'Set.intersection(_:).isEmpty'." + }, + { + "patternId": "joined_default_parameter", + "title": "Joined Default Parameter", + "timeToFix": 5, + "description": "Discouraged explicit usage of the default separator." + }, + { + "patternId": "let_var_whitespace", + "title": "Variable Declaration Whitespace", + "timeToFix": 5, + "description": "Let and var should be separated from other statements by a blank line." + }, + { + "patternId": "literal_expression_end_indentation", + "title": "Literal Expression End Indentation", + "timeToFix": 5, + "description": "Array and dictionary literal end should have the same indentation as the line that started it." + }, + { + "patternId": "multiline_arguments", + "title": "Multiline Arguments", + "timeToFix": 5, + "description": "Arguments should be either on the same line, or one per line." + }, + { + "patternId": "multiple_closures_with_trailing_closure", + "title": "Multiple Closures with Trailing Closure", + "timeToFix": 5, + "description": "Trailing closure syntax should not be used when passing more than one closure argument." + }, + { + "patternId": "no_grouping_extension", + "title": "No Grouping Extension", + "timeToFix": 5, + "description": "Extensions shouldn't be used to group code within the same source file." + }, + { + "patternId": "override_in_extension", + "title": "Override in Extension", + "timeToFix": 5, + "description": "Extensions shouldn't override declarations." + }, + { + "patternId": "pattern_matching_keywords", + "title": "Pattern Matching Keywords", + "timeToFix": 5, + "description": "Combine multiple pattern matching bindings by moving keywords out of tuples." + }, + { + "patternId": "prefixed_toplevel_constant", + "title": "Prefixed Top-Level Constant", + "timeToFix": 5, + "description": "Top-level constants should be prefixed by 'k'." + }, + { + "patternId": "private_action", + "title": "Private Actions", + "timeToFix": 5, + "description": "IBActions should be private." + }, + { + "patternId": "private_over_fileprivate", + "title": "Private over fileprivate", + "timeToFix": 5, + "description": "Prefer 'private' over 'fileprivate' declarations." + }, + { + "patternId": "quick_discouraged_call", + "title": "Quick Discouraged Call", + "timeToFix": 5, + "description": "Discouraged call inside 'describe' and/or 'context' block." + }, + { + "patternId": "quick_discouraged_focused_test", + "title": "Quick Discouraged Focused Test", + "timeToFix": 5, + "description": "Discouraged focused test. Other tests won't run while this one is focused." + }, + { + "patternId": "quick_discouraged_pending_test", + "title": "Quick Discouraged Pending Test", + "timeToFix": 5, + "description": "Discouraged pending test. This test won't run while it's marked as pending." + }, + { + "patternId": "required_enum_case", + "title": "Required Enum Case", + "timeToFix": 5, + "description": "Enums conforming to a specified protocol must implement a specific case(s)." + }, + { + "patternId": "single_test_class", + "title": "Single Test Class", + "timeToFix": 5, + "description": "Test files should contain a single QuickSpec or XCTestCase class." + }, + { + "patternId": "sorted_first_last", + "title": "Min or Max over Sorted First or Last", + "timeToFix": 5, + "description": "Prefer using 'min()' or 'max()' over 'sorted().first' or 'sorted().last'" + }, + { + "patternId": "strict_fileprivate", + "title": "Strict fileprivate", + "timeToFix": 5, + "description": "'fileprivate' should be avoided." + }, + { + "patternId": "superfluous_disable_command", + "title": "Superfluous Disable Command", + "timeToFix": 5, + "description": "SwiftLint 'disable' commands are superfluous when the disabled rule would not have triggered a violation in the disabled region." + }, + { + "patternId": "switch_case_alignment", + "title": "Switch and Case Statement Alignment", + "timeToFix": 5, + "description": "Case statements should vertically align with the enclosing switch statement." + }, + { + "patternId": "trailing_closure", + "title": "Trailing Closure", + "timeToFix": 5, + "description": "Trailing closure syntax should be used whenever possible." + }, + { + "patternId": "unneeded_break_in_switch", + "title": "Unneeded Break in Switch", + "timeToFix": 5, + "description": "Avoid using unneeded break statements." + }, + { + "patternId": "unneeded_parentheses_in_closure_argument", + "title": "Unneeded Parentheses in Closure Argument", + "timeToFix": 5, + "description": "Parentheses are not needed when declaring closure arguments." + }, + { + "patternId": "xctfail_message", + "title": "XCTFail Message", + "timeToFix": 5, + "description": "An XCTFail call should include a description of the assertion." + }, + { + "patternId": "yoda_condition", + "title": "Yoda condition rule", + "timeToFix": 5, + "description": "The variable should be placed on the left, the constant on the right of a comparison operator." } ] diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index 98f9acc..c3428c9 100755 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -441,6 +441,181 @@ "patternId": "weak_delegate", "level": "Info", "category": "CodeStyle" + }, + { + "patternId": "array_init", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "block_based_kvo", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "contains_over_first_not_nil", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "discouraged_direct_init", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "discouraged_object_literal", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "discouraged_optional_boolean", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "explicit_acl", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "explicit_enum_raw_value", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "fallthrough", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "is_disjoint", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "joined_default_parameter", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "let_var_whitespace", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "literal_expression_end_indentation", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "multiline_arguments", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "multiple_closures_with_trailing_closure", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "no_grouping_extension", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "override_in_extension", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "pattern_matching_keywords", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "prefixed_toplevel_constant", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "private_action", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "private_over_fileprivate", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "quick_discouraged_call", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "quick_discouraged_focused_test", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "quick_discouraged_pending_test", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "required_enum_case", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "single_test_class", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "sorted_first_last", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "strict_fileprivate", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "superfluous_disable_command", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "switch_case_alignment", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "trailing_closure", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "unneeded_break_in_switch", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "unneeded_parentheses_in_closure_argument", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "xctfail_message", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "yoda_condition", + "level": "Info", + "category": "CodeStyle" } ] } diff --git a/src/main/resources/docs/tests/array_init.swift b/src/main/resources/docs/tests/array_init.swift new file mode 100644 index 0000000..edcb4cf --- /dev/null +++ b/src/main/resources/docs/tests/array_init.swift @@ -0,0 +1,48 @@ +//#Patterns: array_init + +//#Issue: {"severity": "Info", "line": 12, "patternId": "array_init"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "array_init"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "array_init"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "array_init"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "array_init"} +//#Issue: {"severity": "Info", "line": 36, "patternId": "array_init"} +//#Issue: {"severity": "Info", "line": 42, "patternId": "array_init"} +//#Issue: {"severity": "Info", "line": 48, "patternId": "array_init"} + +foo.map({ $0 }) + + + +foo.map { $0 } + + + +foo.map { return $0 } + + + +foo.map { elem in + elem +} + + + +foo.map { elem in + return elem +} + + + +foo.map { (elem: String) in + elem +} + + + +foo.map { elem -> String in + elem +} + + + +foo.map { $0 /* a comment */ } diff --git a/src/main/resources/docs/tests/block_based_kvo.swift b/src/main/resources/docs/tests/block_based_kvo.swift new file mode 100644 index 0000000..364719b --- /dev/null +++ b/src/main/resources/docs/tests/block_based_kvo.swift @@ -0,0 +1,19 @@ +//#Patterns: block_based_kvo + +//#Issue: {"severity": "Info", "line": 9, "patternId": "block_based_kvo"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "block_based_kvo"} + + + +class Foo: NSObject { + override func observeValue(forKeyPath keyPath: String?, of object: Any?, + change: [NSKeyValueChangeKey : Any]?, + context: UnsafeMutableRawPointer?) {} +} + + +class Foo: NSObject { + override func observeValue(forKeyPath keyPath: String?, of object: Any?, + change: Dictionary?, + context: UnsafeMutableRawPointer?) {} +} diff --git a/src/main/resources/docs/tests/contains_over_first_not_nil.swift b/src/main/resources/docs/tests/contains_over_first_not_nil.swift new file mode 100644 index 0000000..d5532b5 --- /dev/null +++ b/src/main/resources/docs/tests/contains_over_first_not_nil.swift @@ -0,0 +1,32 @@ +//#Patterns: contains_over_first_not_nil + +//#Issue: {"severity": "Info", "line": 12, "patternId": "contains_over_first_not_nil"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "contains_over_first_not_nil"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "contains_over_first_not_nil"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "contains_over_first_not_nil"} +//#Issue: {"severity": "Info", "line": 28, "patternId": "contains_over_first_not_nil"} +//#Issue: {"severity": "Info", "line": 32, "patternId": "contains_over_first_not_nil"} + + + +myList.first { $0 % 2 == 0 } != nil + + + +myList.first(where: { $0 % 2 == 0 }) != nil + + + +myList.map { $0 + 1 }.first(where: { $0 % 2 == 0 }) != nil + + + +myList.first(where: someFunction) != nil + + + +myList.map { $0 + 1 }.first { $0 % 2 == 0 } != nil + + + +(myList.first { $0 % 2 == 0 }) != nil diff --git a/src/main/resources/docs/tests/discouraged_direct_init.swift b/src/main/resources/docs/tests/discouraged_direct_init.swift new file mode 100644 index 0000000..ff85c95 --- /dev/null +++ b/src/main/resources/docs/tests/discouraged_direct_init.swift @@ -0,0 +1,44 @@ +//#Patterns: discouraged_direct_init + +//#Issue: {"severity": "Info", "line": 17, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 32, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 35, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 38, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 41, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 44, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 44, "patternId": "discouraged_direct_init"} + + +UIDevice() + + +Bundle() + + +let foo = UIDevice() + + +let foo = Bundle() + + +let foo = bar(bundle: Bundle(), device: UIDevice()) + + +UIDevice.init() + + +Bundle.init() + + +let foo = UIDevice.init() + + +let foo = Bundle.init() + + +let foo = bar(bundle: Bundle.init(), device: UIDevice.init()) diff --git a/src/main/resources/docs/tests/discouraged_object_literal.swift b/src/main/resources/docs/tests/discouraged_object_literal.swift new file mode 100644 index 0000000..17fdc25 --- /dev/null +++ b/src/main/resources/docs/tests/discouraged_object_literal.swift @@ -0,0 +1,11 @@ +//#Patterns: discouraged_object_literal + +//#Issue: {"severity": "Info", "line": 8, "patternId": "discouraged_object_literal"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "discouraged_object_literal"} + + + +let image = #imageLiteral(resourceName: "image.jpg") + + +let color = #colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1) diff --git a/src/main/resources/docs/tests/discouraged_optional_boolean.swift b/src/main/resources/docs/tests/discouraged_optional_boolean.swift new file mode 100644 index 0000000..445e69c --- /dev/null +++ b/src/main/resources/docs/tests/discouraged_optional_boolean.swift @@ -0,0 +1,445 @@ +//#Patterns: discouraged_optional_boolean + +//#Issue: {"severity": "Info", "line": 86, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 89, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 92, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 95, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 98, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 101, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 104, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 107, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 110, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 113, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 116, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 119, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 122, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 125, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 128, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 131, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 134, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 137, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 140, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 143, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 146, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 149, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 152, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 155, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 159, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 164, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 169, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 174, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 179, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 184, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 189, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 194, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 199, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 204, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 209, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 214, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 219, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 224, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 229, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 234, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 239, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 244, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 249, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 254, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 259, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 264, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 269, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 274, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 279, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 284, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 289, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 294, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 299, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 304, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 309, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 314, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 319, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 324, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 329, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 334, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 339, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 344, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 349, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 354, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 359, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 364, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 369, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 374, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 379, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 384, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 389, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 394, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 399, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 404, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 409, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 414, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 419, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 424, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 429, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 434, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 439, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Info", "line": 444, "patternId": "discouraged_optional_boolean"} + +var foo: Bool? + + +var foo: [String: Bool?] + + +var foo: [Bool?] + + +let foo: Bool? = nil + + +let foo: [String: Bool?] = [:] + + +let foo: [Bool?] = [] + + +let foo = Optional.some(false) + + +let foo = Optional.some(true) + + +var foo: Bool? { return nil } + + +let foo: Bool? { return nil }() + + +func foo() -> Bool? {} + + +func foo() -> [String: Bool?] {} + + +func foo() -> [Bool?] {} + + +static func foo() -> Bool? {} + + +static func foo() -> [String: Bool?] {} + + +static func foo() -> [Bool?] {} + + +func foo() -> (Bool?) -> String {} + + +func foo() -> ([Int]) -> Bool? {} + + +func foo(input: Bool?) {} + + +func foo(input: [String: Bool?]) {} + + +func foo(input: [Bool?]) {} + + +static func foo(input: Bool?) {} + + +static func foo(input: [String: Bool?]) {} + + +static func foo(input: [Bool?]) {} + + +class Foo { + var foo: Bool? +} + + +class Foo { + var foo: [String: Bool?] +} + + +class Foo { + let foo: Bool? = nil +} + + +class Foo { + let foo: [String: Bool?] = [:] +} + + +class Foo { + let foo: [Bool?] = [] +} + + +struct Foo { + var foo: Bool? +} + + +struct Foo { + var foo: [String: Bool?] +} + + +struct Foo { + let foo: Bool? = nil +} + + +struct Foo { + let foo: [String: Bool?] = [:] +} + + +struct Foo { + let foo: [Bool?] = [] +} + + +class Foo { + var foo: Bool? { return nil } +} + + +class Foo { + let foo: Bool? { return nil }() +} + + +struct Foo { + var foo: Bool? { return nil } +} + + +struct Foo { + let foo: Bool? { return nil }() +} + + +enum Foo { + var foo: Bool? { return nil } +} + + +enum Foo { + let foo: Bool? { return nil }() +} + + +class Foo { + func foo() -> Bool? {} +} + + +class Foo { + func foo() -> [String: Bool?] {} +} + + +class Foo { + func foo() -> [Bool?] {} +} + + +class Foo { + static func foo() -> Bool? {} +} + + +class Foo { + static func foo() -> [String: Bool?] {} +} + + +class Foo { + static func foo() -> [Bool?] {} +} + + +class Foo { + func foo() -> (Bool?) -> String {} +} + + +class Foo { + func foo() -> ([Int]) -> Bool? {} +} + + +struct Foo { + func foo() -> Bool? {} +} + + +struct Foo { + func foo() -> [String: Bool?] {} +} + + +struct Foo { + func foo() -> [Bool?] {} +} + + +struct Foo { + static func foo() -> Bool? {} +} + + +struct Foo { + static func foo() -> [String: Bool?] {} +} + + +struct Foo { + static func foo() -> [Bool?] {} +} + + +struct Foo { + func foo() -> (Bool?) -> String {} +} + + +struct Foo { + func foo() -> ([Int]) -> Bool? {} +} + + +enum Foo { + func foo() -> Bool? {} +} + + +enum Foo { + func foo() -> [String: Bool?] {} +} + + +enum Foo { + func foo() -> [Bool?] {} +} + + +enum Foo { + static func foo() -> Bool? {} +} + + +enum Foo { + static func foo() -> [String: Bool?] {} +} + + +enum Foo { + static func foo() -> [Bool?] {} +} + + +enum Foo { + func foo() -> (Bool?) -> String {} +} + + +enum Foo { + func foo() -> ([Int]) -> Bool? {} +} + + +class Foo { + func foo(input: Bool?) {} +} + + +class Foo { + func foo(input: [String: Bool?]) {} +} + + +class Foo { + func foo(input: [Bool?]) {} +} + + +class Foo { + static func foo(input: Bool?) {} +} + + +class Foo { + static func foo(input: [String: Bool?]) {} +} + + +class Foo { + static func foo(input: [Bool?]) {} +} + + +struct Foo { + func foo(input: Bool?) {} +} + + +struct Foo { + func foo(input: [String: Bool?]) {} +} + + +struct Foo { + func foo(input: [Bool?]) {} +} + + +struct Foo { + static func foo(input: Bool?) {} +} + + +struct Foo { + static func foo(input: [String: Bool?]) {} +} + + +struct Foo { + static func foo(input: [Bool?]) {} +} + + +enum Foo { + func foo(input: Bool?) {} +} + + +enum Foo { + func foo(input: [String: Bool?]) {} +} + + +enum Foo { + func foo(input: [Bool?]) {} +} + + +enum Foo { + static func foo(input: Bool?) {} +} + + +enum Foo { + static func foo(input: [String: Bool?]) {} +} + + +enum Foo { + static func foo(input: [Bool?]) {} +} diff --git a/src/main/resources/docs/tests/explicit_acl.swift b/src/main/resources/docs/tests/explicit_acl.swift new file mode 100644 index 0000000..741ff35 --- /dev/null +++ b/src/main/resources/docs/tests/explicit_acl.swift @@ -0,0 +1,27 @@ +//#Patterns: explicit_acl + +//#Issue: {"severity": "Info", "line": 11, "patternId": "explicit_acl"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "explicit_acl"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "explicit_acl"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "explicit_acl"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "explicit_acl"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "explicit_acl"} + + +enum A {} + + +final class B {} + + +internal struct C { let d = 5 } + + +public struct C { let d = 5 } + + +func a() {} + + +internal let a = 0 +func b() {} diff --git a/src/main/resources/docs/tests/explicit_enum_raw_value.swift b/src/main/resources/docs/tests/explicit_enum_raw_value.swift new file mode 100644 index 0000000..a380c2f --- /dev/null +++ b/src/main/resources/docs/tests/explicit_enum_raw_value.swift @@ -0,0 +1,38 @@ +//#Patterns: explicit_enum_raw_value + +//#Issue: {"severity": "Info", "line": 12, "patternId": "explicit_enum_raw_value"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "explicit_enum_raw_value"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "explicit_enum_raw_value"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "explicit_enum_raw_value"} +//#Issue: {"severity": "Info", "line": 31, "patternId": "explicit_enum_raw_value"} + + + +enum Numbers: Int { + case one = 10, two, three = 30 +} + + + +enum Numbers: NSInteger { + case one +} + + + +enum Numbers: String { + case one + case two +} + + + +enum Numbers: String { + case one, two = "two" +} + + + +enum Numbers: Decimal { + case one, ↓two +} diff --git a/src/main/resources/docs/tests/fallthrough.swift b/src/main/resources/docs/tests/fallthrough.swift new file mode 100644 index 0000000..22d38c4 --- /dev/null +++ b/src/main/resources/docs/tests/fallthrough.swift @@ -0,0 +1,12 @@ +//#Patterns: fallthrough + +//#Issue: {"severity": "Info", "line": 9, "patternId": "fallthrough"} + + + +switch foo { +case .bar: + fallthrough +case .bar2: + something() +} diff --git a/src/main/resources/docs/tests/is_disjoint.swift b/src/main/resources/docs/tests/is_disjoint.swift new file mode 100644 index 0000000..12befab --- /dev/null +++ b/src/main/resources/docs/tests/is_disjoint.swift @@ -0,0 +1,11 @@ +//#Patterns: is_disjoint + +//#Issue: {"severity": "Info", "line": 8, "patternId": "is_disjoint"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "is_disjoint"} + + + +_ = Set(syntaxKinds).intersection(commentAndStringKindsSet).isEmpty + + +let isObjc = !objcAttributes.intersection(dictionary.enclosedSwiftAttributes).isEmpty diff --git a/src/main/resources/docs/tests/joined_default_parameter.swift b/src/main/resources/docs/tests/joined_default_parameter.swift new file mode 100644 index 0000000..ddb0690 --- /dev/null +++ b/src/main/resources/docs/tests/joined_default_parameter.swift @@ -0,0 +1,12 @@ +//#Patterns: joined_default_parameter + +//#Issue: {"severity": "Info", "line": 8, "patternId": "joined_default_parameter"} +//#Issue: {"severity": "Info", "line": 12, "patternId": "joined_default_parameter"} + + + +let foo = bar.joined(separator: "") + + +let foo = bar.filter(toto) + .joined(separator: "") diff --git a/src/main/resources/docs/tests/let_var_whitespace.swift b/src/main/resources/docs/tests/let_var_whitespace.swift new file mode 100644 index 0000000..72b93f7 --- /dev/null +++ b/src/main/resources/docs/tests/let_var_whitespace.swift @@ -0,0 +1,42 @@ +//#Patterns: let_var_whitespace + +//#Issue: {"severity": "Info", "line": 12, "patternId": "let_var_whitespace"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "let_var_whitespace"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "let_var_whitespace"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "let_var_whitespace"} +//#Issue: {"severity": "Info", "line": 35, "patternId": "let_var_whitespace"} +//#Issue: {"severity": "Info", "line": 42, "patternId": "let_var_whitespace"} + + +var x = 1 +x = 2 + + + + +a = 5 +var x = 1 + + + +struct X { + let a + func x() {} +} + + + +var x = 0 +@objc func f() {} + + + +var x = 0 +@objc +func f() {} + + + +@objc func f() { +} +var x = 0 diff --git a/src/main/resources/docs/tests/literal_expression_end_indentation.swift b/src/main/resources/docs/tests/literal_expression_end_indentation.swift new file mode 100644 index 0000000..03b2e21 --- /dev/null +++ b/src/main/resources/docs/tests/literal_expression_end_indentation.swift @@ -0,0 +1,25 @@ +//#Patterns: literal_expression_end_indentation + +//#Issue: {"severity": "Info", "line": 12, "patternId": "literal_expression_end_indentation"} +//#Issue: {"severity": "Info", "line": 19, "patternId": "literal_expression_end_indentation"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "literal_expression_end_indentation"} + + + +let x = [ + 1, + 2 + ] + +Example #2 + + let x = [ + 1, + 2 +] + +Example #3 + +let x = [ + key: value + ] diff --git a/src/main/resources/docs/tests/multiline_arguments.swift b/src/main/resources/docs/tests/multiline_arguments.swift new file mode 100644 index 0000000..046cea4 --- /dev/null +++ b/src/main/resources/docs/tests/multiline_arguments.swift @@ -0,0 +1,29 @@ +//#Patterns: multiline_arguments + +//#Issue: {"severity": "Info", "line": 15, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 19, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 28, "patternId": "multiline_arguments"} + + + +foo(0, + param1: 1, param2: true, ↓param3: [3]) + + +foo(0, param1: 1, + param2: true, param3: [3]) + + +foo(0, param1: 1, ↓param2: true, + param3: [3]) + + +foo( + 0, param1: 1, + param2: true, param3: [3] +) diff --git a/src/main/resources/docs/tests/multiple_closures_with_trailing_closure.swift b/src/main/resources/docs/tests/multiple_closures_with_trailing_closure.swift new file mode 100644 index 0000000..679d852 --- /dev/null +++ b/src/main/resources/docs/tests/multiple_closures_with_trailing_closure.swift @@ -0,0 +1,15 @@ +//#Patterns: multiple_closures_with_trailing_closure + +//#Issue: {"severity": "Info", "line": 8, "patternId": "multiple_closures_with_trailing_closure"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "multiple_closures_with_trailing_closure"} + + + +foo.something(param1: { $0 }) { $0 + 1 } + + +UIView.animate(withDuration: 1.0, animations: { + someView.alpha = 0.0 +}) { _ in + someView.removeFromSuperview() +} diff --git a/src/main/resources/docs/tests/no_grouping_extension.swift b/src/main/resources/docs/tests/no_grouping_extension.swift new file mode 100644 index 0000000..cb5845d --- /dev/null +++ b/src/main/resources/docs/tests/no_grouping_extension.swift @@ -0,0 +1,26 @@ +//#Patterns: no_grouping_extension + +//#Issue: {"severity": "Info", "line": 11, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Info", "line": 21, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "no_grouping_extension"} + + + +enum Fruit {} +extension Fruit {} + + + +extension Tea: Error {} +struct Tea {} + + + +class Ham { class Spam {}} +extension Ham.Spam {} + + + +extension External { struct Gotcha {}} +extension External.Gotcha {} diff --git a/src/main/resources/docs/tests/override_in_extension.swift b/src/main/resources/docs/tests/override_in_extension.swift new file mode 100644 index 0000000..c28a1c3 --- /dev/null +++ b/src/main/resources/docs/tests/override_in_extension.swift @@ -0,0 +1,16 @@ +//#Patterns: override_in_extension + +//#Issue: {"severity": "Info", "line": 9, "patternId": "override_in_extension"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "override_in_extension"} + + + +extension Person { + override var age: Int { return 42 } +} + + + +extension Person { + override func celebrateBirthday() {} +} diff --git a/src/main/resources/docs/tests/pattern_matching_keywords.swift b/src/main/resources/docs/tests/pattern_matching_keywords.swift new file mode 100644 index 0000000..0fc9ea8 --- /dev/null +++ b/src/main/resources/docs/tests/pattern_matching_keywords.swift @@ -0,0 +1,43 @@ +//#Patterns: pattern_matching_keywords + +//#Issue: {"severity": "Info", "line": 17, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 32, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 32, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 37, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 37, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 42, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 42, "patternId": "pattern_matching_keywords"} + +switch foo { +case (let x, let y): break +} + + +switch foo { +case .foo(let x, let y): break +} + + +switch foo { +case (.yamlParsing(let x), .yamlParsing(let y)): break +} + + +switch foo { +case (var x, var y): break +} + + +switch foo { +case .foo(var x, var y): break +} + + +switch foo { +case (.yamlParsing(var x), .yamlParsing(var y)): break +} diff --git a/src/main/resources/docs/tests/prefixed_toplevel_constant.swift b/src/main/resources/docs/tests/prefixed_toplevel_constant.swift new file mode 100644 index 0000000..b73c8be --- /dev/null +++ b/src/main/resources/docs/tests/prefixed_toplevel_constant.swift @@ -0,0 +1,38 @@ +//#Patterns: prefixed_toplevel_constant + +//#Issue: {"severity": "Info", "line": 14, "patternId": "prefixed_toplevel_constant"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "prefixed_toplevel_constant"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "prefixed_toplevel_constant"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "prefixed_toplevel_constant"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "prefixed_toplevel_constant"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "prefixed_toplevel_constant"} +//#Issue: {"severity": "Info", "line": 33, "patternId": "prefixed_toplevel_constant"} +//#Issue: {"severity": "Info", "line": 36, "patternId": "prefixed_toplevel_constant"} + + + +private let Foo = 20.0 + + +public let Foo = false + + +internal let Foo = "Foo" + + +let Foo = true + + +let foo = 2, ↓bar = true + + +var foo = true, let Foo = true + + +let +foo = true + + +let foo = { + return a + b +}() diff --git a/src/main/resources/docs/tests/private_action.swift b/src/main/resources/docs/tests/private_action.swift new file mode 100644 index 0000000..4e3c771 --- /dev/null +++ b/src/main/resources/docs/tests/private_action.swift @@ -0,0 +1,78 @@ +//#Patterns: private_action + +//#Issue: {"severity": "Info", "line": 17, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 35, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 41, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 47, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 53, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 59, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 65, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 71, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 77, "patternId": "private_action"} + + +class Foo { + @IBAction func barButtonTapped(_ sender: UIButton) {} +} + + + +struct Foo { + @IBAction func barButtonTapped(_ sender: UIButton) {} +} + + + +class Foo { + @IBAction public func barButtonTapped(_ sender: UIButton) {} +} + + + +struct Foo { + @IBAction public func barButtonTapped(_ sender: UIButton) {} +} + + + +class Foo { + @IBAction internal func barButtonTapped(_ sender: UIButton) {} +} + + + +struct Foo { + @IBAction internal func barButtonTapped(_ sender: UIButton) {} +} + + + +extension Foo { + @IBAction func barButtonTapped(_ sender: UIButton) {} +} + + + +extension Foo { + @IBAction public func barButtonTapped(_ sender: UIButton) {} +} + + + +extension Foo { + @IBAction internal func barButtonTapped(_ sender: UIButton) {} +} + + + +public extension Foo { + @IBAction func barButtonTapped(_ sender: UIButton) {} +} + + + +internal extension Foo { + @IBAction func barButtonTapped(_ sender: UIButton) {} +} diff --git a/src/main/resources/docs/tests/private_over_fileprivate.swift b/src/main/resources/docs/tests/private_over_fileprivate.swift new file mode 100644 index 0000000..21eabe3 --- /dev/null +++ b/src/main/resources/docs/tests/private_over_fileprivate.swift @@ -0,0 +1,12 @@ +//#Patterns: private_over_fileprivate + +//#Issue: {"severity": "Info", "line": 7, "patternId": "private_over_fileprivate"} +//#Issue: {"severity": "Info", "line": 10, "patternId": "private_over_fileprivate"} + + +fileprivate enum MyEnum {} + + +fileprivate class MyClass { + fileprivate(set) var myInt = 4 +} diff --git a/src/main/resources/docs/tests/quick_discouraged_call.swift b/src/main/resources/docs/tests/quick_discouraged_call.swift new file mode 100644 index 0000000..135c69a --- /dev/null +++ b/src/main/resources/docs/tests/quick_discouraged_call.swift @@ -0,0 +1,161 @@ +//#Patterns: quick_discouraged_call + +//#Issue: {"severity": "Info", "line": 30, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 40, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 51, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 54, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 55, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 79, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 92, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 102, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 112, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 122, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 132, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 142, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 145, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 155, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Info", "line": 158, "patternId": "quick_discouraged_call"} + + +class TotoTests { + override func spec() { + describe("foo") { + let foo = Foo() + } + } +} +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + let foo = Foo() + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + let foo = Foo() + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + context("foo") { + let foo = Foo() + } + context("bar") { + let foo = Foo() + foo.bar() + it("does something") { + let foo = Foo() + foo.toto() + } + } + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + context("foo") { + context("foo") { + beforeEach { + let foo = Foo() + foo.toto() + } + it("bar") { + } + context("foo") { + let foo = Foo() + } + } + } + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + context("foo") { + let foo = Foo() + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + sharedExamples("foo") { + let foo = Foo() + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + foo() + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + context("foo") { + foo() + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + sharedExamples("foo") { + foo() + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + xdescribe("foo") { + let foo = Foo() + } + fdescribe("foo") { + let foo = Foo() + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + xcontext("foo") { + let foo = Foo() + } + fcontext("foo") { + let foo = Foo() + } + } +} diff --git a/src/main/resources/docs/tests/quick_discouraged_focused_test.swift b/src/main/resources/docs/tests/quick_discouraged_focused_test.swift new file mode 100644 index 0000000..c6a3c2b --- /dev/null +++ b/src/main/resources/docs/tests/quick_discouraged_focused_test.swift @@ -0,0 +1,65 @@ +//#Patterns: quick_discouraged_focused_test + +//#Issue: {"severity": "Info", "line": 13, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Info", "line": 35, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Info", "line": 44, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Info", "line": 54, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Info", "line": 63, "patternId": "quick_discouraged_focused_test"} + +class TotoTests: QuickSpec { + override func spec() { + fdescribe("foo") { } + } +} + + +class TotoTests: QuickSpec { + override func spec() { + fcontext("foo") { } + } +} + + +class TotoTests: QuickSpec { + override func spec() { + fit("foo") { } + } +} + + +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + fit("bar") { } + } + } +} + + +class TotoTests: QuickSpec { + override func spec() { + context("foo") { + fit("bar") { } + } + } +} + + +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + context("bar") { + fit("toto") { } + } + } + } +} + + +class TotoTests: QuickSpec { + override func spec() { + fitBehavesLike("foo") + } +} diff --git a/src/main/resources/docs/tests/quick_discouraged_pending_test.swift b/src/main/resources/docs/tests/quick_discouraged_pending_test.swift new file mode 100644 index 0000000..e604557 --- /dev/null +++ b/src/main/resources/docs/tests/quick_discouraged_pending_test.swift @@ -0,0 +1,81 @@ +//#Patterns: quick_discouraged_pending_test + +//#Issue: {"severity": "Info", "line": 15, "patternId": "quick_discouraged_pending_test"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "quick_discouraged_pending_test"} +//#Issue: {"severity": "Info", "line": 31, "patternId": "quick_discouraged_pending_test"} +//#Issue: {"severity": "Info", "line": 40, "patternId": "quick_discouraged_pending_test"} +//#Issue: {"severity": "Info", "line": 50, "patternId": "quick_discouraged_pending_test"} +//#Issue: {"severity": "Info", "line": 61, "patternId": "quick_discouraged_pending_test"} +//#Issue: {"severity": "Info", "line": 71, "patternId": "quick_discouraged_pending_test"} +//#Issue: {"severity": "Info", "line": 79, "patternId": "quick_discouraged_pending_test"} + + +class TotoTests: QuickSpec { + override func spec() { + xdescribe("foo") { } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + xcontext("foo") { } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + xit("foo") { } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + xit("bar") { } + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + context("foo") { + xit("bar") { } + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + context("bar") { + xit("toto") { } + } + } + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + pending("foo") + } +} + + + +class TotoTests: QuickSpec { + override func spec() { + xitBehavesLike("foo") + } +} diff --git a/src/main/resources/docs/tests/required_enum_case.swift b/src/main/resources/docs/tests/required_enum_case.swift new file mode 100644 index 0000000..afa4677 --- /dev/null +++ b/src/main/resources/docs/tests/required_enum_case.swift @@ -0,0 +1,23 @@ +//#Patterns: required_enum_case + + +enum MyNetworkResponse: String, NetworkResponsable { + case success, error +} + + +enum MyNetworkResponse: String, NetworkResponsable { + case success, error +} + + +enum MyNetworkResponse: String, NetworkResponsable { + case success + case error +} + + +enum MyNetworkResponse: String, NetworkResponsable { + case success + case error +} diff --git a/src/main/resources/docs/tests/single_test_class.swift b/src/main/resources/docs/tests/single_test_class.swift new file mode 100644 index 0000000..8b07b87 --- /dev/null +++ b/src/main/resources/docs/tests/single_test_class.swift @@ -0,0 +1,48 @@ +//#Patterns: single_test_class + +//#Issue: {"severity": "Info", "line": 19, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 31, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 35, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 36, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 37, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 41, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 42, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 46, "patternId": "single_test_class"} +//#Issue: {"severity": "Info", "line": 47, "patternId": "single_test_class"} + + +class FooTests: QuickSpec { } +class BarTests: QuickSpec { } + + + +class FooTests: QuickSpec { } +class BarTests: QuickSpec { } +class TotoTests: QuickSpec { } + + + +class FooTests: XCTestCase { } +class BarTests: XCTestCase { } + + + +class FooTests: XCTestCase { } +class BarTests: XCTestCase { } +class TotoTests: XCTestCase { } + + + +class FooTests: QuickSpec { } +class BarTests: XCTestCase { } + + + +class FooTests: QuickSpec { } +class BarTests: XCTestCase { } +class TotoTests { } diff --git a/src/main/resources/docs/tests/sorted_first_last.swift b/src/main/resources/docs/tests/sorted_first_last.swift new file mode 100644 index 0000000..fc2178c --- /dev/null +++ b/src/main/resources/docs/tests/sorted_first_last.swift @@ -0,0 +1,66 @@ +//#Patterns: sorted_first_last + +//#Issue: {"severity": "Info", "line": 18, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 34, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 38, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 42, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 46, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 50, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 54, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 58, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 62, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 66, "patternId": "sorted_first_last"} + + +myList.sorted().first + + + +myList.sorted(by: { $0.description < $1.description }).first + + + +myList.sorted(by: >).first + + + +myList.map { $0 + 1 }.sorted().first + + + +myList.sorted(by: someFunction).first + + + +myList.map { $0 + 1 }.sorted { $0.description < $1.description }.first + + + +myList.sorted().last + + + +myList.sorted().last?.something() + + + +myList.sorted(by: { $0.description < $1.description }).last + + + +myList.map { $0 + 1 }.sorted().last + + + +myList.sorted(by: someFunction).last + + + +myList.map { $0 + 1 }.sorted { $0.description < $1.description }.last + + + +myList.map { $0 + 1 }.sorted { $0.first < $1.first }.last diff --git a/src/main/resources/docs/tests/strict_fileprivate.swift b/src/main/resources/docs/tests/strict_fileprivate.swift new file mode 100644 index 0000000..322f5b0 --- /dev/null +++ b/src/main/resources/docs/tests/strict_fileprivate.swift @@ -0,0 +1,42 @@ +//#Patterns: strict_fileprivate + +//#Issue: {"severity": "Info", "line": 12, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Info", "line": 19, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Info", "line": 34, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Info", "line": 40, "patternId": "strict_fileprivate"} + + +fileprivate extension String {} + + +fileprivate +extension String {} + + +fileprivate extension +String {} + + +extension String { + fileprivate func Something(){} +} + + +class MyClass { + fileprivate let myInt = 4 +} + + +class MyClass { + fileprivate(set) var myInt = 4 +} + + +struct Outter { + struct Inter { + fileprivate struct Inner {} + } +} diff --git a/src/main/resources/docs/tests/superfluous_disable_command.swift b/src/main/resources/docs/tests/superfluous_disable_command.swift new file mode 100644 index 0000000..e1bc6dd --- /dev/null +++ b/src/main/resources/docs/tests/superfluous_disable_command.swift @@ -0,0 +1 @@ +//#Patterns: superfluous_disable_command diff --git a/src/main/resources/docs/tests/switch_case_alignment.swift b/src/main/resources/docs/tests/switch_case_alignment.swift new file mode 100644 index 0000000..969a884 --- /dev/null +++ b/src/main/resources/docs/tests/switch_case_alignment.swift @@ -0,0 +1,34 @@ +//#Patterns: switch_case_alignment + +//#Issue: {"severity": "Info", "line": 12, "patternId": "switch_case_alignment"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "switch_case_alignment"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "switch_case_alignment"} +//#Issue: {"severity": "Info", "line": 28, "patternId": "switch_case_alignment"} +//#Issue: {"severity": "Info", "line": 32, "patternId": "switch_case_alignment"} + + + + switch someBool { + case true: + print('red') + case false: + print('blue') + } + + if aBool { + switch someBool { + case true: + print('red') + case false: + print('blue') + } + } + + switch someInt { + case 0: + print('Zero') + case 1: + print('One') + default: + print('Some other number') + } diff --git a/src/main/resources/docs/tests/trailing_closure.swift b/src/main/resources/docs/tests/trailing_closure.swift new file mode 100644 index 0000000..86e189c --- /dev/null +++ b/src/main/resources/docs/tests/trailing_closure.swift @@ -0,0 +1,22 @@ +//#Patterns: trailing_closure + +//#Issue: {"severity": "Info", "line": 10, "patternId": "trailing_closure"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "trailing_closure"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "trailing_closure"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "trailing_closure"} + + + +foo.map({ $0 + 1 }) + + + +foo.reduce(0, combine: { $0 + 1 }) + + + +offsets.sorted(by: { $0.offset < $1.offset }) + + + +foo.something(0, { $0 + 1 }) diff --git a/src/main/resources/docs/tests/unneeded_break_in_switch.swift b/src/main/resources/docs/tests/unneeded_break_in_switch.swift new file mode 100644 index 0000000..4f83a52 --- /dev/null +++ b/src/main/resources/docs/tests/unneeded_break_in_switch.swift @@ -0,0 +1,34 @@ +//#Patterns: unneeded_break_in_switch + +//#Issue: {"severity": "Info", "line": 12, "patternId": "unneeded_break_in_switch"} +//#Issue: {"severity": "Info", "line": 19, "patternId": "unneeded_break_in_switch"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "unneeded_break_in_switch"} +//#Issue: {"severity": "Info", "line": 33, "patternId": "unneeded_break_in_switch"} + + +switch foo { +case .bar: + something() + break +} + + +switch foo { +case .bar: + something() + break // comment +} + + +switch foo { +default: + something() + break +} + + +switch foo { +case .foo, .foo2 where condition: + something() + break +} diff --git a/src/main/resources/docs/tests/unneeded_parentheses_in_closure_argument.swift b/src/main/resources/docs/tests/unneeded_parentheses_in_closure_argument.swift new file mode 100644 index 0000000..7167226 --- /dev/null +++ b/src/main/resources/docs/tests/unneeded_parentheses_in_closure_argument.swift @@ -0,0 +1,25 @@ +//#Patterns: unneeded_parentheses_in_closure_argument + +//#Issue: {"severity": "Info", "line": 10, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "unneeded_parentheses_in_closure_argument"} + + +call(arg: { (bar) in }) + + + +call(arg: { (bar, _) in }) + + + +let foo = { (bar) -> Bool in return true } + + + +foo.map { ($0, $0) }.forEach { (x, y) in } + + +foo.bar { [weak self] (x, y) in } diff --git a/src/main/resources/docs/tests/xctfail_message.swift b/src/main/resources/docs/tests/xctfail_message.swift new file mode 100644 index 0000000..61ae9a0 --- /dev/null +++ b/src/main/resources/docs/tests/xctfail_message.swift @@ -0,0 +1,14 @@ +//#Patterns: xctfail_message + +//#Issue: {"severity": "Info", "line": 8, "patternId": "xctfail_message"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "xctfail_message"} + + +func testFoo() { + XCTFail() +} + + +func testFoo() { + XCTFail("") +} diff --git a/src/main/resources/docs/tests/yoda_condition.swift b/src/main/resources/docs/tests/yoda_condition.swift new file mode 100644 index 0000000..09c4bee --- /dev/null +++ b/src/main/resources/docs/tests/yoda_condition.swift @@ -0,0 +1,33 @@ +//#Patterns: yoda_condition + +//#Issue: {"severity": "Info", "line": 12, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 33, "patternId": "yoda_condition"} + + +if 42 == foo {} + + + +if 42.42 >= foo {} + + + +guard 42 <= foo else { return } + + + +guard "str str" != foo else { return } + + +while 10 > foo { } + + +while 1 < foo { } + + +if nil == foo From fe36bd6e9d70bb6587eb22cea4f28b6a395719a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Tue, 2 Oct 2018 23:50:31 +0100 Subject: [PATCH 007/119] Debian base image with jre and swiftlint --- Dockerfile | 22 ++++++++++++++++++++++ build.sbt | 15 ++++----------- circle.yml | 1 + project/plugins.sbt | 2 +- 4 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2423c13 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM norionomura/swiftlint:0.27.0_swift-4.2.0 as build + +RUN strip -s /usr/bin/swiftlint && \ + strip -s /usr/lib/swift/linux/*.so && \ + strip -s /usr/lib/libsourcekitdInProc.so /usr/lib/x86_64-linux-gnu/libBlocksRuntime.so.0 + +RUN chmod a+x /usr/lib/libsourcekitdInProc.so /usr/lib/x86_64-linux-gnu/libBlocksRuntime.so.0 + + +FROM openjdk:8-jre + +RUN apt-get -q update && \ + apt-get -q install -y --no-install-recommends libatomic1 libcurl3 libbsd0 libxml2 + +RUN wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.4_amd64.deb && dpkg -i libicu55_55.1-7ubuntu0.4_amd64.deb + +COPY --from=build /usr/lib/swift/linux /usr/lib/swift/linux/ +COPY --from=build /usr/bin/swiftlint /usr/bin/ +COPY --from=build /usr/lib/libsourcekitdInProc.so /usr/lib/ +COPY --from=build /usr/lib/x86_64-linux-gnu/libBlocksRuntime.so.0 /usr/lib/x86_64-linux-gnu/ + +CMD [swiftlint, version] diff --git a/build.sbt b/build.sbt index 57546f5..562de64 100755 --- a/build.sbt +++ b/build.sbt @@ -38,10 +38,6 @@ toolVersion := { toolMap.getOrElse[String]("version", throw new Exception("Failed to retrieve 'version' from patterns.json")) } -val installAll = - s"""apt-get update && - |apt-get install default-jre --assume-yes""".stripMargin.replaceAll(System.lineSeparator(), " ") - mappings in Universal <++= (resourceDirectory in Compile) map { (resourceDir: File) => val src = resourceDir / "docs" val dest = "/docs" @@ -60,16 +56,13 @@ daemonUser in Docker := dockerUser daemonGroup in Docker := dockerGroup -dockerBaseImage := s"norionomura/swiftlint:${toolVersion.value}" +dockerBaseImage := s"codacy/swiftlint" dockerCommands := dockerCommands.value.flatMap { - case cmd@Cmd("WORKDIR", _) => List(cmd, - Cmd("RUN", installAll) - ) - case cmd@(Cmd("ADD", "opt /opt")) => List(cmd, - Cmd("RUN", "mv /opt/docker/docs /docs"), + case cmd@(Cmd("ADD", _)) => List( Cmd("RUN", s"""adduser --uid 2004 --disabled-password --gecos \"\" $dockerUser"""), - ExecCmd("RUN", Seq("chown", "-R", s"$dockerUser:$dockerGroup", "/docs"): _*) + cmd, + Cmd("RUN", "mv /opt/docker/docs /docs") ) case other => List(other) } diff --git a/circle.yml b/circle.yml index ef184e9..06c39e5 100755 --- a/circle.yml +++ b/circle.yml @@ -13,6 +13,7 @@ machine: dependencies: override: - (cd $HOME/codacy-plugins-test && sbt compile) + - (cd $HOME/$CIRCLE_PROJECT_REPONAME && docker build -t codacy/swiftlint -f Dockerfile .) - (cd $HOME/$CIRCLE_PROJECT_REPONAME && sbt "set version in Docker := \"latest\"" "set name := \"$CIRCLE_PROJECT_REPONAME\"" docker:publishLocal) cache_directories: - "~/.ivy2" diff --git a/project/plugins.sbt b/project/plugins.sbt index 02581ab..3b2db13 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3") \ No newline at end of file +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.2") \ No newline at end of file From c0f66367ba6709681f096bf598146bb9e7f1741d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Wed, 3 Oct 2018 00:01:39 +0100 Subject: [PATCH 008/119] circle 2 config --- circle.yml | 104 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 42 deletions(-) diff --git a/circle.yml b/circle.yml index 06c39e5..2753444 100755 --- a/circle.yml +++ b/circle.yml @@ -1,43 +1,63 @@ -machine: - pre: - - echo 'DOCKER_OPTS="-s btrfs -e lxc -D --userland-proxy=false"' | sudo tee -a /etc/default/docker - - sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.0-circleci-cp-workaround' - - sudo chmod 0755 /usr/bin/docker - - mkdir -p $HOME/.sbt/.lib/0.13.13 && wget https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.13/sbt-launch.jar -O $HOME/.sbt/.lib/0.13.13/sbt-launch.jar - - (cd $HOME; rm -f codacy-plugins-test; git clone https://github.com/codacy/codacy-plugins-test.git) - java: - version: oraclejdk8 - services: - - docker +version: 2 +jobs: + build: + machine: true + working_directory: ~/workdir + steps: + - checkout + - run: + name: Clone test project + working_directory: ~/ + command: | + (git -C ~/codacy-plugins-test fetch --all && + git -C ~/codacy-plugins-test reset --hard origin/master) || + git clone git://github.com/codacy/codacy-plugins-test.git ~/codacy-plugins-test + - restore_cache: + key: dependencies-{{ checksum "build.sbt" }} + - run: + name: Compile test project + working_directory: ~/codacy-plugins-test + command: sbt compile + - run: + name: Publish base docker image + working_directory: ~/workdir + command: docker build -t codacy/swiftlint -f Dockerfile . + - run: + name: Publish tool docker locally + working_directory: ~/workdir + command: sbt 'set version in Docker := "latest"' "set name := \"$CIRCLE_PROJECT_REPONAME\"" docker:publishLocal + - save_cache: + key: dependencies-{{ checksum "build.sbt" }} + paths: + - "~/.ivy2" + - "~/.m2" + - "~/.sbt" + - "~/codacy-plugins-test/target" + - "~/codacy-plugins-test/project/target" + - "~/codacy-plugins-test/project/project" + - "~/workdir/target" + - "~/workdir/project/target" + - "~/workdir/project/project" + - run: + name: Test json + working_directory: ~/codacy-plugins-test + command: sbt -Dcodacy.tests.ignore.descriptions=true "runMain codacy.plugins.DockerTest json $CIRCLE_PROJECT_REPONAME:latest" + - run: + name: Test patterns + working_directory: ~/codacy-plugins-test + command: sbt -Dcodacy.tests.noremove=true -Dcodacy.tests.threads=8 "runMain codacy.plugins.DockerTest pattern $CIRCLE_PROJECT_REPONAME:latest" + - deploy: + name: Push application Docker image + command: | + if [ "${CIRCLE_BRANCH}" == "master" ]; then + docker login -u $DOCKER_USER -p $DOCKER_PASS + docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME + docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME:1.0.$CIRCLE_BUILD_NUM + docker push codacy/$CIRCLE_PROJECT_REPONAME + fi -dependencies: - override: - - (cd $HOME/codacy-plugins-test && sbt compile) - - (cd $HOME/$CIRCLE_PROJECT_REPONAME && docker build -t codacy/swiftlint -f Dockerfile .) - - (cd $HOME/$CIRCLE_PROJECT_REPONAME && sbt "set version in Docker := \"latest\"" "set name := \"$CIRCLE_PROJECT_REPONAME\"" docker:publishLocal) - cache_directories: - - "~/.ivy2" - - "~/.m2" - - "~/.sbt" - - "~/codacy-plugins-test/target" - - "~/codacy-plugins-test/project/target" - - "~/codacy-plugins-test/project/project" - - "~/$CIRCLE_PROJECT_REPONAME/target" - - "~/$CIRCLE_PROJECT_REPONAME/project/target" - - "~/$CIRCLE_PROJECT_REPONAME/project/project" - -test: - pre: - - (cd $HOME/codacy-plugins-test; git fetch --all; git reset --hard origin/master) - override: - - (cd $HOME/codacy-plugins-test && sbt -Dcodacy.tests.ignore.descriptions=true "run-main codacy.plugins.DockerTest json $CIRCLE_PROJECT_REPONAME:latest") - - (cd $HOME/codacy-plugins-test && sbt -Dcodacy.tests.noremove=true -Dcodacy.tests.threads=8 "run-main codacy.plugins.DockerTest pattern $CIRCLE_PROJECT_REPONAME:latest") - -deployment: - hub: - branch: master - commands: - - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - - docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME - - docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME:1.0.$CIRCLE_BUILD_NUM - - docker push codacy/$CIRCLE_PROJECT_REPONAME +workflows: + version: 2 + build-and-deploy: + jobs: + - build From a0a11deda31f8c8f3bc18c3509e4cb874735fd70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Fri, 5 Oct 2018 12:52:41 +0100 Subject: [PATCH 009/119] Update seed version --- .scalafix.conf | 19 ++++ .scalafmt.conf | 19 ++++ Dockerfile | 8 +- build.sbt | 48 +++++----- project/build.properties | 2 +- project/plugins.sbt | 14 ++- src/main/resources/docs/patterns.json | 2 +- .../docs/tests/closure_spacing.swift | 4 +- src/main/resources/docs/tests/colon.swift | 89 +++++++++---------- src/main/resources/docs/tests/comma.swift | 6 +- .../docs/tests/discouraged_direct_init.swift | 22 +++-- .../docs/tests/empty_enum_arguments.swift | 9 +- .../docs/tests/generic_type_name.swift | 5 +- .../resources/docs/tests/large_tuple.swift | 25 +++--- .../docs/tests/multiline_arguments.swift | 14 ++- .../tests/pattern_matching_keywords.swift | 18 ++-- .../docs/tests/syntactic_sugar.swift | 19 ++-- .../resources/docs/tests/trailing_comma.swift | 17 ++-- src/main/resources/docs/tool-description.md | 1 + src/main/scala/codacy/Engine.scala | 4 +- .../scala/codacy/swiftlint/SwiftLint.scala | 72 +++++++-------- 21 files changed, 225 insertions(+), 192 deletions(-) create mode 100644 .scalafix.conf create mode 100644 .scalafmt.conf create mode 100644 src/main/resources/docs/tool-description.md diff --git a/.scalafix.conf b/.scalafix.conf new file mode 100644 index 0000000..bbf2fae --- /dev/null +++ b/.scalafix.conf @@ -0,0 +1,19 @@ +rules = [ + RemoveUnused + ExplicitResultTypes + LeakingImplicitClassVal + NoAutoTupling + NoValInForComprehension + ProcedureSyntax +] + +NoInfer.symbols = [ + "java.io.Serializable", + "scala.Any", + "scala.AnyVal", + "scala.Product" +] + +ExplicitResultTypes { + unsafeShortenNames = true +} diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000..d13cf26 --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,19 @@ +style = IntelliJ +project.excludeFilters = ["target/.*"] +maxColumn = 120 +continuationIndent.callSite = 2 +continuationIndent.defnSite = 2 +align = none +align.openParenCallSite = false +align.openParenDefnSite = true +newlines.alwaysBeforeTopLevelStatements = true +newlines.sometimesBeforeColonInMethodReturnType = true +spaces.afterKeywordBeforeParen = true +binPack.parentConstructors = false +includeCurlyBraceInSelectChains = true +includeCurlyBraceInSelectChains = false +optIn.breakChainOnFirstMethodDot = false +newlines.penalizeSingleSelectMultiArgList = false +binPack.literalArgumentLists = true +danglingParentheses = false +binPack.literalsMinArgCount = 1 diff --git a/Dockerfile b/Dockerfile index 2423c13..935cdd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,11 @@ RUN chmod a+x /usr/lib/libsourcekitdInProc.so /usr/lib/x86_64-linux-gnu/libBlock FROM openjdk:8-jre RUN apt-get -q update && \ - apt-get -q install -y --no-install-recommends libatomic1 libcurl3 libbsd0 libxml2 - -RUN wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.4_amd64.deb && dpkg -i libicu55_55.1-7ubuntu0.4_amd64.deb + apt-get -q install -y --no-install-recommends libatomic1 libcurl3 libbsd0 libxml2 && \ + wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.4_amd64.deb && \ + dpkg -i libicu55_55.1-7ubuntu0.4_amd64.deb && \ + apt-get clean && \ + rm -rf libicu55_55.1-7ubuntu0.4_amd64.deb /var/lib/apt/lists/* COPY --from=build /usr/lib/swift/linux /usr/lib/swift/linux/ COPY --from=build /usr/bin/swiftlint /usr/bin/ diff --git a/build.sbt b/build.sbt index 562de64..3b48c72 100755 --- a/build.sbt +++ b/build.sbt @@ -6,21 +6,20 @@ name := """codacy-swiftlint""" version := "1.0.0-SNAPSHOT" -val languageVersion = "2.11.11" +val languageVersion = "2.12.7" scalaVersion := languageVersion +scalacOptions ++= Seq("-Ywarn-unused") + +scapegoatVersion in ThisBuild := "1.3.4" resolvers ++= Seq( "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/releases", - "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/" -) + "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/") -libraryDependencies ++= Seq( - "com.typesafe.play" %% "play-json" % "2.4.8", - "com.codacy" %% "codacy-engine-scala-seed" % "2.7.9" withSources() -) +libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "3.0.183" withSources ()) -enablePlugins(JavaAppPackaging) +enablePlugins(AshScriptPlugin) enablePlugins(DockerPlugin) @@ -28,26 +27,27 @@ version in Docker := "1.0.0-SNAPSHOT" organization := "com.codacy" -lazy val toolVersion = SettingKey[String]("Retrieve the version of the underlying tool from patterns.json") +lazy val toolVersion = SettingKey[String]("retrieve the version of the underlying tool from patterns.json") toolVersion := { val jsonFile = (resourceDirectory in Compile).value / "docs" / "patterns.json" - val toolMap = JSON.parseFull(Source.fromFile(jsonFile).getLines().mkString) + val toolMap = JSON + .parseFull(Source.fromFile(jsonFile).getLines().mkString) .getOrElse(throw new Exception("patterns.json is not a valid json")) .asInstanceOf[Map[String, String]] toolMap.getOrElse[String]("version", throw new Exception("Failed to retrieve 'version' from patterns.json")) } -mappings in Universal <++= (resourceDirectory in Compile) map { (resourceDir: File) => - val src = resourceDir / "docs" - val dest = "/docs" - - for { - path <- (src ***).get - if !path.isDirectory - } yield path -> path.toString.replaceFirst(src.toString, dest) -} +mappings in Universal ++= { + (resourceDirectory in Compile) map { (resourceDir: File) => + val src = resourceDir / "docs" + val dest = "/docs" + for { + path <- src.allPaths.get if !path.isDirectory + } yield path -> path.toString.replaceFirst(src.toString, dest) + } +}.value val dockerUser = "docker" val dockerGroup = "docker" @@ -59,10 +59,10 @@ daemonGroup in Docker := dockerGroup dockerBaseImage := s"codacy/swiftlint" dockerCommands := dockerCommands.value.flatMap { - case cmd@(Cmd("ADD", _)) => List( - Cmd("RUN", s"""adduser --uid 2004 --disabled-password --gecos \"\" $dockerUser"""), - cmd, - Cmd("RUN", "mv /opt/docker/docs /docs") - ) + case cmd @ (Cmd("ADD", _)) => + List( + Cmd("RUN", s"""adduser --uid 2004 --disabled-password --gecos \"\" $dockerUser"""), + cmd, + Cmd("RUN", "mv /opt/docker/docs /docs")) case other => List(other) } diff --git a/project/build.properties b/project/build.properties index 406a7d2..5f528e4 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.16 \ No newline at end of file +sbt.version=1.2.3 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index 3b2db13..8102c5e 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1,13 @@ -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.2") \ No newline at end of file +// Packaging (Docker) +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.6") + +// Static Analysis +addSbtPlugin("com.sksamuel.scapegoat" %% "sbt-scapegoat" % "1.0.9") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.0") + +// Formating +addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1") + +// Dependencies +addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.4") +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2") diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index c3428c9..0a7151a 100755 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1,6 +1,6 @@ { "name": "swiftlint", - "version": "0.25.0", + "version": "0.27.0", "patterns": [ { "patternId": "attributes", diff --git a/src/main/resources/docs/tests/closure_spacing.swift b/src/main/resources/docs/tests/closure_spacing.swift index d0059c6..8fb5cd8 100644 --- a/src/main/resources/docs/tests/closure_spacing.swift +++ b/src/main/resources/docs/tests/closure_spacing.swift @@ -1,11 +1,9 @@ //#Patterns: closure_spacing +//#Issue: {"severity": "Info", "line": 8, "patternId": "closure_spacing"} //#Issue: {"severity": "Info", "line": 10, "patternId": "closure_spacing"} //#Issue: {"severity": "Info", "line": 12, "patternId": "closure_spacing"} //#Issue: {"severity": "Info", "line": 14, "patternId": "closure_spacing"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "closure_spacing"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "closure_spacing"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "closure_spacing"} [].filter({$0.contains(location)}) diff --git a/src/main/resources/docs/tests/colon.swift b/src/main/resources/docs/tests/colon.swift index 412c5a0..c9d8642 100644 --- a/src/main/resources/docs/tests/colon.swift +++ b/src/main/resources/docs/tests/colon.swift @@ -1,50 +1,49 @@ //#Patterns: colon -//#Issue: {"severity": "Info", "line": 49, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 52, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 55, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 58, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 61, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 64, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 67, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 70, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 73, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 76, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 79, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 82, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 85, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 88, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 91, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 94, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 97, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 100, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 103, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 106, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 109, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 112, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 115, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 118, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 121, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 124, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 127, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 130, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 130, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 133, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 136, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 139, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 142, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 145, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 148, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 151, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 154, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 157, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 160, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 163, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 166, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 169, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 172, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 175, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 178, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 48, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 51, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 54, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 57, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 60, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 63, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 66, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 69, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 72, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 75, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 78, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 81, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 84, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 87, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 90, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 93, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 96, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 99, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 102, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 105, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 108, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 111, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 114, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 117, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 120, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 123, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 126, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 129, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 132, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 135, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 138, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 141, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 144, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 147, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 150, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 153, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 156, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 159, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 162, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 165, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 168, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 171, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 174, "patternId": "colon"} +//#Issue: {"severity": "Info", "line": 177, "patternId": "colon"} let abc:Void diff --git a/src/main/resources/docs/tests/comma.swift b/src/main/resources/docs/tests/comma.swift index dd013c2..8ad431a 100644 --- a/src/main/resources/docs/tests/comma.swift +++ b/src/main/resources/docs/tests/comma.swift @@ -1,12 +1,10 @@ //#Patterns: comma +//#Issue: {"severity": "Info", "line": 9, "patternId": "comma"} //#Issue: {"severity": "Info", "line": 11, "patternId": "comma"} //#Issue: {"severity": "Info", "line": 13, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "comma"} //#Issue: {"severity": "Info", "line": 15, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "comma"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "comma"} func abc(a: String ,b: String) { } diff --git a/src/main/resources/docs/tests/discouraged_direct_init.swift b/src/main/resources/docs/tests/discouraged_direct_init.swift index ff85c95..c94a6b5 100644 --- a/src/main/resources/docs/tests/discouraged_direct_init.swift +++ b/src/main/resources/docs/tests/discouraged_direct_init.swift @@ -1,17 +1,15 @@ //#Patterns: discouraged_direct_init -//#Issue: {"severity": "Info", "line": 17, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 21, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 33, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 36, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 39, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Info", "line": 42, "patternId": "discouraged_direct_init"} UIDevice() diff --git a/src/main/resources/docs/tests/empty_enum_arguments.swift b/src/main/resources/docs/tests/empty_enum_arguments.swift index 54d30b5..cba20ee 100644 --- a/src/main/resources/docs/tests/empty_enum_arguments.swift +++ b/src/main/resources/docs/tests/empty_enum_arguments.swift @@ -1,10 +1,9 @@ //#Patterns: empty_enum_arguments -//#Issue: {"severity": "Info", "line": 10, "patternId": "empty_enum_arguments"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "empty_enum_arguments"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "empty_enum_arguments"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "empty_enum_arguments"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "empty_enum_arguments"} +//#Issue: {"severity": "Info", "line": 9, "patternId": "empty_enum_arguments"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "empty_enum_arguments"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "empty_enum_arguments"} +//#Issue: {"severity": "Info", "line": 21, "patternId": "empty_enum_arguments"} switch foo { case .bar(_): break diff --git a/src/main/resources/docs/tests/generic_type_name.swift b/src/main/resources/docs/tests/generic_type_name.swift index a8f0acf..bacc936 100644 --- a/src/main/resources/docs/tests/generic_type_name.swift +++ b/src/main/resources/docs/tests/generic_type_name.swift @@ -1,5 +1,6 @@ //#Patterns: generic_type_name +//#Issue: {"severity": "Info", "line": 26, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 29, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 32, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 35, "patternId": "generic_type_name"} @@ -10,21 +11,17 @@ //#Issue: {"severity": "Info", "line": 50, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 53, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 56, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 59, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 62, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 65, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 68, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 71, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 71, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 74, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 77, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 80, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 83, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 86, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 86, "patternId": "generic_type_name"} //#Issue: {"severity": "Info", "line": 89, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 92, "patternId": "generic_type_name"} func foo() {} diff --git a/src/main/resources/docs/tests/large_tuple.swift b/src/main/resources/docs/tests/large_tuple.swift index c9c2ab2..6b32ebe 100644 --- a/src/main/resources/docs/tests/large_tuple.swift +++ b/src/main/resources/docs/tests/large_tuple.swift @@ -1,18 +1,17 @@ //#Patterns: large_tuple -//#Issue: {"severity": "Info", "line": 17, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 19, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 28, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 31, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 34, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 37, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 40, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 43, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 46, "patternId": "large_tuple"} +//#Issue: {"severity": "Info", "line": 49, "patternId": "large_tuple"} let foo: (Int, Int, Int) diff --git a/src/main/resources/docs/tests/multiline_arguments.swift b/src/main/resources/docs/tests/multiline_arguments.swift index 046cea4..59851d8 100644 --- a/src/main/resources/docs/tests/multiline_arguments.swift +++ b/src/main/resources/docs/tests/multiline_arguments.swift @@ -1,13 +1,11 @@ //#Patterns: multiline_arguments -//#Issue: {"severity": "Info", "line": 15, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "multiline_arguments"} diff --git a/src/main/resources/docs/tests/pattern_matching_keywords.swift b/src/main/resources/docs/tests/pattern_matching_keywords.swift index 0fc9ea8..6a6ed1a 100644 --- a/src/main/resources/docs/tests/pattern_matching_keywords.swift +++ b/src/main/resources/docs/tests/pattern_matching_keywords.swift @@ -1,17 +1,11 @@ //#Patterns: pattern_matching_keywords -//#Issue: {"severity": "Info", "line": 17, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 21, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 31, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Info", "line": 36, "patternId": "pattern_matching_keywords"} switch foo { case (let x, let y): break diff --git a/src/main/resources/docs/tests/syntactic_sugar.swift b/src/main/resources/docs/tests/syntactic_sugar.swift index 8fb6bde..299ae48 100644 --- a/src/main/resources/docs/tests/syntactic_sugar.swift +++ b/src/main/resources/docs/tests/syntactic_sugar.swift @@ -1,15 +1,14 @@ //#Patterns: syntactic_sugar -//#Issue: {"severity": "Info", "line": 14, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 19, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 21, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "syntactic_sugar"} let x: Array diff --git a/src/main/resources/docs/tests/trailing_comma.swift b/src/main/resources/docs/tests/trailing_comma.swift index aa3a26b..ae36203 100644 --- a/src/main/resources/docs/tests/trailing_comma.swift +++ b/src/main/resources/docs/tests/trailing_comma.swift @@ -1,14 +1,13 @@ //#Patterns: trailing_comma -//#Issue: {"severity": "Info", "line": 13, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "trailing_comma"} +//#Issue: {"severity": "Info", "line": 12, "patternId": "trailing_comma"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "trailing_comma"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "trailing_comma"} +//#Issue: {"severity": "Info", "line": 21, "patternId": "trailing_comma"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "trailing_comma"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "trailing_comma"} +//#Issue: {"severity": "Info", "line": 33, "patternId": "trailing_comma"} +//#Issue: {"severity": "Info", "line": 37, "patternId": "trailing_comma"} let foo = [1, 2, 3,] diff --git a/src/main/resources/docs/tool-description.md b/src/main/resources/docs/tool-description.md new file mode 100644 index 0000000..67926bc --- /dev/null +++ b/src/main/resources/docs/tool-description.md @@ -0,0 +1 @@ +A tool to enforce Swift style and conventions, loosely based on GitHub's Swift Style Guide. [Learn more](https://github.com/realm/SwiftLint) \ No newline at end of file diff --git a/src/main/scala/codacy/Engine.scala b/src/main/scala/codacy/Engine.scala index 372dc83..733bbde 100755 --- a/src/main/scala/codacy/Engine.scala +++ b/src/main/scala/codacy/Engine.scala @@ -1,6 +1,6 @@ package codacy -import codacy.dockerApi.DockerEngine +import com.codacy.tools.scala.seed.DockerEngine import codacy.swiftlint.SwiftLint -object Engine extends DockerEngine(SwiftLint) +object Engine extends DockerEngine(SwiftLint)() diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index a423cad..6844495 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -1,12 +1,11 @@ package codacy.swiftlint -import java.io.File import java.nio.file.{Path, Paths} -import codacy.docker.api._ -import codacy.docker.api.utils.ToolHelper -import codacy.docker.api.{Pattern, Result, Source, Tool} -import codacy.dockerApi.utils.{CommandRunner, FileHelper} +import com.codacy.plugins.api.results.{Pattern, Result, Tool} +import com.codacy.plugins.api.{Options, Source} +import com.codacy.tools.scala.seed.utils.{CommandRunner, FileHelper} +import com.codacy.tools.scala.seed.utils.ToolHelper._ import play.api.libs.json._ import scala.util.{Failure, Properties, Success, Try} @@ -15,6 +14,7 @@ case class SwiftLintFile(rule_id: String, file: String, reason: String, line: In object SwiftLintFile { implicit val readsSwiftLintFile: Reads[SwiftLintFile] = new Reads[SwiftLintFile] { + def reads(json: JsValue): JsResult[SwiftLintFile] = { for { rule_id <- (json \ "rule_id").validate[String] @@ -28,17 +28,21 @@ object SwiftLintFile { object SwiftLint extends Tool { - private lazy val configFileNames = Set(".swiftlint.yml") + private lazy val nativeConfigFileNames = Set(".swiftlint.yml") - override def apply(source: Source.Directory, configuration: Option[List[Pattern.Definition]], - files: Option[Set[Source.File]], options: Map[Configuration.Key, Configuration.Value]) - (implicit specification: Tool.Specification): Try[List[Result]] = { + override def apply( + source: Source.Directory, + configuration: Option[List[Pattern.Definition]], + files: Option[Set[Source.File]], + options: Map[Options.Key, Options.Value])(implicit specification: Tool.Specification): Try[List[Result]] = { Try { - val path = Paths.get(source.path) - lazy val nativeConfig = FileHelper.findConfigurationFile(configFileNames, path).map(_.toString) - val filesToLint: Set[String] = ToolHelper.filesToLint(source, files) - val patternsToLintOpt: Option[List[codacy.docker.api.Pattern.Definition]] = ToolHelper.patternsToLint(configuration) + lazy val nativeConfig = + FileHelper.findConfigurationFile(Paths.get(source.path), nativeConfigFileNames).map(_.toString) + val filesToLint = files.fold(List(source.path.toString)) { paths => + paths.map(_.toString).toList + } + val patternsToLintOpt = configuration.withDefaultParameters val config = patternsToLintOpt.fold(Option.empty[String]) { case patternsToLint if patternsToLint.nonEmpty => @@ -49,16 +53,16 @@ object SwiftLint extends Tool { val baseCmd = List("swiftlint", "lint", "--quiet", "--reporter", "json") - val command = cfgOpt match { + val command: List[String] = cfgOpt match { case Some(opt) => baseCmd ++ List("--config", opt, "--path") ++ filesToLint case None => baseCmd ++ List("--path") ++ filesToLint } - CommandRunner.exec(command, Some(path.toFile)) match { + CommandRunner.exec(command, Option(Paths.get(source.path).toFile)) match { case Right(resultFromTool) => - parseToolResult(path, resultFromTool.stdout) match { - case s@Success(_) => s + parseToolResult(resultFromTool.stdout) match { + case s @ Success(_) => s case Failure(e) => val msg = s""" @@ -68,7 +72,7 @@ object SwiftLint extends Tool { |stdout: ${resultFromTool.stdout.mkString(Properties.lineSeparator)} |stderr: ${resultFromTool.stderr.mkString(Properties.lineSeparator)} |configFile: - |${cfgOpt.fold("")(p => scala.io.Source.fromFile(new File(p)).getLines().mkString("\n"))} + |${cfgOpt.fold("")(p => scala.io.Source.fromFile(p).getLines().mkString("\n"))} """.stripMargin Failure(new Exception(msg)) } @@ -88,25 +92,25 @@ object SwiftLint extends Tool { FileHelper.createTmpFile(content, ".swiftlint-ci", ".yml") } - private def parseToolResult(path: Path, output: List[String]): Try[List[Result]] = { + private def parseToolResult(output: List[String]): Try[List[Result]] = { Try(Json.parse(output.mkString)).flatMap(parseToolResult) } private def parseToolResult(outputJson: JsValue): Try[List[Result]] = { /* Example: - * [ - * { - * "rule_id": "mark", - * "reason": "MARK comment should be in valid format. e.g. '\/\/ MARK: ...' or '\/\/ MARK: - ...'", - * "character": "5", - * "file": "\/Users\/marlontojal\/Documents\/GitHub\/codacy-swiftlint\/src\/main\/resources\/docs\/tests\/mark.swift", - * "severity": "Warning", - * "type": "Mark", - * "line": "3" - * }, - * ... - * ] - */ + * [ + * { + * "rule_id": "mark", + * "reason": "MARK comment should be in valid format. e.g. '\/\/ MARK: ...' or '\/\/ MARK: - ...'", + * "character": "5", + * "file": "\/Users\/marlontojal\/Documents\/GitHub\/codacy-swiftlint\/src\/main\/resources\/docs\/tests\/mark.swift", + * "severity": "Warning", + * "type": "Mark", + * "line": "3" + * }, + * ... + * ] + */ Try(outputJson.as[List[SwiftLintFile]]).map { violations => violations.flatMap { violation => @@ -115,9 +119,7 @@ object SwiftLint extends Tool { Source.File(violation.file), Result.Message(violation.reason), Pattern.Id(violation.rule_id), - Source.Line(violation.line) - ) - ) + Source.Line(violation.line))) } } } From 730b07de2a9354973de9dbb9611eb8f97a3c78ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Fri, 5 Oct 2018 14:09:59 +0100 Subject: [PATCH 010/119] Use slim base image --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 935cdd8..5b90e31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,12 +7,13 @@ RUN strip -s /usr/bin/swiftlint && \ RUN chmod a+x /usr/lib/libsourcekitdInProc.so /usr/lib/x86_64-linux-gnu/libBlocksRuntime.so.0 -FROM openjdk:8-jre +FROM openjdk:8-jre-slim RUN apt-get -q update && \ - apt-get -q install -y --no-install-recommends libatomic1 libcurl3 libbsd0 libxml2 && \ + apt-get -q install -y --no-install-recommends libatomic1 libcurl3 libbsd0 libxml2 wget && \ wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.4_amd64.deb && \ dpkg -i libicu55_55.1-7ubuntu0.4_amd64.deb && \ + apt-get remove --purge -y wget && \ apt-get clean && \ rm -rf libicu55_55.1-7ubuntu0.4_amd64.deb /var/lib/apt/lists/* From ecb5b0aeff4bccc8bab4621072f665db3c2e457d Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes Date: Mon, 8 Oct 2018 18:10:54 +0100 Subject: [PATCH 011/119] Update and rename circle.yml to .circleci/config.yml --- circle.yml => .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename circle.yml => .circleci/config.yml (98%) diff --git a/circle.yml b/.circleci/config.yml similarity index 98% rename from circle.yml rename to .circleci/config.yml index 2753444..4bf31a0 100755 --- a/circle.yml +++ b/.circleci/config.yml @@ -17,7 +17,7 @@ jobs: - run: name: Compile test project working_directory: ~/codacy-plugins-test - command: sbt compile + command: cat /dev/null | sbt compile - run: name: Publish base docker image working_directory: ~/workdir From 85dcf2f94a8a396037f337b6bb3995a5b8670ecb Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes Date: Mon, 8 Oct 2018 18:12:18 +0100 Subject: [PATCH 012/119] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4bf31a0..2f43ef4 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,7 @@ jobs: - run: name: Compile test project working_directory: ~/codacy-plugins-test - command: cat /dev/null | sbt compile + command: cat /dev/null || sbt compile - run: name: Publish base docker image working_directory: ~/workdir From ad3f262284b6f005d41d4f8ad790ea62e7dc556e Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes Date: Thu, 18 Oct 2018 21:21:30 +0100 Subject: [PATCH 013/119] Fix running with multiple files --- .../docs/tests/syntactic_sugar.swift | 19 ++++++++++--------- .../scala/codacy/swiftlint/SwiftLint.scala | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/resources/docs/tests/syntactic_sugar.swift b/src/main/resources/docs/tests/syntactic_sugar.swift index 299ae48..8fb6bde 100644 --- a/src/main/resources/docs/tests/syntactic_sugar.swift +++ b/src/main/resources/docs/tests/syntactic_sugar.swift @@ -1,14 +1,15 @@ //#Patterns: syntactic_sugar -//#Issue: {"severity": "Info", "line": 13, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 28, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "syntactic_sugar"} let x: Array diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index 6844495..66ae5f2 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -55,8 +55,8 @@ object SwiftLint extends Tool { val command: List[String] = cfgOpt match { case Some(opt) => - baseCmd ++ List("--config", opt, "--path") ++ filesToLint - case None => baseCmd ++ List("--path") ++ filesToLint + baseCmd ++ List("--config", opt) ++ filesToLint + case None => baseCmd ++ filesToLint } CommandRunner.exec(command, Option(Paths.get(source.path).toFile)) match { From 346bb75183f660234556ff3bee81b3bfaf72d0aa Mon Sep 17 00:00:00 2001 From: IGFCoimbra <36641997+IGFCoimbra@users.noreply.github.com> Date: Tue, 30 Oct 2018 14:35:56 +0000 Subject: [PATCH 014/119] Update docs about contributing your own tool --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index 60a3bb5..42c5edd 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This is the docker engine we use at Codacy to have [Swiftlint](https://github.com/realm/SwiftLint) support. You can also create a docker to integrate the tool and language of your choice! -Check the **Docs** section for more information. +See the [codacy-engine-scala-seed](https://github.com/codacy/codacy-engine-scala-seed) repository for more information. ## Usage @@ -21,12 +21,6 @@ The docker is ran with the following command: docker run -it -v $srcDir:/src : ``` -## Docs - -[Tool Developer Guide](https://support.codacy.com/hc/en-us/articles/207994725-Tool-Developer-Guide) - -[Tool Developer Guide - Using Scala](https://support.codacy.com/hc/en-us/articles/207280379-Tool-Developer-Guide-Using-Scala) - ## Test We use the [codacy-plugins-test](https://github.com/codacy/codacy-plugins-test) to test our external tools integration. From 5ba128bb7b51ed1d1d3f4a9eb09084d124175125 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 30 Sep 2019 23:23:26 +0200 Subject: [PATCH 015/119] Add CODEOWNERS [skip ci] --- .github/CODEOWNERS | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..bf17397 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,4 @@ +* @lolgab @ljmf00 @andreaTP @rtfpessoa @bmbferreira @DReigada @pedrocodacy + +*.yml @h314to @paulopontesm + From 1399cf9f7e00adea989e8b2a8ce93e4996a522a9 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 6 Nov 2019 18:57:11 +0100 Subject: [PATCH 016/119] feature: Update SwiftLint to 0.36.0 - Update Swift to 5.1.0 - Bump Scala to 2.13.1 - Use Codacy orbs and Codacy-plugins-test orb - Use Codacy sbt plugin - Bump sbt to 1.3.3 --- .circleci/config.yml | 107 ++++++++---------- .gitignore | 2 + .scalafix.conf | 19 ---- .scalafmt.conf | 33 +++--- Dockerfile | 11 +- build.sbt | 47 ++++---- project/build.properties | 2 +- project/plugins.sbt | 15 +-- src/main/resources/docs/patterns.json | 4 +- .../scala/codacy/swiftlint/SwiftLint.scala | 13 ++- 10 files changed, 107 insertions(+), 146 deletions(-) delete mode 100644 .scalafix.conf diff --git a/.circleci/config.yml b/.circleci/config.yml index 2f43ef4..4e3bb2d 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,63 +1,52 @@ -version: 2 -jobs: - build: - machine: true - working_directory: ~/workdir - steps: - - checkout - - run: - name: Clone test project - working_directory: ~/ - command: | - (git -C ~/codacy-plugins-test fetch --all && - git -C ~/codacy-plugins-test reset --hard origin/master) || - git clone git://github.com/codacy/codacy-plugins-test.git ~/codacy-plugins-test - - restore_cache: - key: dependencies-{{ checksum "build.sbt" }} - - run: - name: Compile test project - working_directory: ~/codacy-plugins-test - command: cat /dev/null || sbt compile - - run: - name: Publish base docker image - working_directory: ~/workdir - command: docker build -t codacy/swiftlint -f Dockerfile . - - run: - name: Publish tool docker locally - working_directory: ~/workdir - command: sbt 'set version in Docker := "latest"' "set name := \"$CIRCLE_PROJECT_REPONAME\"" docker:publishLocal - - save_cache: - key: dependencies-{{ checksum "build.sbt" }} - paths: - - "~/.ivy2" - - "~/.m2" - - "~/.sbt" - - "~/codacy-plugins-test/target" - - "~/codacy-plugins-test/project/target" - - "~/codacy-plugins-test/project/project" - - "~/workdir/target" - - "~/workdir/project/target" - - "~/workdir/project/project" - - run: - name: Test json - working_directory: ~/codacy-plugins-test - command: sbt -Dcodacy.tests.ignore.descriptions=true "runMain codacy.plugins.DockerTest json $CIRCLE_PROJECT_REPONAME:latest" - - run: - name: Test patterns - working_directory: ~/codacy-plugins-test - command: sbt -Dcodacy.tests.noremove=true -Dcodacy.tests.threads=8 "runMain codacy.plugins.DockerTest pattern $CIRCLE_PROJECT_REPONAME:latest" - - deploy: - name: Push application Docker image - command: | - if [ "${CIRCLE_BRANCH}" == "master" ]; then - docker login -u $DOCKER_USER -p $DOCKER_PASS - docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME - docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME:1.0.$CIRCLE_BUILD_NUM - docker push codacy/$CIRCLE_PROJECT_REPONAME - fi +version: 2.1 + +orbs: + codacy: codacy/base@1.0.1 + codacy_plugins_test: codacy/plugins-test@0.4.0 workflows: version: 2 - build-and-deploy: + compile_test_deploy: jobs: - - build + - codacy/checkout_and_version: + write_sbt_version: true + - codacy/sbt: + name: publish_docker_local + cmd: | + docker build -t codacy/swiftlint -f Dockerfile . + sbt "set scalafmtUseIvy in ThisBuild := false; + scalafmt::test; + test:scalafmt::test; + sbt:scalafmt::test; + set name := \"$CIRCLE_PROJECT_REPONAME\"; + set version in Docker := \"latest\"; + docker:publishLocal" + docker save --output ~/workdir/docker-image.tar $CIRCLE_PROJECT_REPONAME:latest + persist_to_workspace: true + requires: + - codacy/checkout_and_version + - codacy_plugins_test/run: + name: plugins_test + requires: + - publish_docker_local + - codacy/sbt: + name: publish_dockerhub + context: CodacyDocker + cmd: | + docker load --input ~/workdir/docker-image.tar + docker login -u $DOCKER_USER -p $DOCKER_PASS + docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME:$(cat .version) + docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME:latest + docker push codacy/$CIRCLE_PROJECT_REPONAME:$(cat .version) + docker push codacy/$CIRCLE_PROJECT_REPONAME:latest + requires: + - plugins_test + filters: + branches: + only: + - master + - codacy/tag_version: + name: tag_version + context: CodacyAWS + requires: + - publish_dockerhub diff --git a/.gitignore b/.gitignore index 0a93913..5b2826f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ /target/ .idea .DS_Store +.metals +.bloop diff --git a/.scalafix.conf b/.scalafix.conf deleted file mode 100644 index bbf2fae..0000000 --- a/.scalafix.conf +++ /dev/null @@ -1,19 +0,0 @@ -rules = [ - RemoveUnused - ExplicitResultTypes - LeakingImplicitClassVal - NoAutoTupling - NoValInForComprehension - ProcedureSyntax -] - -NoInfer.symbols = [ - "java.io.Serializable", - "scala.Any", - "scala.AnyVal", - "scala.Product" -] - -ExplicitResultTypes { - unsafeShortenNames = true -} diff --git a/.scalafmt.conf b/.scalafmt.conf index d13cf26..df338e7 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,19 +1,24 @@ +version = "1.5.1" style = IntelliJ -project.excludeFilters = ["target/.*"] -maxColumn = 120 -continuationIndent.callSite = 2 -continuationIndent.defnSite = 2 + align = none -align.openParenCallSite = false -align.openParenDefnSite = true -newlines.alwaysBeforeTopLevelStatements = true -newlines.sometimesBeforeColonInMethodReturnType = true -spaces.afterKeywordBeforeParen = true +assumeStandardLibraryStripMargin = false +binPack.literalArgumentLists = true binPack.parentConstructors = false +continuationIndent.defnSite = 4 +danglingParentheses = true +docstrings = ScalaDoc includeCurlyBraceInSelectChains = true -includeCurlyBraceInSelectChains = false -optIn.breakChainOnFirstMethodDot = false +lineEndings = unix +maxColumn = 120 +newlines.alwaysBeforeTopLevelStatements = true newlines.penalizeSingleSelectMultiArgList = false -binPack.literalArgumentLists = true -danglingParentheses = false -binPack.literalsMinArgCount = 1 +newlines.sometimesBeforeColonInMethodReturnType = true +optIn.breakChainOnFirstMethodDot = true +project.git = true +rewrite.rules = [ SortImports, PreferCurlyFors ] +spaces.afterKeywordBeforeParen = true + +project.includeFilters = [".*\\.sbt$", ".*\\.scala$"] +project.excludeFilters = [".*\\.scala.html$", "target/.*", "modules/admin/target/.*"] +onTestFailure = "To fix this, run `scalafmt` within sbt or `sbt scalafmt` on the project base directory" diff --git a/Dockerfile b/Dockerfile index 5b90e31..df75be7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,15 @@ -FROM norionomura/swiftlint:0.27.0_swift-4.2.0 as build +FROM norionomura/swiftlint:0.36.0_swift-5.1.0 as build RUN strip -s /usr/bin/swiftlint && \ strip -s /usr/lib/swift/linux/*.so && \ - strip -s /usr/lib/libsourcekitdInProc.so /usr/lib/x86_64-linux-gnu/libBlocksRuntime.so.0 - -RUN chmod a+x /usr/lib/libsourcekitdInProc.so /usr/lib/x86_64-linux-gnu/libBlocksRuntime.so.0 + strip -s /usr/lib/libsourcekitdInProc.so /usr/lib/libBlocksRuntime.so +RUN chmod a+x /usr/lib/libsourcekitdInProc.so /usr/lib/libBlocksRuntime.so FROM openjdk:8-jre-slim RUN apt-get -q update && \ - apt-get -q install -y --no-install-recommends libatomic1 libcurl3 libbsd0 libxml2 wget && \ + apt-get -q install -y --no-install-recommends libatomic1 libcurl4 libbsd0 libxml2 wget && \ wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.4_amd64.deb && \ dpkg -i libicu55_55.1-7ubuntu0.4_amd64.deb && \ apt-get remove --purge -y wget && \ @@ -20,6 +19,6 @@ RUN apt-get -q update && \ COPY --from=build /usr/lib/swift/linux /usr/lib/swift/linux/ COPY --from=build /usr/bin/swiftlint /usr/bin/ COPY --from=build /usr/lib/libsourcekitdInProc.so /usr/lib/ -COPY --from=build /usr/lib/x86_64-linux-gnu/libBlocksRuntime.so.0 /usr/lib/x86_64-linux-gnu/ +COPY --from=build /usr/lib/libBlocksRuntime.so /usr/lib/ CMD [swiftlint, version] diff --git a/build.sbt b/build.sbt index 3b48c72..d7b7177 100755 --- a/build.sbt +++ b/build.sbt @@ -1,41 +1,33 @@ import com.typesafe.sbt.packager.docker.{Cmd, ExecCmd} -import scala.util.parsing.json.JSON -import scala.io.Source +import sjsonnew._ +import sjsonnew.BasicJsonProtocol._ +import sjsonnew.support.scalajson.unsafe._ -name := """codacy-swiftlint""" - -version := "1.0.0-SNAPSHOT" - -val languageVersion = "2.12.7" - -scalaVersion := languageVersion -scalacOptions ++= Seq("-Ywarn-unused") +organization := "com.codacy" -scapegoatVersion in ThisBuild := "1.3.4" +name := "codacy-swiftlint" -resolvers ++= Seq( - "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/releases", - "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/") +scalaVersion := "2.13.1" -libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "3.0.183" withSources ()) +libraryDependencies += "com.codacy" %% "codacy-engine-scala-seed" % "3.1.0" enablePlugins(AshScriptPlugin) enablePlugins(DockerPlugin) -version in Docker := "1.0.0-SNAPSHOT" - -organization := "com.codacy" +lazy val toolVersionKey = settingKey[String]("The version of the underlying tool retrieved from patterns.json") -lazy val toolVersion = SettingKey[String]("retrieve the version of the underlying tool from patterns.json") +toolVersionKey := { + case class Patterns(name: String, version: String) + implicit val patternsIso: IsoLList[Patterns] = + LList.isoCurried((p: Patterns) => ("name", p.name) :*: ("version", p.version) :*: LNil) { + case (_, n) :*: (_, v) :*: LNil => Patterns(n, v) + } -toolVersion := { val jsonFile = (resourceDirectory in Compile).value / "docs" / "patterns.json" - val toolMap = JSON - .parseFull(Source.fromFile(jsonFile).getLines().mkString) - .getOrElse(throw new Exception("patterns.json is not a valid json")) - .asInstanceOf[Map[String, String]] - toolMap.getOrElse[String]("version", throw new Exception("Failed to retrieve 'version' from patterns.json")) + val json = Parser.parseFromFile(jsonFile) + val patterns = json.flatMap(Converter.fromJson[Patterns]) + patterns.get.version } mappings in Universal ++= { @@ -56,13 +48,14 @@ daemonUser in Docker := dockerUser daemonGroup in Docker := dockerGroup -dockerBaseImage := s"codacy/swiftlint" +dockerBaseImage := "codacy/swiftlint" dockerCommands := dockerCommands.value.flatMap { case cmd @ (Cmd("ADD", _)) => List( Cmd("RUN", s"""adduser --uid 2004 --disabled-password --gecos \"\" $dockerUser"""), cmd, - Cmd("RUN", "mv /opt/docker/docs /docs")) + Cmd("RUN", "mv /opt/docker/docs /docs") + ) case other => List(other) } diff --git a/project/build.properties b/project/build.properties index 5f528e4..6adcdc7 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.3 \ No newline at end of file +sbt.version=1.3.3 diff --git a/project/plugins.sbt b/project/plugins.sbt index 8102c5e..c6e5fa8 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,13 +1,2 @@ -// Packaging (Docker) -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.6") - -// Static Analysis -addSbtPlugin("com.sksamuel.scapegoat" %% "sbt-scapegoat" % "1.0.9") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.0") - -// Formating -addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1") - -// Dependencies -addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.4") -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2") +resolvers += Resolver.jcenterRepo +addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "17.1.4") diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index 0a7151a..0389db2 100755 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1,6 +1,6 @@ { - "name": "swiftlint", - "version": "0.27.0", + "name": "SwiftLint", + "version": "0.36.0", "patterns": [ { "patternId": "attributes", diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index 66ae5f2..cd28bbf 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -31,10 +31,11 @@ object SwiftLint extends Tool { private lazy val nativeConfigFileNames = Set(".swiftlint.yml") override def apply( - source: Source.Directory, - configuration: Option[List[Pattern.Definition]], - files: Option[Set[Source.File]], - options: Map[Options.Key, Options.Value])(implicit specification: Tool.Specification): Try[List[Result]] = { + source: Source.Directory, + configuration: Option[List[Pattern.Definition]], + files: Option[Set[Source.File]], + options: Map[Options.Key, Options.Value] + )(implicit specification: Tool.Specification): Try[List[Result]] = { Try { lazy val nativeConfig = @@ -119,7 +120,9 @@ object SwiftLint extends Tool { Source.File(violation.file), Result.Message(violation.reason), Pattern.Id(violation.rule_id), - Source.Line(violation.line))) + Source.Line(violation.line) + ) + ) } } } From f653941a48fb79d3ccff1a07488b3ac06e61bef8 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 7 Nov 2019 10:31:23 +0100 Subject: [PATCH 017/119] fix: Use directly swiftlint image since no compatible with openjdk image --- Dockerfile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index df75be7..982845a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,19 +6,12 @@ RUN strip -s /usr/bin/swiftlint && \ RUN chmod a+x /usr/lib/libsourcekitdInProc.so /usr/lib/libBlocksRuntime.so -FROM openjdk:8-jre-slim - RUN apt-get -q update && \ - apt-get -q install -y --no-install-recommends libatomic1 libcurl4 libbsd0 libxml2 wget && \ + apt-get -q install -y --no-install-recommends openjdk-8-jre libatomic1 libcurl3 libbsd0 libxml2 wget && \ wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.4_amd64.deb && \ dpkg -i libicu55_55.1-7ubuntu0.4_amd64.deb && \ apt-get remove --purge -y wget && \ apt-get clean && \ rm -rf libicu55_55.1-7ubuntu0.4_amd64.deb /var/lib/apt/lists/* -COPY --from=build /usr/lib/swift/linux /usr/lib/swift/linux/ -COPY --from=build /usr/bin/swiftlint /usr/bin/ -COPY --from=build /usr/lib/libsourcekitdInProc.so /usr/lib/ -COPY --from=build /usr/lib/libBlocksRuntime.so /usr/lib/ - -CMD [swiftlint, version] +CMD swiftlint version From 92493a75ba3eb10602bbfb48872ed6aa63dbf7e7 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 26 Dec 2019 18:13:29 +0100 Subject: [PATCH 018/119] bump: Bump codacy orbs - Rename codacy/swiftlint image to codacy-swiftlint-base --- .circleci/config.yml | 6 +++--- build.sbt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4e3bb2d..afea551 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ version: 2.1 orbs: - codacy: codacy/base@1.0.1 - codacy_plugins_test: codacy/plugins-test@0.4.0 + codacy: codacy/base@1.2.1 + codacy_plugins_test: codacy/plugins-test@0.6.6 workflows: version: 2 @@ -13,7 +13,7 @@ workflows: - codacy/sbt: name: publish_docker_local cmd: | - docker build -t codacy/swiftlint -f Dockerfile . + docker build -t codacy-swiftlint-base . sbt "set scalafmtUseIvy in ThisBuild := false; scalafmt::test; test:scalafmt::test; diff --git a/build.sbt b/build.sbt index d7b7177..1d33eac 100755 --- a/build.sbt +++ b/build.sbt @@ -48,7 +48,7 @@ daemonUser in Docker := dockerUser daemonGroup in Docker := dockerGroup -dockerBaseImage := "codacy/swiftlint" +dockerBaseImage := "codacy-swiftlint-base" dockerCommands := dockerCommands.value.flatMap { case cmd @ (Cmd("ADD", _)) => From 3ea636aa266cfc2c27ad8d8dbd499709394ed6aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20=20Melo?= Date: Mon, 13 Jan 2020 10:01:16 +0000 Subject: [PATCH 019/119] bump: Bump circleci orbs version --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index afea551..69a28a3 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ version: 2.1 orbs: - codacy: codacy/base@1.2.1 - codacy_plugins_test: codacy/plugins-test@0.6.6 + codacy: codacy/base@2.0.1 + codacy_plugins_test: codacy/plugins-test@0.7.1 workflows: version: 2 @@ -21,7 +21,7 @@ workflows: set name := \"$CIRCLE_PROJECT_REPONAME\"; set version in Docker := \"latest\"; docker:publishLocal" - docker save --output ~/workdir/docker-image.tar $CIRCLE_PROJECT_REPONAME:latest + docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest persist_to_workspace: true requires: - codacy/checkout_and_version @@ -33,7 +33,7 @@ workflows: name: publish_dockerhub context: CodacyDocker cmd: | - docker load --input ~/workdir/docker-image.tar + docker load --input docker-image.tar docker login -u $DOCKER_USER -p $DOCKER_PASS docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME:$(cat .version) docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME:latest From de48ecce6c4e3835057ab722cf9681225e580e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20=20Melo?= Date: Mon, 13 Jan 2020 17:54:57 +0000 Subject: [PATCH 020/119] fix: Use specified configuration even when native is present on src folder --- src/main/scala/codacy/swiftlint/SwiftLint.scala | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index cd28bbf..bf85b6a 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -8,6 +8,8 @@ import com.codacy.tools.scala.seed.utils.{CommandRunner, FileHelper} import com.codacy.tools.scala.seed.utils.ToolHelper._ import play.api.libs.json._ +import better.files._ + import scala.util.{Failure, Properties, Success, Try} case class SwiftLintFile(rule_id: String, file: String, reason: String, line: Int) @@ -30,6 +32,13 @@ object SwiftLint extends Tool { private lazy val nativeConfigFileNames = Set(".swiftlint.yml") + def deleteNativeConfigurationFiles(source: Source.Directory): Unit = { + File(source.path) + .walk() + .find(file => nativeConfigFileNames.contains(file.name)) + .foreach(_.delete()) + } + override def apply( source: Source.Directory, configuration: Option[List[Pattern.Definition]], @@ -56,6 +65,7 @@ object SwiftLint extends Tool { val command: List[String] = cfgOpt match { case Some(opt) => + deleteNativeConfigurationFiles(source) baseCmd ++ List("--config", opt) ++ filesToLint case None => baseCmd ++ filesToLint } From 9b1a4df11792db5d045ca689ab3703b5d90ef536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20=20Melo?= Date: Mon, 13 Jan 2020 17:20:48 +0000 Subject: [PATCH 021/119] test: Multiple tests added to tool --- .../use-codacy-conf/patterns.xml | 9 ++++++ .../use-codacy-conf/results.xml | 11 +++++++ .../use-codacy-conf/src/closing_brace.swift | 1 + .../use-codacy-conf/src/dynamic_inline.swift | 1 + .../multiple-tests/with-config/patterns.xml | 7 +++++ .../multiple-tests/with-config/results.xml | 8 +++++ .../with-config/src/.swiftlint.yml | 2 ++ .../multiple-tests/with-config/src/.test.yml | 2 ++ .../with-config/src/closing_brace.swift | 9 ++++++ .../with-config/src/dynamic_inline.swift | 30 +++++++++++++++++++ 10 files changed, 80 insertions(+) create mode 100644 src/main/resources/docs/multiple-tests/use-codacy-conf/patterns.xml create mode 100644 src/main/resources/docs/multiple-tests/use-codacy-conf/results.xml create mode 120000 src/main/resources/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift create mode 120000 src/main/resources/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift create mode 100644 src/main/resources/docs/multiple-tests/with-config/patterns.xml create mode 100644 src/main/resources/docs/multiple-tests/with-config/results.xml create mode 100644 src/main/resources/docs/multiple-tests/with-config/src/.swiftlint.yml create mode 100644 src/main/resources/docs/multiple-tests/with-config/src/.test.yml create mode 100644 src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift create mode 100644 src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift diff --git a/src/main/resources/docs/multiple-tests/use-codacy-conf/patterns.xml b/src/main/resources/docs/multiple-tests/use-codacy-conf/patterns.xml new file mode 100644 index 0000000..250d6d1 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/use-codacy-conf/patterns.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/main/resources/docs/multiple-tests/use-codacy-conf/results.xml b/src/main/resources/docs/multiple-tests/use-codacy-conf/results.xml new file mode 100644 index 0000000..1f47dbc --- /dev/null +++ b/src/main/resources/docs/multiple-tests/use-codacy-conf/results.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/main/resources/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift b/src/main/resources/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift new file mode 120000 index 0000000..878b26e --- /dev/null +++ b/src/main/resources/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift @@ -0,0 +1 @@ +../../../tests/closing_brace.swift \ No newline at end of file diff --git a/src/main/resources/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift b/src/main/resources/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift new file mode 120000 index 0000000..495de27 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift @@ -0,0 +1 @@ +../../../tests/dynamic_inline.swift \ No newline at end of file diff --git a/src/main/resources/docs/multiple-tests/with-config/patterns.xml b/src/main/resources/docs/multiple-tests/with-config/patterns.xml new file mode 100644 index 0000000..b08b9a3 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/with-config/patterns.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/main/resources/docs/multiple-tests/with-config/results.xml b/src/main/resources/docs/multiple-tests/with-config/results.xml new file mode 100644 index 0000000..b8ebae9 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/with-config/results.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/main/resources/docs/multiple-tests/with-config/src/.swiftlint.yml b/src/main/resources/docs/multiple-tests/with-config/src/.swiftlint.yml new file mode 100644 index 0000000..379a22b --- /dev/null +++ b/src/main/resources/docs/multiple-tests/with-config/src/.swiftlint.yml @@ -0,0 +1,2 @@ +whitelist_rules: +- closing_brace diff --git a/src/main/resources/docs/multiple-tests/with-config/src/.test.yml b/src/main/resources/docs/multiple-tests/with-config/src/.test.yml new file mode 100644 index 0000000..cfb99ac --- /dev/null +++ b/src/main/resources/docs/multiple-tests/with-config/src/.test.yml @@ -0,0 +1,2 @@ +whitelist_rules: + - dynamic_inline diff --git a/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift b/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift new file mode 100644 index 0000000..78c9abe --- /dev/null +++ b/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift @@ -0,0 +1,9 @@ +//#Patterns: closing_brace + +//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} + + [].map({ } ) + + [].map({ } ) + diff --git a/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift b/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift new file mode 100644 index 0000000..a173305 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift @@ -0,0 +1,30 @@ +//#Patterns: dynamic_inline + +//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} + + class C { + @inline(__always) dynamic func f() {} + } + + class C { + @inline(__always) public dynamic func f() {} + } + + class C { + @inline(__always) dynamic internal func f() {} + } + + class C { + @inline(__always) + dynamic func f() {} + } + + class C { + @inline(__always) + dynamic + func f() {} + } From ca7dc6afaa205ea95538b631a70955acb9b10878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20=20Melo?= Date: Mon, 13 Jan 2020 18:39:19 +0000 Subject: [PATCH 022/119] fix: Fix tests to not use native configuration --- .../use-codacy-conf/src/.swiftlint.yml | 2 ++ .../with-config/src/.swiftlint.yml | 2 +- .../multiple-tests/with-config/src/.test.yml | 2 -- .../with-config/src/closing_brace.swift | 10 +----- .../with-config/src/dynamic_inline.swift | 31 +------------------ .../scala/codacy/swiftlint/SwiftLint.scala | 7 ++++- 6 files changed, 11 insertions(+), 43 deletions(-) create mode 100644 src/main/resources/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml delete mode 100644 src/main/resources/docs/multiple-tests/with-config/src/.test.yml mode change 100644 => 120000 src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift mode change 100644 => 120000 src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift diff --git a/src/main/resources/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml b/src/main/resources/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml new file mode 100644 index 0000000..750359b --- /dev/null +++ b/src/main/resources/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml @@ -0,0 +1,2 @@ +whitelist_rules: + - closing_brace diff --git a/src/main/resources/docs/multiple-tests/with-config/src/.swiftlint.yml b/src/main/resources/docs/multiple-tests/with-config/src/.swiftlint.yml index 379a22b..750359b 100644 --- a/src/main/resources/docs/multiple-tests/with-config/src/.swiftlint.yml +++ b/src/main/resources/docs/multiple-tests/with-config/src/.swiftlint.yml @@ -1,2 +1,2 @@ whitelist_rules: -- closing_brace + - closing_brace diff --git a/src/main/resources/docs/multiple-tests/with-config/src/.test.yml b/src/main/resources/docs/multiple-tests/with-config/src/.test.yml deleted file mode 100644 index cfb99ac..0000000 --- a/src/main/resources/docs/multiple-tests/with-config/src/.test.yml +++ /dev/null @@ -1,2 +0,0 @@ -whitelist_rules: - - dynamic_inline diff --git a/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift b/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift deleted file mode 100644 index 78c9abe..0000000 --- a/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift +++ /dev/null @@ -1,9 +0,0 @@ -//#Patterns: closing_brace - -//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} - - [].map({ } ) - - [].map({ } ) - diff --git a/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift b/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift new file mode 120000 index 0000000..878b26e --- /dev/null +++ b/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift @@ -0,0 +1 @@ +../../../tests/closing_brace.swift \ No newline at end of file diff --git a/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift b/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift deleted file mode 100644 index a173305..0000000 --- a/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift +++ /dev/null @@ -1,30 +0,0 @@ -//#Patterns: dynamic_inline - -//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} - - class C { - @inline(__always) dynamic func f() {} - } - - class C { - @inline(__always) public dynamic func f() {} - } - - class C { - @inline(__always) dynamic internal func f() {} - } - - class C { - @inline(__always) - dynamic func f() {} - } - - class C { - @inline(__always) - dynamic - func f() {} - } diff --git a/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift b/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift new file mode 120000 index 0000000..495de27 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift @@ -0,0 +1 @@ +../../../tests/dynamic_inline.swift \ No newline at end of file diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index bf85b6a..3df46f9 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -59,13 +59,18 @@ object SwiftLint extends Tool { Some(writeConfigFile(patternsToLint).toString) } + // Remove native configuration file if configuration is defined + // so that swiftlint does not use it when running + if (config.isDefined) { + deleteNativeConfigurationFiles(source) + } + val cfgOpt = config.orElse(nativeConfig) val baseCmd = List("swiftlint", "lint", "--quiet", "--reporter", "json") val command: List[String] = cfgOpt match { case Some(opt) => - deleteNativeConfigurationFiles(source) baseCmd ++ List("--config", opt) ++ filesToLint case None => baseCmd ++ filesToLint } From 57aca8460cf5fbedc7b6cce6fe9ba4e08e752669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20=20Melo?= Date: Tue, 14 Jan 2020 10:10:29 +0000 Subject: [PATCH 023/119] Add run multiple tests to circleci --- .circleci/config.yml | 1 + src/main/scala/codacy/swiftlint/SwiftLint.scala | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 69a28a3..70a8fe2 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,6 +27,7 @@ workflows: - codacy/checkout_and_version - codacy_plugins_test/run: name: plugins_test + run_multiple_tests: true requires: - publish_docker_local - codacy/sbt: diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index 3df46f9..5decefd 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -32,11 +32,11 @@ object SwiftLint extends Tool { private lazy val nativeConfigFileNames = Set(".swiftlint.yml") - def deleteNativeConfigurationFiles(source: Source.Directory): Unit = { + def deleteNativeConfigurationFiles(source: Source.Directory, newContent: String): Unit = { File(source.path) .walk() .find(file => nativeConfigFileNames.contains(file.name)) - .foreach(_.delete()) + .foreach(_.write(newContent)) } override def apply( @@ -62,7 +62,7 @@ object SwiftLint extends Tool { // Remove native configuration file if configuration is defined // so that swiftlint does not use it when running if (config.isDefined) { - deleteNativeConfigurationFiles(source) + deleteNativeConfigurationFiles(source, config.getOrElse("")) } val cfgOpt = config.orElse(nativeConfig) From a51d2df5e000e6c5d8626d5b6e93789558aba8e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20=20Melo?= Date: Tue, 14 Jan 2020 16:39:54 +0000 Subject: [PATCH 024/119] fix: Fix problem with running the tool for multiple files and custom config --- .../multiple-files/patterns.xml | 7 + .../multiple-tests/multiple-files/results.xml | 14 ++ .../multiple-files/src/.swiftlint.yml | 3 + .../multiple-files/src/closing_brace.swift | 1 + .../multiple-files/src/dynamic_inline.swift | 1 + .../scala/codacy/swiftlint/SwiftLint.scala | 140 ++++++++++++------ 6 files changed, 117 insertions(+), 49 deletions(-) create mode 100644 src/main/resources/docs/multiple-tests/multiple-files/patterns.xml create mode 100644 src/main/resources/docs/multiple-tests/multiple-files/results.xml create mode 100644 src/main/resources/docs/multiple-tests/multiple-files/src/.swiftlint.yml create mode 120000 src/main/resources/docs/multiple-tests/multiple-files/src/closing_brace.swift create mode 120000 src/main/resources/docs/multiple-tests/multiple-files/src/dynamic_inline.swift diff --git a/src/main/resources/docs/multiple-tests/multiple-files/patterns.xml b/src/main/resources/docs/multiple-tests/multiple-files/patterns.xml new file mode 100644 index 0000000..b08b9a3 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/multiple-files/patterns.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/main/resources/docs/multiple-tests/multiple-files/results.xml b/src/main/resources/docs/multiple-tests/multiple-files/results.xml new file mode 100644 index 0000000..2ed49f4 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/multiple-files/results.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/main/resources/docs/multiple-tests/multiple-files/src/.swiftlint.yml b/src/main/resources/docs/multiple-tests/multiple-files/src/.swiftlint.yml new file mode 100644 index 0000000..9744d80 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/multiple-files/src/.swiftlint.yml @@ -0,0 +1,3 @@ +whitelist_rules: + - closing_brace + - dynamic_inline diff --git a/src/main/resources/docs/multiple-tests/multiple-files/src/closing_brace.swift b/src/main/resources/docs/multiple-tests/multiple-files/src/closing_brace.swift new file mode 120000 index 0000000..878b26e --- /dev/null +++ b/src/main/resources/docs/multiple-tests/multiple-files/src/closing_brace.swift @@ -0,0 +1 @@ +../../../tests/closing_brace.swift \ No newline at end of file diff --git a/src/main/resources/docs/multiple-tests/multiple-files/src/dynamic_inline.swift b/src/main/resources/docs/multiple-tests/multiple-files/src/dynamic_inline.swift new file mode 120000 index 0000000..495de27 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/multiple-files/src/dynamic_inline.swift @@ -0,0 +1 @@ +../../../tests/dynamic_inline.swift \ No newline at end of file diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index 5decefd..8711abd 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -3,12 +3,12 @@ package codacy.swiftlint import java.nio.file.{Path, Paths} import com.codacy.plugins.api.results.{Pattern, Result, Tool} -import com.codacy.plugins.api.{Options, Source} +import com.codacy.plugins.api.{ErrorMessage, Options, Source} import com.codacy.tools.scala.seed.utils.{CommandRunner, FileHelper} import com.codacy.tools.scala.seed.utils.ToolHelper._ import play.api.libs.json._ - import better.files._ +import com.codacy.plugins.api.results.Result.FileError import scala.util.{Failure, Properties, Success, Try} @@ -32,11 +32,85 @@ object SwiftLint extends Tool { private lazy val nativeConfigFileNames = Set(".swiftlint.yml") - def deleteNativeConfigurationFiles(source: Source.Directory, newContent: String): Unit = { + def deleteNativeConfigurationFiles(source: Source.Directory): Unit = { File(source.path) .walk() .find(file => nativeConfigFileNames.contains(file.name)) - .foreach(_.write(newContent)) + .foreach(_.delete()) + } + + def listOfFilesToLint(files: Option[Set[Source.File]], source: Source.Directory): List[String] = { + val listOfFiles = files.fold(List(source.path.toString)) { paths => + paths.map(_.toString).toList + } + + if (listOfFiles.isEmpty) { + List(source.path) + } + + listOfFiles + } + + def nativeConfigurationFile(source: Source.Directory): Option[String] = { + FileHelper.findConfigurationFile(Paths.get(source.path), nativeConfigFileNames).map(_.toString) + } + + def configsFromCodacyConfiguration( + configuration: Option[List[Pattern.Definition]] + )(implicit specification: Tool.Specification): Option[String] = { + val patternsToLintOpt = configuration.withDefaultParameters + + patternsToLintOpt.fold(Option.empty[String]) { + case patternsToLint if patternsToLint.nonEmpty => + Some(writeConfigFile(patternsToLint).toString) + } + } + + def lintConfiguration(source: Source.Directory, configuration: Option[List[Pattern.Definition]])( + implicit specification: Tool.Specification + ): Option[String] = { + lazy val nativeConfig = nativeConfigurationFile(source) + + val config = configsFromCodacyConfiguration(configuration) + + config.orElse(nativeConfig) + } + + private def commandToRun(configOpt: Option[String], files: List[String]): List[String] = { + val baseCmd = List("swiftlint", "lint", "--quiet", "--reporter", "json") + + configOpt match { + case Some(opt) => + baseCmd ++ List("--config", opt) + case None => baseCmd + } + } + + private def runToolCommand( + command: List[String], + source: Source.Directory, + cfgOpt: Option[String] + ): Try[List[Result]] = { + CommandRunner.exec(command, Option(Paths.get(source.path).toFile)) match { + case Right(resultFromTool) => + parseToolResult(resultFromTool.stdout) match { + case s @ Success(_) => s + case Failure(e) => + val msg = + s""" + |${this.getClass.getSimpleName} exited with code ${resultFromTool.exitCode} + |command: ${command.mkString(" ")} + |message: ${e.getMessage} + |stdout: ${resultFromTool.stdout.mkString(Properties.lineSeparator)} + |stderr: ${resultFromTool.stderr.mkString(Properties.lineSeparator)} + |configFile: + |${cfgOpt.fold("")(p => scala.io.Source.fromFile(p).getLines().mkString("\n"))} + """.stripMargin + Failure(new Exception(msg)) + } + case Left(e) => + Failure(e) + } } override def apply( @@ -47,55 +121,23 @@ object SwiftLint extends Tool { )(implicit specification: Tool.Specification): Try[List[Result]] = { Try { - lazy val nativeConfig = - FileHelper.findConfigurationFile(Paths.get(source.path), nativeConfigFileNames).map(_.toString) - val filesToLint = files.fold(List(source.path.toString)) { paths => - paths.map(_.toString).toList - } - val patternsToLintOpt = configuration.withDefaultParameters + val filesToLint = listOfFilesToLint(files, source) - val config = patternsToLintOpt.fold(Option.empty[String]) { - case patternsToLint if patternsToLint.nonEmpty => - Some(writeConfigFile(patternsToLint).toString) - } - - // Remove native configuration file if configuration is defined - // so that swiftlint does not use it when running - if (config.isDefined) { - deleteNativeConfigurationFiles(source, config.getOrElse("")) - } - - val cfgOpt = config.orElse(nativeConfig) + val cfgOpt = lintConfiguration(source, configuration) - val baseCmd = List("swiftlint", "lint", "--quiet", "--reporter", "json") + filesToLint.flatMap { file => + val command: List[String] = commandToRun(cfgOpt, List(file)) - val command: List[String] = cfgOpt match { - case Some(opt) => - baseCmd ++ List("--config", opt) ++ filesToLint - case None => baseCmd ++ filesToLint + val fileCommandAnalysisResult = runToolCommand(command, source, cfgOpt) + fileCommandAnalysisResult match { + case Success(res) => res + case Failure(exception) => + List( + FileError(Source.File(file), Some(ErrorMessage(s"Failed to analyse file $file: ${exception.getMessage}"))) + ) + } } - - CommandRunner.exec(command, Option(Paths.get(source.path).toFile)) match { - case Right(resultFromTool) => - parseToolResult(resultFromTool.stdout) match { - case s @ Success(_) => s - case Failure(e) => - val msg = - s""" - |${this.getClass.getSimpleName} exited with code ${resultFromTool.exitCode} - |command: ${command.mkString(" ")} - |message: ${e.getMessage} - |stdout: ${resultFromTool.stdout.mkString(Properties.lineSeparator)} - |stderr: ${resultFromTool.stderr.mkString(Properties.lineSeparator)} - |configFile: - |${cfgOpt.fold("")(p => scala.io.Source.fromFile(p).getLines().mkString("\n"))} - """.stripMargin - Failure(new Exception(msg)) - } - case Left(e) => - Failure(e) - } - }.flatten + } } private def writeConfigFile(patternsToLint: List[Pattern.Definition]): Path = { From 4e6e515cc933411f2cf34046745cab695c3bfc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20=20Melo?= Date: Tue, 3 Mar 2020 16:35:32 +0000 Subject: [PATCH 025/119] bump: Bump codacy engine scala seed to 4.0.0 --- build.sbt | 2 +- project/build.properties | 2 +- project/plugins.sbt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 1d33eac..af4a964 100755 --- a/build.sbt +++ b/build.sbt @@ -9,7 +9,7 @@ name := "codacy-swiftlint" scalaVersion := "2.13.1" -libraryDependencies += "com.codacy" %% "codacy-engine-scala-seed" % "3.1.0" +libraryDependencies += "com.codacy" %% "codacy-engine-scala-seed" % "4.0.0" enablePlugins(AshScriptPlugin) diff --git a/project/build.properties b/project/build.properties index 6adcdc7..a919a9b 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.3 +sbt.version=1.3.8 diff --git a/project/plugins.sbt b/project/plugins.sbt index c6e5fa8..287d94d 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,2 @@ resolvers += Resolver.jcenterRepo -addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "17.1.4") +addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "18.0.5") From 77a2abcfcb4d3f33aa37cc6f7fec542ebd953beb Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 13 Mar 2020 15:18:05 +0000 Subject: [PATCH 026/119] fix: Fix Codacy badge link --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 42c5edd..bf38b9a 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c19f9b18251e4dc5bce89b0a70d0bc70)](https://app.codacy.com/gh/codacy/codacy-swiftlint?utm_source=github.com&utm_medium=referral&utm_content=codacy/codacy-swiftlint&utm_campaign=Badge_Grade_Settings) [![Build Status](https://circleci.com/gh/codacy/codacy-swiftlint.svg?style=shield&circle-token=:circle-token)](https://circleci.com/gh/codacy/codacy-swiftlint) # Codacy Swiftlint From fe7d96ff790e734a88f8dd39f8327f0a6a421419 Mon Sep 17 00:00:00 2001 From: Francisco Duarte Date: Wed, 20 May 2020 18:03:23 +0100 Subject: [PATCH 027/119] fix: Change tool to only analyse files passed as input (#18) The bug caused the tool to run for every file times the number of files. Now it should only run once per file --- Dockerfile | 6 +++--- build.sbt | 2 ++ src/main/scala/codacy/swiftlint/SwiftLint.scala | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 982845a..050485a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,10 +8,10 @@ RUN chmod a+x /usr/lib/libsourcekitdInProc.so /usr/lib/libBlocksRuntime.so RUN apt-get -q update && \ apt-get -q install -y --no-install-recommends openjdk-8-jre libatomic1 libcurl3 libbsd0 libxml2 wget && \ - wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.4_amd64.deb && \ - dpkg -i libicu55_55.1-7ubuntu0.4_amd64.deb && \ + wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.5_amd64.deb && \ + dpkg -i libicu55_55.1-7ubuntu0.5_amd64.deb && \ apt-get remove --purge -y wget && \ apt-get clean && \ - rm -rf libicu55_55.1-7ubuntu0.4_amd64.deb /var/lib/apt/lists/* + rm -rf libicu55_55.1-7ubuntu0.5_amd64.deb /var/lib/apt/lists/* CMD swiftlint version diff --git a/build.sbt b/build.sbt index af4a964..e9286d8 100755 --- a/build.sbt +++ b/build.sbt @@ -15,6 +15,8 @@ enablePlugins(AshScriptPlugin) enablePlugins(DockerPlugin) +scalacOptions ++= Seq("-Ywarn-unused:_", "-Xfatal-warnings") + lazy val toolVersionKey = settingKey[String]("The version of the underlying tool retrieved from patterns.json") toolVersionKey := { diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index 8711abd..eece825 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -76,14 +76,15 @@ object SwiftLint extends Tool { config.orElse(nativeConfig) } - private def commandToRun(configOpt: Option[String], files: List[String]): List[String] = { + private def commandToRun(configOpt: Option[String], file: String): List[String] = { val baseCmd = List("swiftlint", "lint", "--quiet", "--reporter", "json") - configOpt match { + val configCmd = configOpt match { case Some(opt) => baseCmd ++ List("--config", opt) case None => baseCmd } + configCmd :+ file } private def runToolCommand( @@ -126,7 +127,7 @@ object SwiftLint extends Tool { val cfgOpt = lintConfiguration(source, configuration) filesToLint.flatMap { file => - val command: List[String] = commandToRun(cfgOpt, List(file)) + val command: List[String] = commandToRun(cfgOpt, file) val fileCommandAnalysisResult = runToolCommand(command, source, cfgOpt) fileCommandAnalysisResult match { From aaf4df21dfd0495702fc35fdcc9722ad311d8bb7 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Fri, 5 Jun 2020 13:26:05 +0200 Subject: [PATCH 028/119] test: Add test to filter files - Bump codacy-plugins-test and base orb codacy-plugins-test had a bug that didn't allow test to correctly check for duplicated results. --- .circleci/config.yml | 4 +-- .../multiple-tests/filter-files/patterns.xml | 7 +++++ .../multiple-tests/filter-files/results.xml | 7 +++++ .../filter-files/src/.swiftlint.yml | 3 ++ .../filter-files/src/closing_brace.swift | 9 ++++++ .../filter-files/src/dynamic_inline.swift | 30 +++++++++++++++++++ 6 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/docs/multiple-tests/filter-files/patterns.xml create mode 100644 src/main/resources/docs/multiple-tests/filter-files/results.xml create mode 100644 src/main/resources/docs/multiple-tests/filter-files/src/.swiftlint.yml create mode 100644 src/main/resources/docs/multiple-tests/filter-files/src/closing_brace.swift create mode 100644 src/main/resources/docs/multiple-tests/filter-files/src/dynamic_inline.swift diff --git a/.circleci/config.yml b/.circleci/config.yml index 70a8fe2..c60de81 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ version: 2.1 orbs: - codacy: codacy/base@2.0.1 - codacy_plugins_test: codacy/plugins-test@0.7.1 + codacy: codacy/base@4.1.4 + codacy_plugins_test: codacy/plugins-test@0.13.0 workflows: version: 2 diff --git a/src/main/resources/docs/multiple-tests/filter-files/patterns.xml b/src/main/resources/docs/multiple-tests/filter-files/patterns.xml new file mode 100644 index 0000000..94ef14d --- /dev/null +++ b/src/main/resources/docs/multiple-tests/filter-files/patterns.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/main/resources/docs/multiple-tests/filter-files/results.xml b/src/main/resources/docs/multiple-tests/filter-files/results.xml new file mode 100644 index 0000000..a764c92 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/filter-files/results.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/main/resources/docs/multiple-tests/filter-files/src/.swiftlint.yml b/src/main/resources/docs/multiple-tests/filter-files/src/.swiftlint.yml new file mode 100644 index 0000000..9744d80 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/filter-files/src/.swiftlint.yml @@ -0,0 +1,3 @@ +whitelist_rules: + - closing_brace + - dynamic_inline diff --git a/src/main/resources/docs/multiple-tests/filter-files/src/closing_brace.swift b/src/main/resources/docs/multiple-tests/filter-files/src/closing_brace.swift new file mode 100644 index 0000000..78c9abe --- /dev/null +++ b/src/main/resources/docs/multiple-tests/filter-files/src/closing_brace.swift @@ -0,0 +1,9 @@ +//#Patterns: closing_brace + +//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} + + [].map({ } ) + + [].map({ } ) + diff --git a/src/main/resources/docs/multiple-tests/filter-files/src/dynamic_inline.swift b/src/main/resources/docs/multiple-tests/filter-files/src/dynamic_inline.swift new file mode 100644 index 0000000..a173305 --- /dev/null +++ b/src/main/resources/docs/multiple-tests/filter-files/src/dynamic_inline.swift @@ -0,0 +1,30 @@ +//#Patterns: dynamic_inline + +//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} + + class C { + @inline(__always) dynamic func f() {} + } + + class C { + @inline(__always) public dynamic func f() {} + } + + class C { + @inline(__always) dynamic internal func f() {} + } + + class C { + @inline(__always) + dynamic func f() {} + } + + class C { + @inline(__always) + dynamic + func f() {} + } From b86575a4a4038f63523240dcd3b4e26301d5320b Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Fri, 5 Jun 2020 13:28:12 +0200 Subject: [PATCH 029/119] clean: Update CODEOWNERS --- .github/CODEOWNERS | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index bf17397..30f4c10 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1 @@ -* @lolgab @ljmf00 @andreaTP @rtfpessoa @bmbferreira @DReigada @pedrocodacy - -*.yml @h314to @paulopontesm - +* @codacy/toss From 3d2be9d9c80d21ca01aee594eb491771d300939a Mon Sep 17 00:00:00 2001 From: Francisco Duarte Date: Fri, 17 Jul 2020 15:39:32 +0100 Subject: [PATCH 030/119] fix: Replace patterns.json name with short name :breaking: (#23) --- src/main/resources/docs/patterns.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/docs/patterns.json b/src/main/resources/docs/patterns.json index 0389db2..b9cbd63 100755 --- a/src/main/resources/docs/patterns.json +++ b/src/main/resources/docs/patterns.json @@ -1,5 +1,5 @@ { - "name": "SwiftLint", + "name": "swiftlint", "version": "0.36.0", "patterns": [ { From 6cf77bd62865446bb257a8e70ed75021f55f3c69 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 20 Jul 2020 17:25:16 +0200 Subject: [PATCH 031/119] feature: Update Swiftlint and use native-image - Update Swiftlint to 0.39.2 --- .circleci/config.yml | 23 ++---- .dockerignore | 11 +++ Dockerfile | 25 +++---- Dockerfile.dev | 11 +++ README.md | 7 +- build.sbt | 70 ++++--------------- .../description/description.json | 0 .../multiple-tests/filter-files/patterns.xml | 0 .../multiple-tests/filter-files/results.xml | 0 .../filter-files/src/.swiftlint.yml | 0 .../filter-files/src/closing_brace.swift | 0 .../filter-files/src/dynamic_inline.swift | 0 .../multiple-files/patterns.xml | 0 .../multiple-tests/multiple-files/results.xml | 0 .../multiple-files/src/.swiftlint.yml | 0 .../multiple-files/src}/closing_brace.swift | 0 .../multiple-files/src}/dynamic_inline.swift | 0 .../use-codacy-conf/patterns.xml | 0 .../use-codacy-conf/results.xml | 0 .../use-codacy-conf/src/.swiftlint.yml | 0 .../use-codacy-conf/src/closing_brace.swift | 9 +++ .../use-codacy-conf/src/dynamic_inline.swift | 30 ++++++++ .../multiple-tests/with-config/patterns.xml | 0 .../multiple-tests/with-config/results.xml | 0 .../with-config/src/.swiftlint.yml | 0 .../with-config/src/closing_brace.swift | 9 +++ .../with-config/src/dynamic_inline.swift | 30 ++++++++ .../resources/docs => docs}/patterns.json | 0 .../docs => docs}/tests/array_init.swift | 0 .../docs => docs}/tests/attributes.swift | 0 .../docs => docs}/tests/block_based_kvo.swift | 0 .../tests/class_delegate_protocol.swift | 0 docs/tests/closing_brace.swift | 9 +++ .../tests/closure_end_indentation.swift | 0 .../tests/closure_parameter_position.swift | 0 .../docs => docs}/tests/closure_spacing.swift | 0 .../resources/docs => docs}/tests/colon.swift | 0 .../resources/docs => docs}/tests/comma.swift | 0 .../tests/compiler_protocol_init.swift | 0 .../conditional_returns_on_newline.swift | 0 .../tests/contains_over_first_not_nil.swift | 0 .../tests/control_statement.swift | 0 .../tests/cyclomatic_complexity.swift | 0 ...scarded_notification_center_observer.swift | 0 .../tests/discouraged_direct_init.swift | 0 .../tests/discouraged_object_literal.swift | 0 .../tests/discouraged_optional_boolean.swift | 0 docs/tests/dynamic_inline.swift | 30 ++++++++ .../docs => docs}/tests/empty_count.swift | 0 .../tests/empty_enum_arguments.swift | 0 .../tests/empty_parameters.swift | 0 ...ty_parentheses_with_trailing_closure.swift | 0 .../docs => docs}/tests/explicit_acl.swift | 0 .../tests/explicit_enum_raw_value.swift | 0 .../docs => docs}/tests/explicit_init.swift | 0 .../tests/explicit_top_level_acl.swift | 0 .../tests/explicit_type_interface.swift | 0 .../tests/extension_access_modifier.swift | 0 .../docs => docs}/tests/fallthrough.swift | 0 .../tests/fatal_error_message.swift | 0 .../docs => docs}/tests/file_header.swift | 0 .../docs => docs}/tests/file_length.swift | 0 .../docs => docs}/tests/first_where.swift | 0 .../docs => docs}/tests/for_where.swift | 0 .../docs => docs}/tests/force_cast.swift | 0 .../docs => docs}/tests/force_try.swift | 0 .../tests/force_unwrapping.swift | 0 .../tests/function_parameter_count.swift | 0 .../tests/generic_type_name.swift | 0 .../docs => docs}/tests/identifier_name.swift | 0 .../docs => docs}/tests/implicit_getter.swift | 0 .../docs => docs}/tests/implicit_return.swift | 0 .../tests/implicitly_unwrapped_optional.swift | 0 .../docs => docs}/tests/is_disjoint.swift | 0 .../tests/joined_default_parameter.swift | 0 .../docs => docs}/tests/large_tuple.swift | 0 .../tests/legacy_cggeometry_functions.swift | 0 .../docs => docs}/tests/legacy_constant.swift | 0 .../tests/legacy_constructor.swift | 0 .../tests/legacy_nsgeometry_functions.swift | 0 .../tests/let_var_whitespace.swift | 0 .../docs => docs}/tests/line_length.swift | 0 .../literal_expression_end_indentation.swift | 0 .../resources/docs => docs}/tests/mark.swift | 0 .../tests/multiline_arguments.swift | 0 .../tests/multiline_parameters.swift | 0 ...tiple_closures_with_trailing_closure.swift | 0 .../docs => docs}/tests/nesting.swift | 0 .../docs => docs}/tests/nimble_operator.swift | 0 .../tests/no_extension_access_modifier.swift | 0 .../tests/no_grouping_extension.swift | 0 .../notification_center_detachment.swift | 0 .../tests/number_separator.swift | 0 .../docs => docs}/tests/object_literal.swift | 0 .../docs => docs}/tests/opening_brace.swift | 0 .../tests/operator_usage_whitespace.swift | 0 .../tests/operator_whitespace.swift | 0 .../tests/overridden_super_call.swift | 0 .../tests/override_in_extension.swift | 0 .../tests/pattern_matching_keywords.swift | 0 .../tests/prefixed_toplevel_constant.swift | 0 .../docs => docs}/tests/private_action.swift | 0 .../docs => docs}/tests/private_outlet.swift | 0 .../tests/private_over_fileprivate.swift | 0 .../tests/private_unit_test.swift | 0 .../tests/prohibited_super_call.swift | 0 .../protocol_property_accessors_order.swift | 0 .../tests/quick_discouraged_call.swift | 0 .../quick_discouraged_focused_test.swift | 0 .../quick_discouraged_pending_test.swift | 0 .../tests/redundant_discardable_let.swift | 0 .../tests/redundant_nil_coalescing.swift | 0 .../redundant_optional_initialization.swift | 0 .../tests/redundant_string_enum_value.swift | 0 .../tests/redundant_void_return.swift | 0 .../tests/required_enum_case.swift | 0 .../tests/return_arrow_whitespace.swift | 0 .../tests/shorthand_operator.swift | 0 .../tests/single_test_class.swift | 0 .../tests/sorted_first_last.swift | 0 .../docs => docs}/tests/sorted_imports.swift | 0 .../tests/statement_position.swift | 0 .../tests/strict_fileprivate.swift | 0 .../tests/superfluous_disable_command.swift | 0 .../tests/switch_case_alignment.swift | 0 .../tests/switch_case_on_newline.swift | 0 .../docs => docs}/tests/syntactic_sugar.swift | 0 .../resources/docs => docs}/tests/todo.swift | 0 .../tests/trailing_closure.swift | 0 .../docs => docs}/tests/trailing_comma.swift | 0 .../tests/trailing_semicolon.swift | 0 .../tests/type_body_length.swift | 0 .../docs => docs}/tests/type_name.swift | 0 .../tests/unneeded_break_in_switch.swift | 0 ...eded_parentheses_in_closure_argument.swift | 0 .../tests/unused_closure_parameter.swift | 0 .../tests/unused_enumerated.swift | 0 .../tests/unused_optional_binding.swift | 0 .../tests/valid_ibinspectable.swift | 0 .../tests/vertical_parameter_alignment.swift | 0 ...vertical_parameter_alignment_on_call.swift | 0 .../tests/vertical_whitespace.swift | 0 .../docs => docs}/tests/void_return.swift | 0 .../docs => docs}/tests/weak_delegate.swift | 0 .../docs => docs}/tests/xctfail_message.swift | 0 .../docs => docs}/tests/yoda_condition.swift | 0 .../docs => docs}/tool-description.md | 0 project/plugins.sbt | 4 +- .../multiple-files/src/closing_brace.swift | 1 - .../multiple-files/src/dynamic_inline.swift | 1 - .../use-codacy-conf/src/closing_brace.swift | 1 - .../use-codacy-conf/src/dynamic_inline.swift | 1 - .../with-config/src/closing_brace.swift | 1 - .../with-config/src/dynamic_inline.swift | 1 - .../scala/codacy/swiftlint/SwiftLint.scala | 12 ++-- 155 files changed, 178 insertions(+), 108 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile.dev rename {src/main/resources/docs => docs}/description/description.json (100%) rename {src/main/resources/docs => docs}/multiple-tests/filter-files/patterns.xml (100%) rename {src/main/resources/docs => docs}/multiple-tests/filter-files/results.xml (100%) rename {src/main/resources/docs => docs}/multiple-tests/filter-files/src/.swiftlint.yml (100%) rename {src/main/resources/docs => docs}/multiple-tests/filter-files/src/closing_brace.swift (100%) rename {src/main/resources/docs => docs}/multiple-tests/filter-files/src/dynamic_inline.swift (100%) rename {src/main/resources/docs => docs}/multiple-tests/multiple-files/patterns.xml (100%) rename {src/main/resources/docs => docs}/multiple-tests/multiple-files/results.xml (100%) rename {src/main/resources/docs => docs}/multiple-tests/multiple-files/src/.swiftlint.yml (100%) rename {src/main/resources/docs/tests => docs/multiple-tests/multiple-files/src}/closing_brace.swift (100%) rename {src/main/resources/docs/tests => docs/multiple-tests/multiple-files/src}/dynamic_inline.swift (100%) rename {src/main/resources/docs => docs}/multiple-tests/use-codacy-conf/patterns.xml (100%) rename {src/main/resources/docs => docs}/multiple-tests/use-codacy-conf/results.xml (100%) rename {src/main/resources/docs => docs}/multiple-tests/use-codacy-conf/src/.swiftlint.yml (100%) create mode 100644 docs/multiple-tests/use-codacy-conf/src/closing_brace.swift create mode 100644 docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift rename {src/main/resources/docs => docs}/multiple-tests/with-config/patterns.xml (100%) rename {src/main/resources/docs => docs}/multiple-tests/with-config/results.xml (100%) rename {src/main/resources/docs => docs}/multiple-tests/with-config/src/.swiftlint.yml (100%) create mode 100644 docs/multiple-tests/with-config/src/closing_brace.swift create mode 100644 docs/multiple-tests/with-config/src/dynamic_inline.swift rename {src/main/resources/docs => docs}/patterns.json (100%) rename {src/main/resources/docs => docs}/tests/array_init.swift (100%) rename {src/main/resources/docs => docs}/tests/attributes.swift (100%) rename {src/main/resources/docs => docs}/tests/block_based_kvo.swift (100%) rename {src/main/resources/docs => docs}/tests/class_delegate_protocol.swift (100%) create mode 100644 docs/tests/closing_brace.swift rename {src/main/resources/docs => docs}/tests/closure_end_indentation.swift (100%) rename {src/main/resources/docs => docs}/tests/closure_parameter_position.swift (100%) rename {src/main/resources/docs => docs}/tests/closure_spacing.swift (100%) rename {src/main/resources/docs => docs}/tests/colon.swift (100%) rename {src/main/resources/docs => docs}/tests/comma.swift (100%) rename {src/main/resources/docs => docs}/tests/compiler_protocol_init.swift (100%) rename {src/main/resources/docs => docs}/tests/conditional_returns_on_newline.swift (100%) rename {src/main/resources/docs => docs}/tests/contains_over_first_not_nil.swift (100%) rename {src/main/resources/docs => docs}/tests/control_statement.swift (100%) rename {src/main/resources/docs => docs}/tests/cyclomatic_complexity.swift (100%) rename {src/main/resources/docs => docs}/tests/discarded_notification_center_observer.swift (100%) rename {src/main/resources/docs => docs}/tests/discouraged_direct_init.swift (100%) rename {src/main/resources/docs => docs}/tests/discouraged_object_literal.swift (100%) rename {src/main/resources/docs => docs}/tests/discouraged_optional_boolean.swift (100%) create mode 100644 docs/tests/dynamic_inline.swift rename {src/main/resources/docs => docs}/tests/empty_count.swift (100%) rename {src/main/resources/docs => docs}/tests/empty_enum_arguments.swift (100%) rename {src/main/resources/docs => docs}/tests/empty_parameters.swift (100%) rename {src/main/resources/docs => docs}/tests/empty_parentheses_with_trailing_closure.swift (100%) rename {src/main/resources/docs => docs}/tests/explicit_acl.swift (100%) rename {src/main/resources/docs => docs}/tests/explicit_enum_raw_value.swift (100%) rename {src/main/resources/docs => docs}/tests/explicit_init.swift (100%) rename {src/main/resources/docs => docs}/tests/explicit_top_level_acl.swift (100%) rename {src/main/resources/docs => docs}/tests/explicit_type_interface.swift (100%) rename {src/main/resources/docs => docs}/tests/extension_access_modifier.swift (100%) rename {src/main/resources/docs => docs}/tests/fallthrough.swift (100%) rename {src/main/resources/docs => docs}/tests/fatal_error_message.swift (100%) rename {src/main/resources/docs => docs}/tests/file_header.swift (100%) rename {src/main/resources/docs => docs}/tests/file_length.swift (100%) rename {src/main/resources/docs => docs}/tests/first_where.swift (100%) rename {src/main/resources/docs => docs}/tests/for_where.swift (100%) rename {src/main/resources/docs => docs}/tests/force_cast.swift (100%) rename {src/main/resources/docs => docs}/tests/force_try.swift (100%) rename {src/main/resources/docs => docs}/tests/force_unwrapping.swift (100%) rename {src/main/resources/docs => docs}/tests/function_parameter_count.swift (100%) rename {src/main/resources/docs => docs}/tests/generic_type_name.swift (100%) rename {src/main/resources/docs => docs}/tests/identifier_name.swift (100%) rename {src/main/resources/docs => docs}/tests/implicit_getter.swift (100%) rename {src/main/resources/docs => docs}/tests/implicit_return.swift (100%) rename {src/main/resources/docs => docs}/tests/implicitly_unwrapped_optional.swift (100%) rename {src/main/resources/docs => docs}/tests/is_disjoint.swift (100%) rename {src/main/resources/docs => docs}/tests/joined_default_parameter.swift (100%) rename {src/main/resources/docs => docs}/tests/large_tuple.swift (100%) rename {src/main/resources/docs => docs}/tests/legacy_cggeometry_functions.swift (100%) rename {src/main/resources/docs => docs}/tests/legacy_constant.swift (100%) rename {src/main/resources/docs => docs}/tests/legacy_constructor.swift (100%) rename {src/main/resources/docs => docs}/tests/legacy_nsgeometry_functions.swift (100%) rename {src/main/resources/docs => docs}/tests/let_var_whitespace.swift (100%) rename {src/main/resources/docs => docs}/tests/line_length.swift (100%) rename {src/main/resources/docs => docs}/tests/literal_expression_end_indentation.swift (100%) rename {src/main/resources/docs => docs}/tests/mark.swift (100%) rename {src/main/resources/docs => docs}/tests/multiline_arguments.swift (100%) rename {src/main/resources/docs => docs}/tests/multiline_parameters.swift (100%) rename {src/main/resources/docs => docs}/tests/multiple_closures_with_trailing_closure.swift (100%) rename {src/main/resources/docs => docs}/tests/nesting.swift (100%) rename {src/main/resources/docs => docs}/tests/nimble_operator.swift (100%) rename {src/main/resources/docs => docs}/tests/no_extension_access_modifier.swift (100%) rename {src/main/resources/docs => docs}/tests/no_grouping_extension.swift (100%) rename {src/main/resources/docs => docs}/tests/notification_center_detachment.swift (100%) rename {src/main/resources/docs => docs}/tests/number_separator.swift (100%) rename {src/main/resources/docs => docs}/tests/object_literal.swift (100%) rename {src/main/resources/docs => docs}/tests/opening_brace.swift (100%) rename {src/main/resources/docs => docs}/tests/operator_usage_whitespace.swift (100%) rename {src/main/resources/docs => docs}/tests/operator_whitespace.swift (100%) rename {src/main/resources/docs => docs}/tests/overridden_super_call.swift (100%) rename {src/main/resources/docs => docs}/tests/override_in_extension.swift (100%) rename {src/main/resources/docs => docs}/tests/pattern_matching_keywords.swift (100%) rename {src/main/resources/docs => docs}/tests/prefixed_toplevel_constant.swift (100%) rename {src/main/resources/docs => docs}/tests/private_action.swift (100%) rename {src/main/resources/docs => docs}/tests/private_outlet.swift (100%) rename {src/main/resources/docs => docs}/tests/private_over_fileprivate.swift (100%) rename {src/main/resources/docs => docs}/tests/private_unit_test.swift (100%) rename {src/main/resources/docs => docs}/tests/prohibited_super_call.swift (100%) rename {src/main/resources/docs => docs}/tests/protocol_property_accessors_order.swift (100%) rename {src/main/resources/docs => docs}/tests/quick_discouraged_call.swift (100%) rename {src/main/resources/docs => docs}/tests/quick_discouraged_focused_test.swift (100%) rename {src/main/resources/docs => docs}/tests/quick_discouraged_pending_test.swift (100%) rename {src/main/resources/docs => docs}/tests/redundant_discardable_let.swift (100%) rename {src/main/resources/docs => docs}/tests/redundant_nil_coalescing.swift (100%) rename {src/main/resources/docs => docs}/tests/redundant_optional_initialization.swift (100%) rename {src/main/resources/docs => docs}/tests/redundant_string_enum_value.swift (100%) rename {src/main/resources/docs => docs}/tests/redundant_void_return.swift (100%) rename {src/main/resources/docs => docs}/tests/required_enum_case.swift (100%) rename {src/main/resources/docs => docs}/tests/return_arrow_whitespace.swift (100%) rename {src/main/resources/docs => docs}/tests/shorthand_operator.swift (100%) rename {src/main/resources/docs => docs}/tests/single_test_class.swift (100%) rename {src/main/resources/docs => docs}/tests/sorted_first_last.swift (100%) rename {src/main/resources/docs => docs}/tests/sorted_imports.swift (100%) rename {src/main/resources/docs => docs}/tests/statement_position.swift (100%) rename {src/main/resources/docs => docs}/tests/strict_fileprivate.swift (100%) rename {src/main/resources/docs => docs}/tests/superfluous_disable_command.swift (100%) rename {src/main/resources/docs => docs}/tests/switch_case_alignment.swift (100%) rename {src/main/resources/docs => docs}/tests/switch_case_on_newline.swift (100%) rename {src/main/resources/docs => docs}/tests/syntactic_sugar.swift (100%) rename {src/main/resources/docs => docs}/tests/todo.swift (100%) rename {src/main/resources/docs => docs}/tests/trailing_closure.swift (100%) rename {src/main/resources/docs => docs}/tests/trailing_comma.swift (100%) rename {src/main/resources/docs => docs}/tests/trailing_semicolon.swift (100%) rename {src/main/resources/docs => docs}/tests/type_body_length.swift (100%) rename {src/main/resources/docs => docs}/tests/type_name.swift (100%) rename {src/main/resources/docs => docs}/tests/unneeded_break_in_switch.swift (100%) rename {src/main/resources/docs => docs}/tests/unneeded_parentheses_in_closure_argument.swift (100%) rename {src/main/resources/docs => docs}/tests/unused_closure_parameter.swift (100%) rename {src/main/resources/docs => docs}/tests/unused_enumerated.swift (100%) rename {src/main/resources/docs => docs}/tests/unused_optional_binding.swift (100%) rename {src/main/resources/docs => docs}/tests/valid_ibinspectable.swift (100%) rename {src/main/resources/docs => docs}/tests/vertical_parameter_alignment.swift (100%) rename {src/main/resources/docs => docs}/tests/vertical_parameter_alignment_on_call.swift (100%) rename {src/main/resources/docs => docs}/tests/vertical_whitespace.swift (100%) rename {src/main/resources/docs => docs}/tests/void_return.swift (100%) rename {src/main/resources/docs => docs}/tests/weak_delegate.swift (100%) rename {src/main/resources/docs => docs}/tests/xctfail_message.swift (100%) rename {src/main/resources/docs => docs}/tests/yoda_condition.swift (100%) rename {src/main/resources/docs => docs}/tool-description.md (100%) delete mode 120000 src/main/resources/docs/multiple-tests/multiple-files/src/closing_brace.swift delete mode 120000 src/main/resources/docs/multiple-tests/multiple-files/src/dynamic_inline.swift delete mode 120000 src/main/resources/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift delete mode 120000 src/main/resources/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift delete mode 120000 src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift delete mode 120000 src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift diff --git a/.circleci/config.yml b/.circleci/config.yml index c60de81..f4803cd 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codacy: codacy/base@4.1.4 + codacy: codacy/base@4.2.7 codacy_plugins_test: codacy/plugins-test@0.13.0 workflows: @@ -13,14 +13,11 @@ workflows: - codacy/sbt: name: publish_docker_local cmd: | - docker build -t codacy-swiftlint-base . - sbt "set scalafmtUseIvy in ThisBuild := false; - scalafmt::test; + sbt "scalafmt::test; test:scalafmt::test; sbt:scalafmt::test; - set name := \"$CIRCLE_PROJECT_REPONAME\"; - set version in Docker := \"latest\"; - docker:publishLocal" + graalvm-native-image:packageBin" + docker build -t $CIRCLE_PROJECT_REPONAME:latest . docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest persist_to_workspace: true requires: @@ -30,16 +27,8 @@ workflows: run_multiple_tests: true requires: - publish_docker_local - - codacy/sbt: - name: publish_dockerhub + - codacy/publish_docker: context: CodacyDocker - cmd: | - docker load --input docker-image.tar - docker login -u $DOCKER_USER -p $DOCKER_PASS - docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME:$(cat .version) - docker tag $CIRCLE_PROJECT_REPONAME codacy/$CIRCLE_PROJECT_REPONAME:latest - docker push codacy/$CIRCLE_PROJECT_REPONAME:$(cat .version) - docker push codacy/$CIRCLE_PROJECT_REPONAME:latest requires: - plugins_test filters: @@ -50,4 +39,4 @@ workflows: name: tag_version context: CodacyAWS requires: - - publish_dockerhub + - codacy/publish_docker diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..45c2e43 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +# Ignore everything +** + +# Allow files and directories +!/target/graalvm-native-image/codacy-swiftlint +!/target/universal/stage/ +!/docs + +# Ignore unnecessary files inside allowed directories +# This should go after the allowed directories +**/.DS_Store diff --git a/Dockerfile b/Dockerfile index 050485a..0b302ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,8 @@ -FROM norionomura/swiftlint:0.36.0_swift-5.1.0 as build - -RUN strip -s /usr/bin/swiftlint && \ - strip -s /usr/lib/swift/linux/*.so && \ - strip -s /usr/lib/libsourcekitdInProc.so /usr/lib/libBlocksRuntime.so - -RUN chmod a+x /usr/lib/libsourcekitdInProc.so /usr/lib/libBlocksRuntime.so - -RUN apt-get -q update && \ - apt-get -q install -y --no-install-recommends openjdk-8-jre libatomic1 libcurl3 libbsd0 libxml2 wget && \ - wget http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.5_amd64.deb && \ - dpkg -i libicu55_55.1-7ubuntu0.5_amd64.deb && \ - apt-get remove --purge -y wget && \ - apt-get clean && \ - rm -rf libicu55_55.1-7ubuntu0.5_amd64.deb /var/lib/apt/lists/* - -CMD swiftlint version +FROM norionomura/swiftlint:0.39.2 as build + +WORKDIR /src +COPY docs /docs +COPY target/graalvm-native-image/codacy-swiftlint /workdir/ +RUN adduser --uid 2004 --disabled-password --gecos "" docker +USER docker +ENTRYPOINT ["/workdir/codacy-swiftlint"] diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..a598cdf --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,11 @@ +FROM norionomura/swiftlint:0.39.2 as build + +RUN apt-get update && apt-get install -y openjdk-8-jre + +WORKDIR /src +COPY docs /docs +COPY target/universal/stage/ /workdir/ +RUN adduser --uid 2004 --disabled-password --gecos "" docker +RUN chmod +x /workdir/bin/codacy-swiftlint +USER docker +ENTRYPOINT ["/workdir/bin/codacy-swiftlint"] diff --git a/README.md b/README.md index bf38b9a..9d0cbaa 100755 --- a/README.md +++ b/README.md @@ -12,13 +12,14 @@ See the [codacy-engine-scala-seed](https://github.com/codacy/codacy-engine-scala You can create the docker by doing: -``` -sbt docker:publishLocal +```bash +sbt graalvm-native-image:packageBin +docker build -t codacy-swiftlint . ``` The docker is ran with the following command: -``` +```bash docker run -it -v $srcDir:/src : ``` diff --git a/build.sbt b/build.sbt index e9286d8..7aaaf90 100755 --- a/build.sbt +++ b/build.sbt @@ -1,63 +1,23 @@ -import com.typesafe.sbt.packager.docker.{Cmd, ExecCmd} -import sjsonnew._ -import sjsonnew.BasicJsonProtocol._ -import sjsonnew.support.scalajson.unsafe._ - organization := "com.codacy" name := "codacy-swiftlint" -scalaVersion := "2.13.1" - -libraryDependencies += "com.codacy" %% "codacy-engine-scala-seed" % "4.0.0" - -enablePlugins(AshScriptPlugin) - -enablePlugins(DockerPlugin) - -scalacOptions ++= Seq("-Ywarn-unused:_", "-Xfatal-warnings") - -lazy val toolVersionKey = settingKey[String]("The version of the underlying tool retrieved from patterns.json") - -toolVersionKey := { - case class Patterns(name: String, version: String) - implicit val patternsIso: IsoLList[Patterns] = - LList.isoCurried((p: Patterns) => ("name", p.name) :*: ("version", p.version) :*: LNil) { - case (_, n) :*: (_, v) :*: LNil => Patterns(n, v) - } - - val jsonFile = (resourceDirectory in Compile).value / "docs" / "patterns.json" - val json = Parser.parseFromFile(jsonFile) - val patterns = json.flatMap(Converter.fromJson[Patterns]) - patterns.get.version -} - -mappings in Universal ++= { - (resourceDirectory in Compile) map { (resourceDir: File) => - val src = resourceDir / "docs" - val dest = "/docs" - - for { - path <- src.allPaths.get if !path.isDirectory - } yield path -> path.toString.replaceFirst(src.toString, dest) - } -}.value - -val dockerUser = "docker" -val dockerGroup = "docker" +scalaVersion := "2.13.3" -daemonUser in Docker := dockerUser +libraryDependencies += "com.codacy" %% "codacy-engine-scala-seed" % "4.0.3" -daemonGroup in Docker := dockerGroup +enablePlugins(GraalVMNativeImagePlugin) -dockerBaseImage := "codacy-swiftlint-base" +val graalVersion = "20.1.0-java11" -dockerCommands := dockerCommands.value.flatMap { - case cmd @ (Cmd("ADD", _)) => - List( - Cmd("RUN", s"""adduser --uid 2004 --disabled-password --gecos \"\" $dockerUser"""), - cmd, - Cmd("RUN", "mv /opt/docker/docs /docs") - ) - case other => List(other) -} +graalVMNativeImageGraalVersion := Some(graalVersion) +containerBuildImage := Some(s"oracle/graalvm-ce:$graalVersion") +graalVMNativeImageOptions ++= Seq( + "-O1", + "-H:+ReportExceptionStackTraces", + "--no-fallback", + "--no-server", + "--initialize-at-build-time", + "--report-unsupported-elements-at-runtime", + "--static" +) diff --git a/src/main/resources/docs/description/description.json b/docs/description/description.json similarity index 100% rename from src/main/resources/docs/description/description.json rename to docs/description/description.json diff --git a/src/main/resources/docs/multiple-tests/filter-files/patterns.xml b/docs/multiple-tests/filter-files/patterns.xml similarity index 100% rename from src/main/resources/docs/multiple-tests/filter-files/patterns.xml rename to docs/multiple-tests/filter-files/patterns.xml diff --git a/src/main/resources/docs/multiple-tests/filter-files/results.xml b/docs/multiple-tests/filter-files/results.xml similarity index 100% rename from src/main/resources/docs/multiple-tests/filter-files/results.xml rename to docs/multiple-tests/filter-files/results.xml diff --git a/src/main/resources/docs/multiple-tests/filter-files/src/.swiftlint.yml b/docs/multiple-tests/filter-files/src/.swiftlint.yml similarity index 100% rename from src/main/resources/docs/multiple-tests/filter-files/src/.swiftlint.yml rename to docs/multiple-tests/filter-files/src/.swiftlint.yml diff --git a/src/main/resources/docs/multiple-tests/filter-files/src/closing_brace.swift b/docs/multiple-tests/filter-files/src/closing_brace.swift similarity index 100% rename from src/main/resources/docs/multiple-tests/filter-files/src/closing_brace.swift rename to docs/multiple-tests/filter-files/src/closing_brace.swift diff --git a/src/main/resources/docs/multiple-tests/filter-files/src/dynamic_inline.swift b/docs/multiple-tests/filter-files/src/dynamic_inline.swift similarity index 100% rename from src/main/resources/docs/multiple-tests/filter-files/src/dynamic_inline.swift rename to docs/multiple-tests/filter-files/src/dynamic_inline.swift diff --git a/src/main/resources/docs/multiple-tests/multiple-files/patterns.xml b/docs/multiple-tests/multiple-files/patterns.xml similarity index 100% rename from src/main/resources/docs/multiple-tests/multiple-files/patterns.xml rename to docs/multiple-tests/multiple-files/patterns.xml diff --git a/src/main/resources/docs/multiple-tests/multiple-files/results.xml b/docs/multiple-tests/multiple-files/results.xml similarity index 100% rename from src/main/resources/docs/multiple-tests/multiple-files/results.xml rename to docs/multiple-tests/multiple-files/results.xml diff --git a/src/main/resources/docs/multiple-tests/multiple-files/src/.swiftlint.yml b/docs/multiple-tests/multiple-files/src/.swiftlint.yml similarity index 100% rename from src/main/resources/docs/multiple-tests/multiple-files/src/.swiftlint.yml rename to docs/multiple-tests/multiple-files/src/.swiftlint.yml diff --git a/src/main/resources/docs/tests/closing_brace.swift b/docs/multiple-tests/multiple-files/src/closing_brace.swift similarity index 100% rename from src/main/resources/docs/tests/closing_brace.swift rename to docs/multiple-tests/multiple-files/src/closing_brace.swift diff --git a/src/main/resources/docs/tests/dynamic_inline.swift b/docs/multiple-tests/multiple-files/src/dynamic_inline.swift similarity index 100% rename from src/main/resources/docs/tests/dynamic_inline.swift rename to docs/multiple-tests/multiple-files/src/dynamic_inline.swift diff --git a/src/main/resources/docs/multiple-tests/use-codacy-conf/patterns.xml b/docs/multiple-tests/use-codacy-conf/patterns.xml similarity index 100% rename from src/main/resources/docs/multiple-tests/use-codacy-conf/patterns.xml rename to docs/multiple-tests/use-codacy-conf/patterns.xml diff --git a/src/main/resources/docs/multiple-tests/use-codacy-conf/results.xml b/docs/multiple-tests/use-codacy-conf/results.xml similarity index 100% rename from src/main/resources/docs/multiple-tests/use-codacy-conf/results.xml rename to docs/multiple-tests/use-codacy-conf/results.xml diff --git a/src/main/resources/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml b/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml similarity index 100% rename from src/main/resources/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml rename to docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml diff --git a/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift b/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift new file mode 100644 index 0000000..78c9abe --- /dev/null +++ b/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift @@ -0,0 +1,9 @@ +//#Patterns: closing_brace + +//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} + + [].map({ } ) + + [].map({ } ) + diff --git a/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift b/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift new file mode 100644 index 0000000..a173305 --- /dev/null +++ b/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift @@ -0,0 +1,30 @@ +//#Patterns: dynamic_inline + +//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} + + class C { + @inline(__always) dynamic func f() {} + } + + class C { + @inline(__always) public dynamic func f() {} + } + + class C { + @inline(__always) dynamic internal func f() {} + } + + class C { + @inline(__always) + dynamic func f() {} + } + + class C { + @inline(__always) + dynamic + func f() {} + } diff --git a/src/main/resources/docs/multiple-tests/with-config/patterns.xml b/docs/multiple-tests/with-config/patterns.xml similarity index 100% rename from src/main/resources/docs/multiple-tests/with-config/patterns.xml rename to docs/multiple-tests/with-config/patterns.xml diff --git a/src/main/resources/docs/multiple-tests/with-config/results.xml b/docs/multiple-tests/with-config/results.xml similarity index 100% rename from src/main/resources/docs/multiple-tests/with-config/results.xml rename to docs/multiple-tests/with-config/results.xml diff --git a/src/main/resources/docs/multiple-tests/with-config/src/.swiftlint.yml b/docs/multiple-tests/with-config/src/.swiftlint.yml similarity index 100% rename from src/main/resources/docs/multiple-tests/with-config/src/.swiftlint.yml rename to docs/multiple-tests/with-config/src/.swiftlint.yml diff --git a/docs/multiple-tests/with-config/src/closing_brace.swift b/docs/multiple-tests/with-config/src/closing_brace.swift new file mode 100644 index 0000000..78c9abe --- /dev/null +++ b/docs/multiple-tests/with-config/src/closing_brace.swift @@ -0,0 +1,9 @@ +//#Patterns: closing_brace + +//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} + + [].map({ } ) + + [].map({ } ) + diff --git a/docs/multiple-tests/with-config/src/dynamic_inline.swift b/docs/multiple-tests/with-config/src/dynamic_inline.swift new file mode 100644 index 0000000..a173305 --- /dev/null +++ b/docs/multiple-tests/with-config/src/dynamic_inline.swift @@ -0,0 +1,30 @@ +//#Patterns: dynamic_inline + +//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} + + class C { + @inline(__always) dynamic func f() {} + } + + class C { + @inline(__always) public dynamic func f() {} + } + + class C { + @inline(__always) dynamic internal func f() {} + } + + class C { + @inline(__always) + dynamic func f() {} + } + + class C { + @inline(__always) + dynamic + func f() {} + } diff --git a/src/main/resources/docs/patterns.json b/docs/patterns.json similarity index 100% rename from src/main/resources/docs/patterns.json rename to docs/patterns.json diff --git a/src/main/resources/docs/tests/array_init.swift b/docs/tests/array_init.swift similarity index 100% rename from src/main/resources/docs/tests/array_init.swift rename to docs/tests/array_init.swift diff --git a/src/main/resources/docs/tests/attributes.swift b/docs/tests/attributes.swift similarity index 100% rename from src/main/resources/docs/tests/attributes.swift rename to docs/tests/attributes.swift diff --git a/src/main/resources/docs/tests/block_based_kvo.swift b/docs/tests/block_based_kvo.swift similarity index 100% rename from src/main/resources/docs/tests/block_based_kvo.swift rename to docs/tests/block_based_kvo.swift diff --git a/src/main/resources/docs/tests/class_delegate_protocol.swift b/docs/tests/class_delegate_protocol.swift similarity index 100% rename from src/main/resources/docs/tests/class_delegate_protocol.swift rename to docs/tests/class_delegate_protocol.swift diff --git a/docs/tests/closing_brace.swift b/docs/tests/closing_brace.swift new file mode 100644 index 0000000..78c9abe --- /dev/null +++ b/docs/tests/closing_brace.swift @@ -0,0 +1,9 @@ +//#Patterns: closing_brace + +//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} + + [].map({ } ) + + [].map({ } ) + diff --git a/src/main/resources/docs/tests/closure_end_indentation.swift b/docs/tests/closure_end_indentation.swift similarity index 100% rename from src/main/resources/docs/tests/closure_end_indentation.swift rename to docs/tests/closure_end_indentation.swift diff --git a/src/main/resources/docs/tests/closure_parameter_position.swift b/docs/tests/closure_parameter_position.swift similarity index 100% rename from src/main/resources/docs/tests/closure_parameter_position.swift rename to docs/tests/closure_parameter_position.swift diff --git a/src/main/resources/docs/tests/closure_spacing.swift b/docs/tests/closure_spacing.swift similarity index 100% rename from src/main/resources/docs/tests/closure_spacing.swift rename to docs/tests/closure_spacing.swift diff --git a/src/main/resources/docs/tests/colon.swift b/docs/tests/colon.swift similarity index 100% rename from src/main/resources/docs/tests/colon.swift rename to docs/tests/colon.swift diff --git a/src/main/resources/docs/tests/comma.swift b/docs/tests/comma.swift similarity index 100% rename from src/main/resources/docs/tests/comma.swift rename to docs/tests/comma.swift diff --git a/src/main/resources/docs/tests/compiler_protocol_init.swift b/docs/tests/compiler_protocol_init.swift similarity index 100% rename from src/main/resources/docs/tests/compiler_protocol_init.swift rename to docs/tests/compiler_protocol_init.swift diff --git a/src/main/resources/docs/tests/conditional_returns_on_newline.swift b/docs/tests/conditional_returns_on_newline.swift similarity index 100% rename from src/main/resources/docs/tests/conditional_returns_on_newline.swift rename to docs/tests/conditional_returns_on_newline.swift diff --git a/src/main/resources/docs/tests/contains_over_first_not_nil.swift b/docs/tests/contains_over_first_not_nil.swift similarity index 100% rename from src/main/resources/docs/tests/contains_over_first_not_nil.swift rename to docs/tests/contains_over_first_not_nil.swift diff --git a/src/main/resources/docs/tests/control_statement.swift b/docs/tests/control_statement.swift similarity index 100% rename from src/main/resources/docs/tests/control_statement.swift rename to docs/tests/control_statement.swift diff --git a/src/main/resources/docs/tests/cyclomatic_complexity.swift b/docs/tests/cyclomatic_complexity.swift similarity index 100% rename from src/main/resources/docs/tests/cyclomatic_complexity.swift rename to docs/tests/cyclomatic_complexity.swift diff --git a/src/main/resources/docs/tests/discarded_notification_center_observer.swift b/docs/tests/discarded_notification_center_observer.swift similarity index 100% rename from src/main/resources/docs/tests/discarded_notification_center_observer.swift rename to docs/tests/discarded_notification_center_observer.swift diff --git a/src/main/resources/docs/tests/discouraged_direct_init.swift b/docs/tests/discouraged_direct_init.swift similarity index 100% rename from src/main/resources/docs/tests/discouraged_direct_init.swift rename to docs/tests/discouraged_direct_init.swift diff --git a/src/main/resources/docs/tests/discouraged_object_literal.swift b/docs/tests/discouraged_object_literal.swift similarity index 100% rename from src/main/resources/docs/tests/discouraged_object_literal.swift rename to docs/tests/discouraged_object_literal.swift diff --git a/src/main/resources/docs/tests/discouraged_optional_boolean.swift b/docs/tests/discouraged_optional_boolean.swift similarity index 100% rename from src/main/resources/docs/tests/discouraged_optional_boolean.swift rename to docs/tests/discouraged_optional_boolean.swift diff --git a/docs/tests/dynamic_inline.swift b/docs/tests/dynamic_inline.swift new file mode 100644 index 0000000..a173305 --- /dev/null +++ b/docs/tests/dynamic_inline.swift @@ -0,0 +1,30 @@ +//#Patterns: dynamic_inline + +//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} + + class C { + @inline(__always) dynamic func f() {} + } + + class C { + @inline(__always) public dynamic func f() {} + } + + class C { + @inline(__always) dynamic internal func f() {} + } + + class C { + @inline(__always) + dynamic func f() {} + } + + class C { + @inline(__always) + dynamic + func f() {} + } diff --git a/src/main/resources/docs/tests/empty_count.swift b/docs/tests/empty_count.swift similarity index 100% rename from src/main/resources/docs/tests/empty_count.swift rename to docs/tests/empty_count.swift diff --git a/src/main/resources/docs/tests/empty_enum_arguments.swift b/docs/tests/empty_enum_arguments.swift similarity index 100% rename from src/main/resources/docs/tests/empty_enum_arguments.swift rename to docs/tests/empty_enum_arguments.swift diff --git a/src/main/resources/docs/tests/empty_parameters.swift b/docs/tests/empty_parameters.swift similarity index 100% rename from src/main/resources/docs/tests/empty_parameters.swift rename to docs/tests/empty_parameters.swift diff --git a/src/main/resources/docs/tests/empty_parentheses_with_trailing_closure.swift b/docs/tests/empty_parentheses_with_trailing_closure.swift similarity index 100% rename from src/main/resources/docs/tests/empty_parentheses_with_trailing_closure.swift rename to docs/tests/empty_parentheses_with_trailing_closure.swift diff --git a/src/main/resources/docs/tests/explicit_acl.swift b/docs/tests/explicit_acl.swift similarity index 100% rename from src/main/resources/docs/tests/explicit_acl.swift rename to docs/tests/explicit_acl.swift diff --git a/src/main/resources/docs/tests/explicit_enum_raw_value.swift b/docs/tests/explicit_enum_raw_value.swift similarity index 100% rename from src/main/resources/docs/tests/explicit_enum_raw_value.swift rename to docs/tests/explicit_enum_raw_value.swift diff --git a/src/main/resources/docs/tests/explicit_init.swift b/docs/tests/explicit_init.swift similarity index 100% rename from src/main/resources/docs/tests/explicit_init.swift rename to docs/tests/explicit_init.swift diff --git a/src/main/resources/docs/tests/explicit_top_level_acl.swift b/docs/tests/explicit_top_level_acl.swift similarity index 100% rename from src/main/resources/docs/tests/explicit_top_level_acl.swift rename to docs/tests/explicit_top_level_acl.swift diff --git a/src/main/resources/docs/tests/explicit_type_interface.swift b/docs/tests/explicit_type_interface.swift similarity index 100% rename from src/main/resources/docs/tests/explicit_type_interface.swift rename to docs/tests/explicit_type_interface.swift diff --git a/src/main/resources/docs/tests/extension_access_modifier.swift b/docs/tests/extension_access_modifier.swift similarity index 100% rename from src/main/resources/docs/tests/extension_access_modifier.swift rename to docs/tests/extension_access_modifier.swift diff --git a/src/main/resources/docs/tests/fallthrough.swift b/docs/tests/fallthrough.swift similarity index 100% rename from src/main/resources/docs/tests/fallthrough.swift rename to docs/tests/fallthrough.swift diff --git a/src/main/resources/docs/tests/fatal_error_message.swift b/docs/tests/fatal_error_message.swift similarity index 100% rename from src/main/resources/docs/tests/fatal_error_message.swift rename to docs/tests/fatal_error_message.swift diff --git a/src/main/resources/docs/tests/file_header.swift b/docs/tests/file_header.swift similarity index 100% rename from src/main/resources/docs/tests/file_header.swift rename to docs/tests/file_header.swift diff --git a/src/main/resources/docs/tests/file_length.swift b/docs/tests/file_length.swift similarity index 100% rename from src/main/resources/docs/tests/file_length.swift rename to docs/tests/file_length.swift diff --git a/src/main/resources/docs/tests/first_where.swift b/docs/tests/first_where.swift similarity index 100% rename from src/main/resources/docs/tests/first_where.swift rename to docs/tests/first_where.swift diff --git a/src/main/resources/docs/tests/for_where.swift b/docs/tests/for_where.swift similarity index 100% rename from src/main/resources/docs/tests/for_where.swift rename to docs/tests/for_where.swift diff --git a/src/main/resources/docs/tests/force_cast.swift b/docs/tests/force_cast.swift similarity index 100% rename from src/main/resources/docs/tests/force_cast.swift rename to docs/tests/force_cast.swift diff --git a/src/main/resources/docs/tests/force_try.swift b/docs/tests/force_try.swift similarity index 100% rename from src/main/resources/docs/tests/force_try.swift rename to docs/tests/force_try.swift diff --git a/src/main/resources/docs/tests/force_unwrapping.swift b/docs/tests/force_unwrapping.swift similarity index 100% rename from src/main/resources/docs/tests/force_unwrapping.swift rename to docs/tests/force_unwrapping.swift diff --git a/src/main/resources/docs/tests/function_parameter_count.swift b/docs/tests/function_parameter_count.swift similarity index 100% rename from src/main/resources/docs/tests/function_parameter_count.swift rename to docs/tests/function_parameter_count.swift diff --git a/src/main/resources/docs/tests/generic_type_name.swift b/docs/tests/generic_type_name.swift similarity index 100% rename from src/main/resources/docs/tests/generic_type_name.swift rename to docs/tests/generic_type_name.swift diff --git a/src/main/resources/docs/tests/identifier_name.swift b/docs/tests/identifier_name.swift similarity index 100% rename from src/main/resources/docs/tests/identifier_name.swift rename to docs/tests/identifier_name.swift diff --git a/src/main/resources/docs/tests/implicit_getter.swift b/docs/tests/implicit_getter.swift similarity index 100% rename from src/main/resources/docs/tests/implicit_getter.swift rename to docs/tests/implicit_getter.swift diff --git a/src/main/resources/docs/tests/implicit_return.swift b/docs/tests/implicit_return.swift similarity index 100% rename from src/main/resources/docs/tests/implicit_return.swift rename to docs/tests/implicit_return.swift diff --git a/src/main/resources/docs/tests/implicitly_unwrapped_optional.swift b/docs/tests/implicitly_unwrapped_optional.swift similarity index 100% rename from src/main/resources/docs/tests/implicitly_unwrapped_optional.swift rename to docs/tests/implicitly_unwrapped_optional.swift diff --git a/src/main/resources/docs/tests/is_disjoint.swift b/docs/tests/is_disjoint.swift similarity index 100% rename from src/main/resources/docs/tests/is_disjoint.swift rename to docs/tests/is_disjoint.swift diff --git a/src/main/resources/docs/tests/joined_default_parameter.swift b/docs/tests/joined_default_parameter.swift similarity index 100% rename from src/main/resources/docs/tests/joined_default_parameter.swift rename to docs/tests/joined_default_parameter.swift diff --git a/src/main/resources/docs/tests/large_tuple.swift b/docs/tests/large_tuple.swift similarity index 100% rename from src/main/resources/docs/tests/large_tuple.swift rename to docs/tests/large_tuple.swift diff --git a/src/main/resources/docs/tests/legacy_cggeometry_functions.swift b/docs/tests/legacy_cggeometry_functions.swift similarity index 100% rename from src/main/resources/docs/tests/legacy_cggeometry_functions.swift rename to docs/tests/legacy_cggeometry_functions.swift diff --git a/src/main/resources/docs/tests/legacy_constant.swift b/docs/tests/legacy_constant.swift similarity index 100% rename from src/main/resources/docs/tests/legacy_constant.swift rename to docs/tests/legacy_constant.swift diff --git a/src/main/resources/docs/tests/legacy_constructor.swift b/docs/tests/legacy_constructor.swift similarity index 100% rename from src/main/resources/docs/tests/legacy_constructor.swift rename to docs/tests/legacy_constructor.swift diff --git a/src/main/resources/docs/tests/legacy_nsgeometry_functions.swift b/docs/tests/legacy_nsgeometry_functions.swift similarity index 100% rename from src/main/resources/docs/tests/legacy_nsgeometry_functions.swift rename to docs/tests/legacy_nsgeometry_functions.swift diff --git a/src/main/resources/docs/tests/let_var_whitespace.swift b/docs/tests/let_var_whitespace.swift similarity index 100% rename from src/main/resources/docs/tests/let_var_whitespace.swift rename to docs/tests/let_var_whitespace.swift diff --git a/src/main/resources/docs/tests/line_length.swift b/docs/tests/line_length.swift similarity index 100% rename from src/main/resources/docs/tests/line_length.swift rename to docs/tests/line_length.swift diff --git a/src/main/resources/docs/tests/literal_expression_end_indentation.swift b/docs/tests/literal_expression_end_indentation.swift similarity index 100% rename from src/main/resources/docs/tests/literal_expression_end_indentation.swift rename to docs/tests/literal_expression_end_indentation.swift diff --git a/src/main/resources/docs/tests/mark.swift b/docs/tests/mark.swift similarity index 100% rename from src/main/resources/docs/tests/mark.swift rename to docs/tests/mark.swift diff --git a/src/main/resources/docs/tests/multiline_arguments.swift b/docs/tests/multiline_arguments.swift similarity index 100% rename from src/main/resources/docs/tests/multiline_arguments.swift rename to docs/tests/multiline_arguments.swift diff --git a/src/main/resources/docs/tests/multiline_parameters.swift b/docs/tests/multiline_parameters.swift similarity index 100% rename from src/main/resources/docs/tests/multiline_parameters.swift rename to docs/tests/multiline_parameters.swift diff --git a/src/main/resources/docs/tests/multiple_closures_with_trailing_closure.swift b/docs/tests/multiple_closures_with_trailing_closure.swift similarity index 100% rename from src/main/resources/docs/tests/multiple_closures_with_trailing_closure.swift rename to docs/tests/multiple_closures_with_trailing_closure.swift diff --git a/src/main/resources/docs/tests/nesting.swift b/docs/tests/nesting.swift similarity index 100% rename from src/main/resources/docs/tests/nesting.swift rename to docs/tests/nesting.swift diff --git a/src/main/resources/docs/tests/nimble_operator.swift b/docs/tests/nimble_operator.swift similarity index 100% rename from src/main/resources/docs/tests/nimble_operator.swift rename to docs/tests/nimble_operator.swift diff --git a/src/main/resources/docs/tests/no_extension_access_modifier.swift b/docs/tests/no_extension_access_modifier.swift similarity index 100% rename from src/main/resources/docs/tests/no_extension_access_modifier.swift rename to docs/tests/no_extension_access_modifier.swift diff --git a/src/main/resources/docs/tests/no_grouping_extension.swift b/docs/tests/no_grouping_extension.swift similarity index 100% rename from src/main/resources/docs/tests/no_grouping_extension.swift rename to docs/tests/no_grouping_extension.swift diff --git a/src/main/resources/docs/tests/notification_center_detachment.swift b/docs/tests/notification_center_detachment.swift similarity index 100% rename from src/main/resources/docs/tests/notification_center_detachment.swift rename to docs/tests/notification_center_detachment.swift diff --git a/src/main/resources/docs/tests/number_separator.swift b/docs/tests/number_separator.swift similarity index 100% rename from src/main/resources/docs/tests/number_separator.swift rename to docs/tests/number_separator.swift diff --git a/src/main/resources/docs/tests/object_literal.swift b/docs/tests/object_literal.swift similarity index 100% rename from src/main/resources/docs/tests/object_literal.swift rename to docs/tests/object_literal.swift diff --git a/src/main/resources/docs/tests/opening_brace.swift b/docs/tests/opening_brace.swift similarity index 100% rename from src/main/resources/docs/tests/opening_brace.swift rename to docs/tests/opening_brace.swift diff --git a/src/main/resources/docs/tests/operator_usage_whitespace.swift b/docs/tests/operator_usage_whitespace.swift similarity index 100% rename from src/main/resources/docs/tests/operator_usage_whitespace.swift rename to docs/tests/operator_usage_whitespace.swift diff --git a/src/main/resources/docs/tests/operator_whitespace.swift b/docs/tests/operator_whitespace.swift similarity index 100% rename from src/main/resources/docs/tests/operator_whitespace.swift rename to docs/tests/operator_whitespace.swift diff --git a/src/main/resources/docs/tests/overridden_super_call.swift b/docs/tests/overridden_super_call.swift similarity index 100% rename from src/main/resources/docs/tests/overridden_super_call.swift rename to docs/tests/overridden_super_call.swift diff --git a/src/main/resources/docs/tests/override_in_extension.swift b/docs/tests/override_in_extension.swift similarity index 100% rename from src/main/resources/docs/tests/override_in_extension.swift rename to docs/tests/override_in_extension.swift diff --git a/src/main/resources/docs/tests/pattern_matching_keywords.swift b/docs/tests/pattern_matching_keywords.swift similarity index 100% rename from src/main/resources/docs/tests/pattern_matching_keywords.swift rename to docs/tests/pattern_matching_keywords.swift diff --git a/src/main/resources/docs/tests/prefixed_toplevel_constant.swift b/docs/tests/prefixed_toplevel_constant.swift similarity index 100% rename from src/main/resources/docs/tests/prefixed_toplevel_constant.swift rename to docs/tests/prefixed_toplevel_constant.swift diff --git a/src/main/resources/docs/tests/private_action.swift b/docs/tests/private_action.swift similarity index 100% rename from src/main/resources/docs/tests/private_action.swift rename to docs/tests/private_action.swift diff --git a/src/main/resources/docs/tests/private_outlet.swift b/docs/tests/private_outlet.swift similarity index 100% rename from src/main/resources/docs/tests/private_outlet.swift rename to docs/tests/private_outlet.swift diff --git a/src/main/resources/docs/tests/private_over_fileprivate.swift b/docs/tests/private_over_fileprivate.swift similarity index 100% rename from src/main/resources/docs/tests/private_over_fileprivate.swift rename to docs/tests/private_over_fileprivate.swift diff --git a/src/main/resources/docs/tests/private_unit_test.swift b/docs/tests/private_unit_test.swift similarity index 100% rename from src/main/resources/docs/tests/private_unit_test.swift rename to docs/tests/private_unit_test.swift diff --git a/src/main/resources/docs/tests/prohibited_super_call.swift b/docs/tests/prohibited_super_call.swift similarity index 100% rename from src/main/resources/docs/tests/prohibited_super_call.swift rename to docs/tests/prohibited_super_call.swift diff --git a/src/main/resources/docs/tests/protocol_property_accessors_order.swift b/docs/tests/protocol_property_accessors_order.swift similarity index 100% rename from src/main/resources/docs/tests/protocol_property_accessors_order.swift rename to docs/tests/protocol_property_accessors_order.swift diff --git a/src/main/resources/docs/tests/quick_discouraged_call.swift b/docs/tests/quick_discouraged_call.swift similarity index 100% rename from src/main/resources/docs/tests/quick_discouraged_call.swift rename to docs/tests/quick_discouraged_call.swift diff --git a/src/main/resources/docs/tests/quick_discouraged_focused_test.swift b/docs/tests/quick_discouraged_focused_test.swift similarity index 100% rename from src/main/resources/docs/tests/quick_discouraged_focused_test.swift rename to docs/tests/quick_discouraged_focused_test.swift diff --git a/src/main/resources/docs/tests/quick_discouraged_pending_test.swift b/docs/tests/quick_discouraged_pending_test.swift similarity index 100% rename from src/main/resources/docs/tests/quick_discouraged_pending_test.swift rename to docs/tests/quick_discouraged_pending_test.swift diff --git a/src/main/resources/docs/tests/redundant_discardable_let.swift b/docs/tests/redundant_discardable_let.swift similarity index 100% rename from src/main/resources/docs/tests/redundant_discardable_let.swift rename to docs/tests/redundant_discardable_let.swift diff --git a/src/main/resources/docs/tests/redundant_nil_coalescing.swift b/docs/tests/redundant_nil_coalescing.swift similarity index 100% rename from src/main/resources/docs/tests/redundant_nil_coalescing.swift rename to docs/tests/redundant_nil_coalescing.swift diff --git a/src/main/resources/docs/tests/redundant_optional_initialization.swift b/docs/tests/redundant_optional_initialization.swift similarity index 100% rename from src/main/resources/docs/tests/redundant_optional_initialization.swift rename to docs/tests/redundant_optional_initialization.swift diff --git a/src/main/resources/docs/tests/redundant_string_enum_value.swift b/docs/tests/redundant_string_enum_value.swift similarity index 100% rename from src/main/resources/docs/tests/redundant_string_enum_value.swift rename to docs/tests/redundant_string_enum_value.swift diff --git a/src/main/resources/docs/tests/redundant_void_return.swift b/docs/tests/redundant_void_return.swift similarity index 100% rename from src/main/resources/docs/tests/redundant_void_return.swift rename to docs/tests/redundant_void_return.swift diff --git a/src/main/resources/docs/tests/required_enum_case.swift b/docs/tests/required_enum_case.swift similarity index 100% rename from src/main/resources/docs/tests/required_enum_case.swift rename to docs/tests/required_enum_case.swift diff --git a/src/main/resources/docs/tests/return_arrow_whitespace.swift b/docs/tests/return_arrow_whitespace.swift similarity index 100% rename from src/main/resources/docs/tests/return_arrow_whitespace.swift rename to docs/tests/return_arrow_whitespace.swift diff --git a/src/main/resources/docs/tests/shorthand_operator.swift b/docs/tests/shorthand_operator.swift similarity index 100% rename from src/main/resources/docs/tests/shorthand_operator.swift rename to docs/tests/shorthand_operator.swift diff --git a/src/main/resources/docs/tests/single_test_class.swift b/docs/tests/single_test_class.swift similarity index 100% rename from src/main/resources/docs/tests/single_test_class.swift rename to docs/tests/single_test_class.swift diff --git a/src/main/resources/docs/tests/sorted_first_last.swift b/docs/tests/sorted_first_last.swift similarity index 100% rename from src/main/resources/docs/tests/sorted_first_last.swift rename to docs/tests/sorted_first_last.swift diff --git a/src/main/resources/docs/tests/sorted_imports.swift b/docs/tests/sorted_imports.swift similarity index 100% rename from src/main/resources/docs/tests/sorted_imports.swift rename to docs/tests/sorted_imports.swift diff --git a/src/main/resources/docs/tests/statement_position.swift b/docs/tests/statement_position.swift similarity index 100% rename from src/main/resources/docs/tests/statement_position.swift rename to docs/tests/statement_position.swift diff --git a/src/main/resources/docs/tests/strict_fileprivate.swift b/docs/tests/strict_fileprivate.swift similarity index 100% rename from src/main/resources/docs/tests/strict_fileprivate.swift rename to docs/tests/strict_fileprivate.swift diff --git a/src/main/resources/docs/tests/superfluous_disable_command.swift b/docs/tests/superfluous_disable_command.swift similarity index 100% rename from src/main/resources/docs/tests/superfluous_disable_command.swift rename to docs/tests/superfluous_disable_command.swift diff --git a/src/main/resources/docs/tests/switch_case_alignment.swift b/docs/tests/switch_case_alignment.swift similarity index 100% rename from src/main/resources/docs/tests/switch_case_alignment.swift rename to docs/tests/switch_case_alignment.swift diff --git a/src/main/resources/docs/tests/switch_case_on_newline.swift b/docs/tests/switch_case_on_newline.swift similarity index 100% rename from src/main/resources/docs/tests/switch_case_on_newline.swift rename to docs/tests/switch_case_on_newline.swift diff --git a/src/main/resources/docs/tests/syntactic_sugar.swift b/docs/tests/syntactic_sugar.swift similarity index 100% rename from src/main/resources/docs/tests/syntactic_sugar.swift rename to docs/tests/syntactic_sugar.swift diff --git a/src/main/resources/docs/tests/todo.swift b/docs/tests/todo.swift similarity index 100% rename from src/main/resources/docs/tests/todo.swift rename to docs/tests/todo.swift diff --git a/src/main/resources/docs/tests/trailing_closure.swift b/docs/tests/trailing_closure.swift similarity index 100% rename from src/main/resources/docs/tests/trailing_closure.swift rename to docs/tests/trailing_closure.swift diff --git a/src/main/resources/docs/tests/trailing_comma.swift b/docs/tests/trailing_comma.swift similarity index 100% rename from src/main/resources/docs/tests/trailing_comma.swift rename to docs/tests/trailing_comma.swift diff --git a/src/main/resources/docs/tests/trailing_semicolon.swift b/docs/tests/trailing_semicolon.swift similarity index 100% rename from src/main/resources/docs/tests/trailing_semicolon.swift rename to docs/tests/trailing_semicolon.swift diff --git a/src/main/resources/docs/tests/type_body_length.swift b/docs/tests/type_body_length.swift similarity index 100% rename from src/main/resources/docs/tests/type_body_length.swift rename to docs/tests/type_body_length.swift diff --git a/src/main/resources/docs/tests/type_name.swift b/docs/tests/type_name.swift similarity index 100% rename from src/main/resources/docs/tests/type_name.swift rename to docs/tests/type_name.swift diff --git a/src/main/resources/docs/tests/unneeded_break_in_switch.swift b/docs/tests/unneeded_break_in_switch.swift similarity index 100% rename from src/main/resources/docs/tests/unneeded_break_in_switch.swift rename to docs/tests/unneeded_break_in_switch.swift diff --git a/src/main/resources/docs/tests/unneeded_parentheses_in_closure_argument.swift b/docs/tests/unneeded_parentheses_in_closure_argument.swift similarity index 100% rename from src/main/resources/docs/tests/unneeded_parentheses_in_closure_argument.swift rename to docs/tests/unneeded_parentheses_in_closure_argument.swift diff --git a/src/main/resources/docs/tests/unused_closure_parameter.swift b/docs/tests/unused_closure_parameter.swift similarity index 100% rename from src/main/resources/docs/tests/unused_closure_parameter.swift rename to docs/tests/unused_closure_parameter.swift diff --git a/src/main/resources/docs/tests/unused_enumerated.swift b/docs/tests/unused_enumerated.swift similarity index 100% rename from src/main/resources/docs/tests/unused_enumerated.swift rename to docs/tests/unused_enumerated.swift diff --git a/src/main/resources/docs/tests/unused_optional_binding.swift b/docs/tests/unused_optional_binding.swift similarity index 100% rename from src/main/resources/docs/tests/unused_optional_binding.swift rename to docs/tests/unused_optional_binding.swift diff --git a/src/main/resources/docs/tests/valid_ibinspectable.swift b/docs/tests/valid_ibinspectable.swift similarity index 100% rename from src/main/resources/docs/tests/valid_ibinspectable.swift rename to docs/tests/valid_ibinspectable.swift diff --git a/src/main/resources/docs/tests/vertical_parameter_alignment.swift b/docs/tests/vertical_parameter_alignment.swift similarity index 100% rename from src/main/resources/docs/tests/vertical_parameter_alignment.swift rename to docs/tests/vertical_parameter_alignment.swift diff --git a/src/main/resources/docs/tests/vertical_parameter_alignment_on_call.swift b/docs/tests/vertical_parameter_alignment_on_call.swift similarity index 100% rename from src/main/resources/docs/tests/vertical_parameter_alignment_on_call.swift rename to docs/tests/vertical_parameter_alignment_on_call.swift diff --git a/src/main/resources/docs/tests/vertical_whitespace.swift b/docs/tests/vertical_whitespace.swift similarity index 100% rename from src/main/resources/docs/tests/vertical_whitespace.swift rename to docs/tests/vertical_whitespace.swift diff --git a/src/main/resources/docs/tests/void_return.swift b/docs/tests/void_return.swift similarity index 100% rename from src/main/resources/docs/tests/void_return.swift rename to docs/tests/void_return.swift diff --git a/src/main/resources/docs/tests/weak_delegate.swift b/docs/tests/weak_delegate.swift similarity index 100% rename from src/main/resources/docs/tests/weak_delegate.swift rename to docs/tests/weak_delegate.swift diff --git a/src/main/resources/docs/tests/xctfail_message.swift b/docs/tests/xctfail_message.swift similarity index 100% rename from src/main/resources/docs/tests/xctfail_message.swift rename to docs/tests/xctfail_message.swift diff --git a/src/main/resources/docs/tests/yoda_condition.swift b/docs/tests/yoda_condition.swift similarity index 100% rename from src/main/resources/docs/tests/yoda_condition.swift rename to docs/tests/yoda_condition.swift diff --git a/src/main/resources/docs/tool-description.md b/docs/tool-description.md similarity index 100% rename from src/main/resources/docs/tool-description.md rename to docs/tool-description.md diff --git a/project/plugins.sbt b/project/plugins.sbt index 287d94d..4f2f225 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,2 @@ -resolvers += Resolver.jcenterRepo -addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "18.0.5") +addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "20.0.7") +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.4") diff --git a/src/main/resources/docs/multiple-tests/multiple-files/src/closing_brace.swift b/src/main/resources/docs/multiple-tests/multiple-files/src/closing_brace.swift deleted file mode 120000 index 878b26e..0000000 --- a/src/main/resources/docs/multiple-tests/multiple-files/src/closing_brace.swift +++ /dev/null @@ -1 +0,0 @@ -../../../tests/closing_brace.swift \ No newline at end of file diff --git a/src/main/resources/docs/multiple-tests/multiple-files/src/dynamic_inline.swift b/src/main/resources/docs/multiple-tests/multiple-files/src/dynamic_inline.swift deleted file mode 120000 index 495de27..0000000 --- a/src/main/resources/docs/multiple-tests/multiple-files/src/dynamic_inline.swift +++ /dev/null @@ -1 +0,0 @@ -../../../tests/dynamic_inline.swift \ No newline at end of file diff --git a/src/main/resources/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift b/src/main/resources/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift deleted file mode 120000 index 878b26e..0000000 --- a/src/main/resources/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift +++ /dev/null @@ -1 +0,0 @@ -../../../tests/closing_brace.swift \ No newline at end of file diff --git a/src/main/resources/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift b/src/main/resources/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift deleted file mode 120000 index 495de27..0000000 --- a/src/main/resources/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift +++ /dev/null @@ -1 +0,0 @@ -../../../tests/dynamic_inline.swift \ No newline at end of file diff --git a/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift b/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift deleted file mode 120000 index 878b26e..0000000 --- a/src/main/resources/docs/multiple-tests/with-config/src/closing_brace.swift +++ /dev/null @@ -1 +0,0 @@ -../../../tests/closing_brace.swift \ No newline at end of file diff --git a/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift b/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift deleted file mode 120000 index 495de27..0000000 --- a/src/main/resources/docs/multiple-tests/with-config/src/dynamic_inline.swift +++ /dev/null @@ -1 +0,0 @@ -../../../tests/dynamic_inline.swift \ No newline at end of file diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index eece825..2d374af 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -40,15 +40,11 @@ object SwiftLint extends Tool { } def listOfFilesToLint(files: Option[Set[Source.File]], source: Source.Directory): List[String] = { - val listOfFiles = files.fold(List(source.path.toString)) { paths => - paths.map(_.toString).toList + files match { + case None => List(source.path) + case Some(paths) if paths.isEmpty => List(source.path) + case Some(paths) => paths.map(_.path).toList } - - if (listOfFiles.isEmpty) { - List(source.path) - } - - listOfFiles } def nativeConfigurationFile(source: Source.Directory): Option[String] = { From 22cfc61b43c4cb096095c6164e62433f7296c68b Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Tue, 21 Jul 2020 12:13:44 +0200 Subject: [PATCH 032/119] fix: Create smaller docker image --- .gitignore | 2 +- Dockerfile | 9 +++++++-- Dockerfile.dev | 11 ++++++++--- build.sbt | 12 ++++++++++++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 5b2826f..84b56bd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ /project/*-shim.sbt /project/project/ /project/target/ -/target/ +target .idea .DS_Store .metals diff --git a/Dockerfile b/Dockerfile index 0b302ab..ba649fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,13 @@ -FROM norionomura/swiftlint:0.39.2 as build +FROM norionomura/swiftlint:0.39.2 as builder + +FROM swift:5.2.4-xenial-slim + +COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint +COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so -WORKDIR /src COPY docs /docs COPY target/graalvm-native-image/codacy-swiftlint /workdir/ RUN adduser --uid 2004 --disabled-password --gecos "" docker USER docker +WORKDIR /src ENTRYPOINT ["/workdir/codacy-swiftlint"] diff --git a/Dockerfile.dev b/Dockerfile.dev index a598cdf..dfa9d23 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,11 +1,16 @@ -FROM norionomura/swiftlint:0.39.2 as build +FROM norionomura/swiftlint:0.39.2 as builder + +FROM swift:5.2.4-xenial-slim + +COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint +COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so RUN apt-get update && apt-get install -y openjdk-8-jre -WORKDIR /src COPY docs /docs COPY target/universal/stage/ /workdir/ -RUN adduser --uid 2004 --disabled-password --gecos "" docker RUN chmod +x /workdir/bin/codacy-swiftlint +RUN adduser --uid 2004 -m docker USER docker +WORKDIR /src ENTRYPOINT ["/workdir/bin/codacy-swiftlint"] diff --git a/build.sbt b/build.sbt index 7aaaf90..919db28 100755 --- a/build.sbt +++ b/build.sbt @@ -4,6 +4,18 @@ name := "codacy-swiftlint" scalaVersion := "2.13.3" +lazy val swiftlintVersion = Def.setting("1.10.0") + +Compile / sourceGenerators += Def.task { + val file = (Compile / sourceManaged).value / "codacy" / "swiftlint" / "Versions.scala" + IO.write(file, s"""package codacy.swiftlint + |object Versions { + | val swiftlintVersion: String = "${swiftlintVersion.value}" + |} + |""".stripMargin) + Seq(file) +}.taskValue + libraryDependencies += "com.codacy" %% "codacy-engine-scala-seed" % "4.0.3" enablePlugins(GraalVMNativeImagePlugin) From 9cdffcd79c360a1ef2cda1edb7a7fc014388f91a Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Tue, 21 Jul 2020 13:55:29 +0200 Subject: [PATCH 033/119] fix: Fix Dockerfile.dev --- Dockerfile.dev | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index dfa9d23..2c39d0b 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -2,15 +2,15 @@ FROM norionomura/swiftlint:0.39.2 as builder FROM swift:5.2.4-xenial-slim +RUN apt-get update && apt-get install -y openjdk-8-jre + COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so -RUN apt-get update && apt-get install -y openjdk-8-jre - COPY docs /docs COPY target/universal/stage/ /workdir/ RUN chmod +x /workdir/bin/codacy-swiftlint -RUN adduser --uid 2004 -m docker +RUN adduser --uid 2004 --disabled-password --gecos "" docker USER docker WORKDIR /src ENTRYPOINT ["/workdir/bin/codacy-swiftlint"] From 94b9dbe0952edfb02ea8f367d9551782725c621d Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Tue, 21 Jul 2020 13:55:41 +0200 Subject: [PATCH 034/119] docs: Document Dockerfile.dev --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 9d0cbaa..a64ff26 100755 --- a/README.md +++ b/README.md @@ -25,6 +25,13 @@ docker run -it -v $srcDir:/src : ## Test +For a faster development loop you can create a Docker image based on the JVM instead of creating a native-image: + +```bash +sbt universal:stage +docker build -t codacy-swiftlint -f Dockerfile.dev . +``` + We use the [codacy-plugins-test](https://github.com/codacy/codacy-plugins-test) to test our external tools integration. You can follow the instructions there to make sure your tool is working as expected. From 8caef8064fdbd0f602791db4b94bb0602df489f3 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 22 Jul 2020 13:56:51 +0200 Subject: [PATCH 035/119] feature: Add generated docs --- docs/description/anyobject_protocol.md | 50 + docs/description/array_init.md | 118 + docs/description/attributes.md | 367 ++ docs/description/block_based_kvo.md | 37 + docs/description/class_delegate_protocol.md | 71 + docs/description/closing_brace.md | 33 + docs/description/closure_body_length.md | 547 +++ docs/description/closure_end_indentation.md | 107 + .../description/closure_parameter_position.md | 143 + docs/description/closure_spacing.md | 47 + docs/description/collection_alignment.md | 117 + docs/description/colon.md | 444 +++ docs/description/comma.md | 73 + docs/description/compiler_protocol_init.md | 35 + .../conditional_returns_on_newline.md | 73 + .../description/contains_over_filter_count.md | 120 + .../contains_over_filter_is_empty.md | 80 + .../contains_over_first_not_nil.md | 155 + .../contains_over_range_nil_comparison.md | 39 + docs/description/control_statement.md | 206 ++ docs/description/convenience_type.md | 64 + docs/description/custom_rules.md | 11 + docs/description/cyclomatic_complexity.md | 74 + docs/description/deployment_target.md | 103 + docs/description/description.json | 821 +++-- .../discarded_notification_center_observer.md | 79 + docs/description/discouraged_direct_init.md | 79 + .../description/discouraged_object_literal.md | 47 + .../discouraged_optional_boolean.md | 627 ++++ .../discouraged_optional_collection.md | 909 +++++ docs/description/duplicate_enum_cases.md | 39 + docs/description/duplicate_imports.md | 201 ++ docs/description/dynamic_inline.md | 63 + docs/description/empty_collection_literal.md | 63 + docs/description/empty_count.md | 100 + docs/description/empty_enum_arguments.md | 96 + docs/description/empty_parameters.md | 65 + ...empty_parentheses_with_trailing_closure.md | 80 + docs/description/empty_string.md | 37 + docs/description/empty_xctest_method.md | 154 + .../enum_case_associated_values_count.md | 41 + docs/description/expiring_todo.md | 70 + docs/description/explicit_acl.md | 119 + docs/description/explicit_enum_raw_value.md | 81 + docs/description/explicit_init.md | 69 + docs/description/explicit_self.md | 51 + docs/description/explicit_top_level_acl.md | 84 + docs/description/explicit_type_interface.md | 75 + docs/description/extension_access_modifier.md | 84 + docs/description/fallthrough.md | 31 + docs/description/fatal_error_message.md | 39 + docs/description/file_header.md | 48 + docs/description/file_length.md | 1229 +++++++ docs/description/file_name.md | 11 + docs/description/file_name_no_space.md | 11 + docs/description/file_types_order.md | 211 ++ docs/description/first_where.md | 83 + docs/description/flatmap_over_map_reduce.md | 27 + docs/description/for_where.md | 85 + docs/description/force_cast.md | 25 + docs/description/force_try.md | 27 + docs/description/force_unwrapping.md | 145 + docs/description/function_body_length.md | 11 + .../function_default_parameter_at_end.md | 63 + docs/description/function_parameter_count.md | 74 + docs/description/generic_type_name.md | 195 ++ docs/description/identical_operands.md | 815 +++++ docs/description/identifier_name.md | 115 + docs/description/implicit_getter.md | 260 ++ docs/description/implicit_return.md | 129 + .../implicitly_unwrapped_optional.md | 83 + docs/description/indentation_width.md | 71 + docs/description/inert_defer.md | 54 + docs/description/is_disjoint.md | 39 + docs/description/joined_default_parameter.md | 42 + docs/description/large_tuple.md | 155 + docs/description/last_where.md | 75 + docs/description/leading_whitespace.md | 30 + .../legacy_cggeometry_functions.md | 175 + docs/description/legacy_constant.md | 95 + docs/description/legacy_constructor.md | 201 ++ docs/description/legacy_hashing.md | 82 + docs/description/legacy_multiple.md | 70 + .../legacy_nsgeometry_functions.md | 167 + docs/description/legacy_random.md | 45 + docs/description/let_var_whitespace.md | 171 + docs/description/line_length.md | 45 + .../literal_expression_end_indentation.md | 82 + docs/description/lower_acl_than_parent.md | 79 + docs/description/mark.md | 142 + docs/description/missing_docs.md | 73 + docs/description/modifier_order.md | 270 ++ docs/description/multiline_arguments.md | 118 + .../multiline_arguments_brackets.md | 83 + docs/description/multiline_function_chains.md | 110 + .../description/multiline_literal_brackets.md | 106 + docs/description/multiline_parameters.md | 474 +++ .../multiline_parameters_brackets.md | 97 + ...multiple_closures_with_trailing_closure.md | 55 + docs/description/nesting.md | 111 + docs/description/nimble_operator.md | 135 + .../no_extension_access_modifier.md | 46 + docs/description/no_fallthrough_only.md | 183 + docs/description/no_grouping_extension.md | 57 + docs/description/no_space_in_method_call.md | 67 + .../notification_center_detachment.md | 39 + docs/description/nslocalizedstring_key.md | 31 + .../nslocalizedstring_require_bundle.md | 48 + docs/description/nsobject_prefer_isequal.md | 111 + docs/description/number_separator.md | 315 ++ docs/description/object_literal.md | 111 + docs/description/opening_brace.md | 196 ++ docs/description/operator_usage_whitespace.md | 189 + docs/description/operator_whitespace.md | 60 + .../optional_enum_case_matching.md | 83 + docs/description/orphaned_doc_comment.md | 51 + docs/description/overridden_super_call.md | 83 + docs/description/override_in_extension.md | 66 + docs/description/pattern_matching_keywords.md | 117 + .../prefer_self_type_over_type_of_self.md | 71 + .../description/prefixed_toplevel_constant.md | 113 + docs/description/private_action.md | 134 + docs/description/private_outlet.md | 64 + docs/description/private_over_fileprivate.md | 73 + docs/description/private_unit_test.md | 105 + .../prohibited_interface_builder.md | 39 + docs/description/prohibited_super_call.md | 78 + .../protocol_property_accessors_order.md | 39 + docs/description/quick_discouraged_call.md | 313 ++ .../quick_discouraged_focused_test.md | 94 + .../quick_discouraged_pending_test.md | 102 + .../raw_value_for_camel_cased_codable_enum.md | 91 + docs/description/reduce_boolean.md | 55 + docs/description/reduce_into.md | 106 + docs/description/redundant_discardable_let.md | 49 + docs/description/redundant_nil_coalescing.md | 30 + docs/description/redundant_objc_attribute.md | 213 ++ .../redundant_optional_initialization.md | 106 + .../redundant_set_access_control.md | 71 + .../redundant_string_enum_value.md | 68 + docs/description/redundant_type_annotation.md | 59 + docs/description/redundant_void_return.md | 104 + docs/description/required_deinit.md | 82 + docs/description/required_enum_case.md | 75 + docs/description/return_arrow_whitespace.md | 87 + docs/description/shorthand_operator.md | 264 ++ docs/description/single_test_class.md | 63 + docs/description/sorted_first_last.md | 137 + docs/description/sorted_imports.md | 101 + docs/description/statement_position.md | 63 + docs/description/static_operator.md | 85 + docs/description/strict_fileprivate.md | 77 + docs/description/strong_iboutlet.md | 45 + .../superfluous_disable_command.md | 11 + docs/description/switch_case_alignment.md | 107 + docs/description/switch_case_on_newline.md | 178 + docs/description/syntactic_sugar.md | 107 + docs/description/todo.md | 65 + docs/description/toggle_bool.md | 53 + docs/description/trailing_closure.md | 77 + docs/description/trailing_comma.md | 111 + docs/description/trailing_newline.md | 30 + docs/description/trailing_semicolon.md | 46 + docs/description/trailing_whitespace.md | 50 + docs/description/type_body_length.md | 3120 +++++++++++++++++ docs/description/type_contents_order.md | 249 ++ docs/description/type_name.md | 231 ++ docs/description/unavailable_function.md | 54 + docs/description/unneeded_break_in_switch.md | 82 + ...nneeded_parentheses_in_closure_argument.md | 84 + docs/description/unowned_variable_capture.md | 51 + docs/description/untyped_error_in_catch.md | 84 + docs/description/unused_capture_list.md | 87 + docs/description/unused_closure_parameter.md | 172 + docs/description/unused_control_flow_label.md | 84 + docs/description/unused_declaration.md | 85 + docs/description/unused_enumerated.md | 80 + docs/description/unused_import.md | 83 + docs/description/unused_optional_binding.md | 104 + docs/description/unused_setter_value.md | 104 + docs/description/valid_ibinspectable.md | 125 + .../vertical_parameter_alignment.md | 96 + .../vertical_parameter_alignment_on_call.md | 118 + docs/description/vertical_whitespace.md | 62 + .../vertical_whitespace_between_cases.md | 122 + .../vertical_whitespace_closing_braces.md | 127 + .../vertical_whitespace_opening_braces.md | 197 ++ docs/description/void_return.md | 85 + docs/description/weak_delegate.md | 95 + docs/description/xct_specific_matcher.md | 303 ++ docs/description/xctfail_message.md | 39 + docs/description/yoda_condition.md | 87 + docs/patterns.json | 462 ++- 193 files changed, 26670 insertions(+), 363 deletions(-) create mode 100644 docs/description/anyobject_protocol.md create mode 100644 docs/description/array_init.md create mode 100644 docs/description/attributes.md create mode 100644 docs/description/block_based_kvo.md create mode 100644 docs/description/class_delegate_protocol.md create mode 100644 docs/description/closing_brace.md create mode 100644 docs/description/closure_body_length.md create mode 100644 docs/description/closure_end_indentation.md create mode 100644 docs/description/closure_parameter_position.md create mode 100644 docs/description/closure_spacing.md create mode 100644 docs/description/collection_alignment.md create mode 100644 docs/description/colon.md create mode 100644 docs/description/comma.md create mode 100644 docs/description/compiler_protocol_init.md create mode 100644 docs/description/conditional_returns_on_newline.md create mode 100644 docs/description/contains_over_filter_count.md create mode 100644 docs/description/contains_over_filter_is_empty.md create mode 100644 docs/description/contains_over_first_not_nil.md create mode 100644 docs/description/contains_over_range_nil_comparison.md create mode 100644 docs/description/control_statement.md create mode 100644 docs/description/convenience_type.md create mode 100644 docs/description/custom_rules.md create mode 100644 docs/description/cyclomatic_complexity.md create mode 100644 docs/description/deployment_target.md mode change 100755 => 100644 docs/description/description.json create mode 100644 docs/description/discarded_notification_center_observer.md create mode 100644 docs/description/discouraged_direct_init.md create mode 100644 docs/description/discouraged_object_literal.md create mode 100644 docs/description/discouraged_optional_boolean.md create mode 100644 docs/description/discouraged_optional_collection.md create mode 100644 docs/description/duplicate_enum_cases.md create mode 100644 docs/description/duplicate_imports.md create mode 100644 docs/description/dynamic_inline.md create mode 100644 docs/description/empty_collection_literal.md create mode 100644 docs/description/empty_count.md create mode 100644 docs/description/empty_enum_arguments.md create mode 100644 docs/description/empty_parameters.md create mode 100644 docs/description/empty_parentheses_with_trailing_closure.md create mode 100644 docs/description/empty_string.md create mode 100644 docs/description/empty_xctest_method.md create mode 100644 docs/description/enum_case_associated_values_count.md create mode 100644 docs/description/expiring_todo.md create mode 100644 docs/description/explicit_acl.md create mode 100644 docs/description/explicit_enum_raw_value.md create mode 100644 docs/description/explicit_init.md create mode 100644 docs/description/explicit_self.md create mode 100644 docs/description/explicit_top_level_acl.md create mode 100644 docs/description/explicit_type_interface.md create mode 100644 docs/description/extension_access_modifier.md create mode 100644 docs/description/fallthrough.md create mode 100644 docs/description/fatal_error_message.md create mode 100644 docs/description/file_header.md create mode 100644 docs/description/file_length.md create mode 100644 docs/description/file_name.md create mode 100644 docs/description/file_name_no_space.md create mode 100644 docs/description/file_types_order.md create mode 100644 docs/description/first_where.md create mode 100644 docs/description/flatmap_over_map_reduce.md create mode 100644 docs/description/for_where.md create mode 100644 docs/description/force_cast.md create mode 100644 docs/description/force_try.md create mode 100644 docs/description/force_unwrapping.md create mode 100644 docs/description/function_body_length.md create mode 100644 docs/description/function_default_parameter_at_end.md create mode 100644 docs/description/function_parameter_count.md create mode 100644 docs/description/generic_type_name.md create mode 100644 docs/description/identical_operands.md create mode 100644 docs/description/identifier_name.md create mode 100644 docs/description/implicit_getter.md create mode 100644 docs/description/implicit_return.md create mode 100644 docs/description/implicitly_unwrapped_optional.md create mode 100644 docs/description/indentation_width.md create mode 100644 docs/description/inert_defer.md create mode 100644 docs/description/is_disjoint.md create mode 100644 docs/description/joined_default_parameter.md create mode 100644 docs/description/large_tuple.md create mode 100644 docs/description/last_where.md create mode 100644 docs/description/leading_whitespace.md create mode 100644 docs/description/legacy_cggeometry_functions.md create mode 100644 docs/description/legacy_constant.md create mode 100644 docs/description/legacy_constructor.md create mode 100644 docs/description/legacy_hashing.md create mode 100644 docs/description/legacy_multiple.md create mode 100644 docs/description/legacy_nsgeometry_functions.md create mode 100644 docs/description/legacy_random.md create mode 100644 docs/description/let_var_whitespace.md create mode 100644 docs/description/line_length.md create mode 100644 docs/description/literal_expression_end_indentation.md create mode 100644 docs/description/lower_acl_than_parent.md create mode 100644 docs/description/mark.md create mode 100644 docs/description/missing_docs.md create mode 100644 docs/description/modifier_order.md create mode 100644 docs/description/multiline_arguments.md create mode 100644 docs/description/multiline_arguments_brackets.md create mode 100644 docs/description/multiline_function_chains.md create mode 100644 docs/description/multiline_literal_brackets.md create mode 100644 docs/description/multiline_parameters.md create mode 100644 docs/description/multiline_parameters_brackets.md create mode 100644 docs/description/multiple_closures_with_trailing_closure.md create mode 100644 docs/description/nesting.md create mode 100644 docs/description/nimble_operator.md create mode 100644 docs/description/no_extension_access_modifier.md create mode 100644 docs/description/no_fallthrough_only.md create mode 100644 docs/description/no_grouping_extension.md create mode 100644 docs/description/no_space_in_method_call.md create mode 100644 docs/description/notification_center_detachment.md create mode 100644 docs/description/nslocalizedstring_key.md create mode 100644 docs/description/nslocalizedstring_require_bundle.md create mode 100644 docs/description/nsobject_prefer_isequal.md create mode 100644 docs/description/number_separator.md create mode 100644 docs/description/object_literal.md create mode 100644 docs/description/opening_brace.md create mode 100644 docs/description/operator_usage_whitespace.md create mode 100644 docs/description/operator_whitespace.md create mode 100644 docs/description/optional_enum_case_matching.md create mode 100644 docs/description/orphaned_doc_comment.md create mode 100644 docs/description/overridden_super_call.md create mode 100644 docs/description/override_in_extension.md create mode 100644 docs/description/pattern_matching_keywords.md create mode 100644 docs/description/prefer_self_type_over_type_of_self.md create mode 100644 docs/description/prefixed_toplevel_constant.md create mode 100644 docs/description/private_action.md create mode 100644 docs/description/private_outlet.md create mode 100644 docs/description/private_over_fileprivate.md create mode 100644 docs/description/private_unit_test.md create mode 100644 docs/description/prohibited_interface_builder.md create mode 100644 docs/description/prohibited_super_call.md create mode 100644 docs/description/protocol_property_accessors_order.md create mode 100644 docs/description/quick_discouraged_call.md create mode 100644 docs/description/quick_discouraged_focused_test.md create mode 100644 docs/description/quick_discouraged_pending_test.md create mode 100644 docs/description/raw_value_for_camel_cased_codable_enum.md create mode 100644 docs/description/reduce_boolean.md create mode 100644 docs/description/reduce_into.md create mode 100644 docs/description/redundant_discardable_let.md create mode 100644 docs/description/redundant_nil_coalescing.md create mode 100644 docs/description/redundant_objc_attribute.md create mode 100644 docs/description/redundant_optional_initialization.md create mode 100644 docs/description/redundant_set_access_control.md create mode 100644 docs/description/redundant_string_enum_value.md create mode 100644 docs/description/redundant_type_annotation.md create mode 100644 docs/description/redundant_void_return.md create mode 100644 docs/description/required_deinit.md create mode 100644 docs/description/required_enum_case.md create mode 100644 docs/description/return_arrow_whitespace.md create mode 100644 docs/description/shorthand_operator.md create mode 100644 docs/description/single_test_class.md create mode 100644 docs/description/sorted_first_last.md create mode 100644 docs/description/sorted_imports.md create mode 100644 docs/description/statement_position.md create mode 100644 docs/description/static_operator.md create mode 100644 docs/description/strict_fileprivate.md create mode 100644 docs/description/strong_iboutlet.md create mode 100644 docs/description/superfluous_disable_command.md create mode 100644 docs/description/switch_case_alignment.md create mode 100644 docs/description/switch_case_on_newline.md create mode 100644 docs/description/syntactic_sugar.md create mode 100644 docs/description/todo.md create mode 100644 docs/description/toggle_bool.md create mode 100644 docs/description/trailing_closure.md create mode 100644 docs/description/trailing_comma.md create mode 100644 docs/description/trailing_newline.md create mode 100644 docs/description/trailing_semicolon.md create mode 100644 docs/description/trailing_whitespace.md create mode 100644 docs/description/type_body_length.md create mode 100644 docs/description/type_contents_order.md create mode 100644 docs/description/type_name.md create mode 100644 docs/description/unavailable_function.md create mode 100644 docs/description/unneeded_break_in_switch.md create mode 100644 docs/description/unneeded_parentheses_in_closure_argument.md create mode 100644 docs/description/unowned_variable_capture.md create mode 100644 docs/description/untyped_error_in_catch.md create mode 100644 docs/description/unused_capture_list.md create mode 100644 docs/description/unused_closure_parameter.md create mode 100644 docs/description/unused_control_flow_label.md create mode 100644 docs/description/unused_declaration.md create mode 100644 docs/description/unused_enumerated.md create mode 100644 docs/description/unused_import.md create mode 100644 docs/description/unused_optional_binding.md create mode 100644 docs/description/unused_setter_value.md create mode 100644 docs/description/valid_ibinspectable.md create mode 100644 docs/description/vertical_parameter_alignment.md create mode 100644 docs/description/vertical_parameter_alignment_on_call.md create mode 100644 docs/description/vertical_whitespace.md create mode 100644 docs/description/vertical_whitespace_between_cases.md create mode 100644 docs/description/vertical_whitespace_closing_braces.md create mode 100644 docs/description/vertical_whitespace_opening_braces.md create mode 100644 docs/description/void_return.md create mode 100644 docs/description/weak_delegate.md create mode 100644 docs/description/xct_specific_matcher.md create mode 100644 docs/description/xctfail_message.md create mode 100644 docs/description/yoda_condition.md mode change 100755 => 100644 docs/patterns.json diff --git a/docs/description/anyobject_protocol.md b/docs/description/anyobject_protocol.md new file mode 100644 index 0000000..dfb63c9 --- /dev/null +++ b/docs/description/anyobject_protocol.md @@ -0,0 +1,50 @@ +# AnyObject Protocol + +Prefer using `AnyObject` over `class` for class-only protocols. + +* **Identifier:** anyobject_protocol +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +protocol SomeProtocol {} + +``` + +```swift +protocol SomeClassOnlyProtocol: AnyObject {} + +``` + +```swift +protocol SomeClassOnlyProtocol: AnyObject, SomeInheritedProtocol {} + +``` + +```swift +@objc protocol SomeClassOnlyProtocol: AnyObject, SomeInheritedProtocol {} + +``` + +## Triggering Examples + +```swift +protocol SomeClassOnlyProtocol: ↓class {} + +``` + +```swift +protocol SomeClassOnlyProtocol: ↓class, SomeInheritedProtocol {} + +``` + +```swift +@objc protocol SomeClassOnlyProtocol: ↓class, SomeInheritedProtocol {} + +``` \ No newline at end of file diff --git a/docs/description/array_init.md b/docs/description/array_init.md new file mode 100644 index 0000000..67ff6fb --- /dev/null +++ b/docs/description/array_init.md @@ -0,0 +1,118 @@ +# Array Init + +Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array. + +* **Identifier:** array_init +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +Array(foo) + +``` + +```swift +foo.map { $0.0 } + +``` + +```swift +foo.map { $1 } + +``` + +```swift +foo.map { $0() } + +``` + +```swift +foo.map { ((), $0) } + +``` + +```swift +foo.map { $0! } + +``` + +```swift +foo.map { $0! /* force unwrap */ } + +``` + +```swift +foo.something { RouteMapper.map($0) } + +``` + +```swift +foo.map { !$0 } + +``` + +```swift +foo.map { /* a comment */ !$0 } + +``` + +## Triggering Examples + +```swift +↓foo.map({ $0 }) + +``` + +```swift +↓foo.map { $0 } + +``` + +```swift +↓foo.map { return $0 } + +``` + +```swift +↓foo.map { elem in + elem +} + +``` + +```swift +↓foo.map { elem in + return elem +} + +``` + +```swift +↓foo.map { (elem: String) in + elem +} + +``` + +```swift +↓foo.map { elem -> String in + elem +} + +``` + +```swift +↓foo.map { $0 /* a comment */ } + +``` + +```swift +↓foo.map { /* a comment */ $0 } + +``` \ No newline at end of file diff --git a/docs/description/attributes.md b/docs/description/attributes.md new file mode 100644 index 0000000..98ec152 --- /dev/null +++ b/docs/description/attributes.md @@ -0,0 +1,367 @@ +# Attributes + +Attributes should be on their own lines in functions and types, but on the same line as variables and imports. + +* **Identifier:** attributes +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, always_on_same_line: ["@IBAction", "@NSManaged"], always_on_line_above: [] + +## Non Triggering Examples + +```swift +@objc var x: String +``` + +```swift +@objc private var x: String +``` + +```swift +@nonobjc var x: String +``` + +```swift +@IBOutlet private var label: UILabel +``` + +```swift +@IBOutlet @objc private var label: UILabel +``` + +```swift +@NSCopying var name: NSString +``` + +```swift +@NSManaged var name: String? +``` + +```swift +@IBInspectable var cornerRadius: CGFloat +``` + +```swift +@available(iOS 9.0, *) + let stackView: UIStackView +``` + +```swift +@NSManaged func addSomeObject(book: SomeObject) +``` + +```swift +@IBAction func buttonPressed(button: UIButton) +``` + +```swift +@objc + @IBAction func buttonPressed(button: UIButton) +``` + +```swift +@available(iOS 9.0, *) + func animate(view: UIStackView) +``` + +```swift +@available(iOS 9.0, *, message="A message") + func animate(view: UIStackView) +``` + +```swift +@nonobjc + final class X +``` + +```swift +@available(iOS 9.0, *) + class UIStackView +``` + +```swift +@NSApplicationMain + class AppDelegate: NSObject, NSApplicationDelegate +``` + +```swift +@UIApplicationMain + class AppDelegate: NSObject, UIApplicationDelegate +``` + +```swift +@IBDesignable + class MyCustomView: UIView +``` + +```swift +@testable import SourceKittenFramework +``` + +```swift +@objc(foo_x) + var x: String +``` + +```swift +@available(iOS 9.0, *) +@objc(abc_stackView) + let stackView: UIStackView +``` + +```swift +@objc(abc_addSomeObject:) + @NSManaged func addSomeObject(book: SomeObject) +``` + +```swift +@objc(ABCThing) + @available(iOS 9.0, *) + class Thing +``` + +```swift +class Foo: NSObject { + override var description: String { return "" } +} +``` + +```swift +class Foo: NSObject { + + override func setUp() {} +} +``` + +```swift +@objc +class ⽺ {} + +``` + +```swift +extension Property { + + @available(*, unavailable, renamed: "isOptional") +public var optional: Bool { fatalError() } +} +``` + +```swift +@GKInspectable var maxSpeed: Float +``` + +```swift +@discardableResult + func a() -> Int +``` + +```swift +@objc + @discardableResult + func a() -> Int +``` + +```swift +func increase(f: @autoclosure () -> Int) -> Int +``` + +```swift +func foo(completionHandler: @escaping () -> Void) +``` + +```swift +private struct DefaultError: Error {} +``` + +```swift +@testable import foo + +private let bar = 1 +``` + +```swift +import XCTest +@testable import DeleteMe + +@available (iOS 11.0, *) +class DeleteMeTests: XCTestCase { +} +``` + +```swift +@objc +internal func foo(identifier: String, completion: @escaping (() -> Void)) {} +``` + +```swift +func printBoolOrTrue(_ expression: @autoclosure () throws -> Bool?) rethrows { + try print(expression() ?? true) +} +``` + +## Triggering Examples + +```swift +@objc + ↓var x: String +``` + +```swift +@objc + + ↓var x: String +``` + +```swift +@objc + private ↓var x: String +``` + +```swift +@nonobjc + ↓var x: String +``` + +```swift +@IBOutlet + private ↓var label: UILabel +``` + +```swift +@IBOutlet + + private ↓var label: UILabel +``` + +```swift +@NSCopying + ↓var name: NSString +``` + +```swift +@NSManaged + ↓var name: String? +``` + +```swift +@IBInspectable + ↓var cornerRadius: CGFloat +``` + +```swift +@available(iOS 9.0, *) ↓let stackView: UIStackView +``` + +```swift +@NSManaged + ↓func addSomeObject(book: SomeObject) +``` + +```swift +@IBAction + ↓func buttonPressed(button: UIButton) +``` + +```swift +@IBAction + @objc + ↓func buttonPressed(button: UIButton) +``` + +```swift +@available(iOS 9.0, *) ↓func animate(view: UIStackView) +``` + +```swift +@nonobjc final ↓class X +``` + +```swift +@available(iOS 9.0, *) ↓class UIStackView +``` + +```swift +@available(iOS 9.0, *) + @objc ↓class UIStackView +``` + +```swift +@available(iOS 9.0, *) @objc + ↓class UIStackView +``` + +```swift +@available(iOS 9.0, *) + + ↓class UIStackView +``` + +```swift +@UIApplicationMain ↓class AppDelegate: NSObject, UIApplicationDelegate +``` + +```swift +@IBDesignable ↓class MyCustomView: UIView +``` + +```swift +@testable +↓import SourceKittenFramework +``` + +```swift +@testable + + +↓import SourceKittenFramework +``` + +```swift +@objc(foo_x) ↓var x: String +``` + +```swift +@available(iOS 9.0, *) @objc(abc_stackView) + ↓let stackView: UIStackView +``` + +```swift +@objc(abc_addSomeObject:) @NSManaged + ↓func addSomeObject(book: SomeObject) +``` + +```swift +@objc(abc_addSomeObject:) + @NSManaged + ↓func addSomeObject(book: SomeObject) +``` + +```swift +@available(iOS 9.0, *) + @objc(ABCThing) ↓class Thing +``` + +```swift +@GKInspectable + ↓var maxSpeed: Float +``` + +```swift +@discardableResult ↓func a() -> Int +``` + +```swift +@objc + @discardableResult ↓func a() -> Int +``` + +```swift +@objc + + @discardableResult + ↓func a() -> Int +``` \ No newline at end of file diff --git a/docs/description/block_based_kvo.md b/docs/description/block_based_kvo.md new file mode 100644 index 0000000..2fd69e9 --- /dev/null +++ b/docs/description/block_based_kvo.md @@ -0,0 +1,37 @@ +# Block Based KVO + +Prefer the new block based KVO API with keypaths when using Swift 3.2 or later. + +* **Identifier:** block_based_kvo +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let observer = foo.observe(\.value, options: [.new]) { (foo, change) in + print(change.newValue) +} +``` + +## Triggering Examples + +```swift +class Foo: NSObject { + override ↓func observeValue(forKeyPath keyPath: String?, of object: Any?, + change: [NSKeyValueChangeKey : Any]?, + context: UnsafeMutableRawPointer?) {} +} +``` + +```swift +class Foo: NSObject { + override ↓func observeValue(forKeyPath keyPath: String?, of object: Any?, + change: Dictionary?, + context: UnsafeMutableRawPointer?) {} +} +``` \ No newline at end of file diff --git a/docs/description/class_delegate_protocol.md b/docs/description/class_delegate_protocol.md new file mode 100644 index 0000000..8b516ea --- /dev/null +++ b/docs/description/class_delegate_protocol.md @@ -0,0 +1,71 @@ +# Class Delegate Protocol + +Delegate protocols should be class-only so they can be weakly referenced. + +* **Identifier:** class_delegate_protocol +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +protocol FooDelegate: class {} + +``` + +```swift +protocol FooDelegate: class, BarDelegate {} + +``` + +```swift +protocol Foo {} + +``` + +```swift +class FooDelegate {} + +``` + +```swift +@objc protocol FooDelegate {} + +``` + +```swift +@objc(MyFooDelegate) + protocol FooDelegate {} + +``` + +```swift +protocol FooDelegate: BarDelegate {} + +``` + +```swift +protocol FooDelegate: AnyObject {} + +``` + +```swift +protocol FooDelegate: NSObjectProtocol {} + +``` + +## Triggering Examples + +```swift +↓protocol FooDelegate {} + +``` + +```swift +↓protocol FooDelegate: Bar {} + +``` \ No newline at end of file diff --git a/docs/description/closing_brace.md b/docs/description/closing_brace.md new file mode 100644 index 0000000..84a5a7a --- /dev/null +++ b/docs/description/closing_brace.md @@ -0,0 +1,33 @@ +# Closing Brace Spacing + +Closing brace with closing parenthesis should not have any whitespaces in the middle. + +* **Identifier:** closing_brace +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +[].map({ }) +``` + +```swift +[].map( + { } +) +``` + +## Triggering Examples + +```swift +[].map({ ↓} ) +``` + +```swift +[].map({ ↓} ) +``` \ No newline at end of file diff --git a/docs/description/closure_body_length.md b/docs/description/closure_body_length.md new file mode 100644 index 0000000..36d85d4 --- /dev/null +++ b/docs/description/closure_body_length.md @@ -0,0 +1,547 @@ +# Closure Body Length + +Closure bodies should not span too many lines. + +* **Identifier:** closure_body_length +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** metrics +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.2.0 +* **Default configuration:** warning: 20, error: 100 + +## Non Triggering Examples + +```swift +foo.bar { $0 } +``` + +```swift +foo.bar { toto in +} +``` + +```swift +foo.bar { toto in + let a = 0 + // toto + // toto + // toto + // toto + // toto + // toto + // toto + // toto + // toto + // toto + + + + + + + + + + +} +``` + +```swift +foo.bar { toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +} +``` + +```swift +foo.bar { toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + // toto + // toto + // toto + // toto + // toto + // toto + // toto + // toto + // toto + // toto + + + + + + + + + + +} +``` + +```swift +foo.bar({ toto in +}) +``` + +```swift +foo.bar({ toto in + let a = 0 +}) +``` + +```swift +foo.bar({ toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +}) +``` + +```swift +foo.bar(label: { toto in +}) +``` + +```swift +foo.bar(label: { toto in + let a = 0 +}) +``` + +```swift +foo.bar(label: { toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +}) +``` + +```swift +foo.bar(label: { toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +}, anotherLabel: { toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +}) +``` + +```swift +foo.bar(label: { toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +}) { toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +} +``` + +```swift +let foo: Bar = { toto in + let bar = Bar() + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + return bar +}() +``` + +## Triggering Examples + +```swift +foo.bar ↓{ toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +} +``` + +```swift +foo.bar ↓{ toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + // toto + // toto + // toto + // toto + // toto + // toto + // toto + // toto + // toto + // toto + + + + + + + + + + +} +``` + +```swift +foo.bar(↓{ toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +}) +``` + +```swift +foo.bar(label: ↓{ toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +}) +``` + +```swift +foo.bar(label: ↓{ toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +}, anotherLabel: ↓{ toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +}) +``` + +```swift +foo.bar(label: ↓{ toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +}) ↓{ toto in + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 +} +``` + +```swift +let foo: Bar = ↓{ toto in + let bar = Bar() + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + let a = 0 + return bar +}() +``` \ No newline at end of file diff --git a/docs/description/closure_end_indentation.md b/docs/description/closure_end_indentation.md new file mode 100644 index 0000000..3dab5c4 --- /dev/null +++ b/docs/description/closure_end_indentation.md @@ -0,0 +1,107 @@ +# Closure End Indentation + +Closure end should have the same indentation as the line that started it. + +* **Identifier:** closure_end_indentation +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +SignalProducer(values: [1, 2, 3]) + .startWithNext { number in + print(number) + } + +``` + +```swift +[1, 2].map { $0 + 1 } + +``` + +```swift +return match(pattern: pattern, with: [.comment]).flatMap { range in + return Command(string: contents, range: range) +}.flatMap { command in + return command.expand() +} + +``` + +```swift +foo(foo: bar, + options: baz) { _ in } + +``` + +```swift +someReallyLongProperty.chainingWithAnotherProperty + .foo { _ in } +``` + +```swift +foo(abc, 123) +{ _ in } + +``` + +```swift +function( + closure: { x in + print(x) + }, + anotherClosure: { y in + print(y) + }) +``` + +```swift +function(parameter: param, + closure: { x in + print(x) +}) +``` + +```swift +function(parameter: param, closure: { x in + print(x) + }, + anotherClosure: { y in + print(y) + }) +``` + +## Triggering Examples + +```swift +SignalProducer(values: [1, 2, 3]) + .startWithNext { number in + print(number) +↓} + +``` + +```swift +return match(pattern: pattern, with: [.comment]).flatMap { range in + return Command(string: contents, range: range) + ↓}.flatMap { command in + return command.expand() +↓} + +``` + +```swift +function( + closure: { x in + print(x) +↓}, + anotherClosure: { y in + print(y) +↓}) +``` \ No newline at end of file diff --git a/docs/description/closure_parameter_position.md b/docs/description/closure_parameter_position.md new file mode 100644 index 0000000..8e1c8d8 --- /dev/null +++ b/docs/description/closure_parameter_position.md @@ -0,0 +1,143 @@ +# Closure Parameter Position + +Closure parameters should be on the same line as opening brace. + +* **Identifier:** closure_parameter_position +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +[1, 2].map { $0 + 1 } + +``` + +```swift +[1, 2].map({ $0 + 1 }) + +``` + +```swift +[1, 2].map { number in + number + 1 +} + +``` + +```swift +[1, 2].map { number -> Int in + number + 1 +} + +``` + +```swift +[1, 2].map { (number: Int) -> Int in + number + 1 +} + +``` + +```swift +[1, 2].map { [weak self] number in + number + 1 +} + +``` + +```swift +[1, 2].something(closure: { number in + number + 1 +}) + +``` + +```swift +let isEmpty = [1, 2].isEmpty() + +``` + +```swift +rlmConfiguration.migrationBlock.map { rlmMigration in + return { migration, schemaVersion in + rlmMigration(migration.rlmMigration, schemaVersion) + } +} +``` + +```swift +let mediaView: UIView = { [weak self] index in + return UIView() +}(index) +``` + +## Triggering Examples + +```swift +[1, 2].map { + ↓number in + number + 1 +} + +``` + +```swift +[1, 2].map { + ↓number -> Int in + number + 1 +} + +``` + +```swift +[1, 2].map { + (↓number: Int) -> Int in + number + 1 +} + +``` + +```swift +[1, 2].map { + [weak self] ↓number in + number + 1 +} + +``` + +```swift +[1, 2].map { [weak self] + ↓number in + number + 1 +} + +``` + +```swift +[1, 2].map({ + ↓number in + number + 1 +}) + +``` + +```swift +[1, 2].something(closure: { + ↓number in + number + 1 +}) + +``` + +```swift +[1, 2].reduce(0) { + ↓sum, ↓number in + number + sum +} + +``` \ No newline at end of file diff --git a/docs/description/closure_spacing.md b/docs/description/closure_spacing.md new file mode 100644 index 0000000..b45b5e1 --- /dev/null +++ b/docs/description/closure_spacing.md @@ -0,0 +1,47 @@ +# Closure Spacing + +Closure expressions should have a single space inside each brace. + +* **Identifier:** closure_spacing +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +[].map ({ $0.description }) +``` + +```swift +[].filter { $0.contains(location) } +``` + +```swift +extension UITableViewCell: ReusableView { } +``` + +```swift +extension UITableViewCell: ReusableView {} +``` + +## Triggering Examples + +```swift +[].filter(↓{$0.contains(location)}) +``` + +```swift +[].map(↓{$0}) +``` + +```swift +(↓{each in return result.contains(where: ↓{e in return e}) }).count +``` + +```swift +filter ↓{ sorted ↓{ $0 < $1}} +``` \ No newline at end of file diff --git a/docs/description/collection_alignment.md b/docs/description/collection_alignment.md new file mode 100644 index 0000000..e3247a0 --- /dev/null +++ b/docs/description/collection_alignment.md @@ -0,0 +1,117 @@ +# Collection Element Alignment + +All elements in a collection literal should be vertically aligned + +* **Identifier:** collection_alignment +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, align_colons: false + +## Non Triggering Examples + +```swift +doThings(arg: [ + "foo": 1, + "bar": 2, + "fizz": 2, + "buzz": 2 +]) +``` + +```swift +let abc = [ + "alpha": "a", + "beta": "b", + "gamma": "g", + "delta": "d", + "epsilon": "e" +] +``` + +```swift +let meals = [ + "breakfast": "oatmeal", + "lunch": "sandwich", + "dinner": "burger" +] +``` + +```swift +let coordinates = [ + CLLocationCoordinate2D(latitude: 0, longitude: 33), + CLLocationCoordinate2D(latitude: 0, longitude: 66), + CLLocationCoordinate2D(latitude: 0, longitude: 99) +] +``` + +```swift +var evenNumbers: Set = [ + 2, + 4, + 6 +] +``` + +```swift +let abc = [1, 2, 3, 4] +``` + +```swift +let abc = [ + 1, 2, 3, 4 +] +``` + +```swift +let abc = [ + "foo": "bar", "fizz": "buzz" +] +``` + +## Triggering Examples + +```swift +doThings(arg: [ + "foo": 1, + "bar": 2, + ↓"fizz": 2, + ↓"buzz": 2 +]) +``` + +```swift +let abc = [ + "alpha": "a", + ↓"beta": "b", + "gamma": "g", + "delta": "d", + ↓"epsilon": "e" +] +``` + +```swift +let meals = [ + "breakfast": "oatmeal", + "lunch": "sandwich", + ↓"dinner": "burger" +] +``` + +```swift +let coordinates = [ + CLLocationCoordinate2D(latitude: 0, longitude: 33), + ↓CLLocationCoordinate2D(latitude: 0, longitude: 66), + CLLocationCoordinate2D(latitude: 0, longitude: 99) +] +``` + +```swift +var evenNumbers: Set = [ + 2, + ↓4, + 6 +] +``` \ No newline at end of file diff --git a/docs/description/colon.md b/docs/description/colon.md new file mode 100644 index 0000000..8723981 --- /dev/null +++ b/docs/description/colon.md @@ -0,0 +1,444 @@ +# Colon + +Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. + +* **Identifier:** colon +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, flexible_right_spacing: false, apply_to_dictionaries: true + +## Non Triggering Examples + +```swift +let abc: Void + +``` + +```swift +let abc: [Void: Void] + +``` + +```swift +let abc: (Void, Void) + +``` + +```swift +let abc: ([Void], String, Int) + +``` + +```swift +let abc: [([Void], String, Int)] + +``` + +```swift +let abc: String="def" + +``` + +```swift +let abc: Int=0 + +``` + +```swift +let abc: Enum=Enum.Value + +``` + +```swift +func abc(def: Void) {} + +``` + +```swift +func abc(def: Void, ghi: Void) {} + +``` + +```swift +let abc: String = "abc:" +``` + +```swift +let abc = [Void: Void]() + +``` + +```swift +let abc = [1: [3: 2], 3: 4] + +``` + +```swift +let abc = ["string": "string"] + +``` + +```swift +let abc = ["string:string": "string"] + +``` + +```swift +let abc: [String: Int] + +``` + +```swift +func foo(bar: [String: Int]) {} + +``` + +```swift +func foo() -> [String: Int] { return [:] } + +``` + +```swift +let abc: Any + +``` + +```swift +let abc: [Any: Int] + +``` + +```swift +let abc: [String: Any] + +``` + +```swift +class Foo: Bar {} + +``` + +```swift +class Foo: Bar {} + +``` + +```swift +class Foo: Bar {} + +``` + +```swift +class Foo: Bar {} + +``` + +```swift +class Foo {} + +``` + +```swift +switch foo { +case .bar: + _ = something() +} +``` + +```swift +object.method(x: 5, y: "string") + +``` + +```swift +object.method(x: 5, y: + "string") +``` + +```swift +object.method(5, y: "string") + +``` + +```swift +func abc() { def(ghi: jkl) } +``` + +```swift +func abc(def: Void) { ghi(jkl: mno) } +``` + +```swift +class ABC { let def = ghi(jkl: mno) } } +``` + +```swift +func foo() { let dict = [1: 1] } +``` + +```swift +let aaa = Self.bbb ? Self.ccc : Self.ddd else { +return nil +Example("} +``` + +## Triggering Examples + +```swift +let ↓abc:Void + +``` + +```swift +let ↓abc: Void + +``` + +```swift +let ↓abc :Void + +``` + +```swift +let ↓abc : Void + +``` + +```swift +let ↓abc : [Void: Void] + +``` + +```swift +let ↓abc : (Void, String, Int) + +``` + +```swift +let ↓abc : ([Void], String, Int) + +``` + +```swift +let ↓abc : [([Void], String, Int)] + +``` + +```swift +let ↓abc: (Void, String, Int) + +``` + +```swift +let ↓abc: ([Void], String, Int) + +``` + +```swift +let ↓abc: [([Void], String, Int)] + +``` + +```swift +let ↓abc :String="def" + +``` + +```swift +let ↓abc :Int=0 + +``` + +```swift +let ↓abc :Int = 0 + +``` + +```swift +let ↓abc:Int=0 + +``` + +```swift +let ↓abc:Int = 0 + +``` + +```swift +let ↓abc:Enum=Enum.Value + +``` + +```swift +func abc(↓def:Void) {} + +``` + +```swift +func abc(↓def: Void) {} + +``` + +```swift +func abc(↓def :Void) {} + +``` + +```swift +func abc(↓def : Void) {} + +``` + +```swift +func abc(def: Void, ↓ghi :Void) {} + +``` + +```swift +let abc = [Void↓:Void]() + +``` + +```swift +let abc = [Void↓ : Void]() + +``` + +```swift +let abc = [Void↓: Void]() + +``` + +```swift +let abc = [Void↓ : Void]() + +``` + +```swift +let abc = [1: [3↓ : 2], 3: 4] + +``` + +```swift +let abc = [1: [3↓ : 2], 3↓: 4] + +``` + +```swift +let abc: [↓String : Int] + +``` + +```swift +let abc: [↓String:Int] + +``` + +```swift +func foo(bar: [↓String : Int]) {} + +``` + +```swift +func foo(bar: [↓String:Int]) {} + +``` + +```swift +func foo() -> [↓String : Int] { return [:] } + +``` + +```swift +func foo() -> [↓String:Int] { return [:] } + +``` + +```swift +let ↓abc : Any + +``` + +```swift +let abc: [↓Any : Int] + +``` + +```swift +let abc: [↓String : Any] + +``` + +```swift +class ↓Foo : Bar {} + +``` + +```swift +class ↓Foo:Bar {} + +``` + +```swift +class ↓Foo : Bar {} + +``` + +```swift +class ↓Foo:Bar {} + +``` + +```swift +class ↓Foo:Bar {} + +``` + +```swift +class ↓Foo:Bar {} + +``` + +```swift +class Foo<↓T:Equatable> {} + +``` + +```swift +class Foo<↓T : Equatable> {} + +``` + +```swift +object.method(x: 5, y↓ : "string") + +``` + +```swift +object.method(x↓:5, y: "string") + +``` + +```swift +object.method(x↓: 5, y: "string") + +``` + +```swift +func abc() { def(ghi↓:jkl) } +``` + +```swift +func abc(def: Void) { ghi(jkl↓:mno) } +``` + +```swift +class ABC { let def = ghi(jkl↓:mno) } } +``` + +```swift +func foo() { let dict = [1↓ : 1] } +``` \ No newline at end of file diff --git a/docs/description/comma.md b/docs/description/comma.md new file mode 100644 index 0000000..fd85ae0 --- /dev/null +++ b/docs/description/comma.md @@ -0,0 +1,73 @@ +# Comma Spacing + +There should be no space before and one after any comma. + +* **Identifier:** comma +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func abc(a: String, b: String) { } +``` + +```swift +abc(a: "string", b: "string" +``` + +```swift +enum a { case a, b, c } +``` + +```swift +func abc( + a: String, // comment + bcd: String // comment +) { +} + +``` + +```swift +func abc( + a: String, + bcd: String +) { +} + +``` + +```swift +#imageLiteral(resourceName: "foo,bar,baz") +``` + +## Triggering Examples + +```swift +func abc(a: String↓ ,b: String) { } +``` + +```swift +func abc(a: String↓ ,b: String↓ ,c: String↓ ,d: String) { } +``` + +```swift +abc(a: "string"↓,b: "string" +``` + +```swift +enum a { case a↓ ,b } +``` + +```swift +let result = plus( + first: 3↓ , // #683 + second: 4 +) + +``` \ No newline at end of file diff --git a/docs/description/compiler_protocol_init.md b/docs/description/compiler_protocol_init.md new file mode 100644 index 0000000..9384e5b --- /dev/null +++ b/docs/description/compiler_protocol_init.md @@ -0,0 +1,35 @@ +# Compiler Protocol Init + +The initializers declared in compiler protocols such as `ExpressibleByArrayLiteral` shouldn't be called directly. + +* **Identifier:** compiler_protocol_init +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let set: Set = [1, 2] + +``` + +```swift +let set = Set(array) + +``` + +## Triggering Examples + +```swift +let set = ↓Set(arrayLiteral: 1, 2) + +``` + +```swift +let set = ↓Set.init(arrayLiteral: 1, 2) + +``` \ No newline at end of file diff --git a/docs/description/conditional_returns_on_newline.md b/docs/description/conditional_returns_on_newline.md new file mode 100644 index 0000000..35118de --- /dev/null +++ b/docs/description/conditional_returns_on_newline.md @@ -0,0 +1,73 @@ +# Conditional Returns on Newline + +Conditional statements should always return on the next line + +* **Identifier:** conditional_returns_on_newline +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, if_only: false + +## Non Triggering Examples + +```swift +guard true else { + return true +} +``` + +```swift +guard true, + let x = true else { + return true +} +``` + +```swift +if true else { + return true +} +``` + +```swift +if true, + let x = true else { + return true +} +``` + +```swift +if textField.returnKeyType == .Next { +``` + +```swift +if true { // return } +``` + +```swift +/*if true { */ return } +``` + +## Triggering Examples + +```swift +↓guard true else { return } +``` + +```swift +↓if true { return } +``` + +```swift +↓if true { break } else { return } +``` + +```swift +↓if true { break } else { return } +``` + +```swift +↓if true { return "YES" } else { return "NO" } +``` \ No newline at end of file diff --git a/docs/description/contains_over_filter_count.md b/docs/description/contains_over_filter_count.md new file mode 100644 index 0000000..bdaef69 --- /dev/null +++ b/docs/description/contains_over_filter_count.md @@ -0,0 +1,120 @@ +# Contains Over Filter Count + +Prefer `contains` over comparing `filter(where:).count` to 0. + +* **Identifier:** contains_over_filter_count +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let result = myList.filter(where: { $0 % 2 == 0 }).count > 1 + +``` + +```swift +let result = myList.filter { $0 % 2 == 0 }.count > 1 + +``` + +```swift +let result = myList.filter(where: { $0 % 2 == 0 }).count > 01 + +``` + +```swift +let result = myList.filter(where: { $0 % 2 == 0 }).count == 1 + +``` + +```swift +let result = myList.filter { $0 % 2 == 0 }.count == 1 + +``` + +```swift +let result = myList.filter(where: { $0 % 2 == 0 }).count == 01 + +``` + +```swift +let result = myList.filter(where: { $0 % 2 == 0 }).count != 1 + +``` + +```swift +let result = myList.filter { $0 % 2 == 0 }.count != 1 + +``` + +```swift +let result = myList.filter(where: { $0 % 2 == 0 }).count != 01 + +``` + +```swift +let result = myList.contains(where: { $0 % 2 == 0 }) + +``` + +```swift +let result = !myList.contains(where: { $0 % 2 == 0 }) + +``` + +```swift +let result = myList.contains(10) + +``` + +## Triggering Examples + +```swift +let result = ↓myList.filter(where: { $0 % 2 == 0 }).count > 0 + +``` + +```swift +let result = ↓myList.filter { $0 % 2 == 0 }.count > 0 + +``` + +```swift +let result = ↓myList.filter(where: someFunction).count > 0 + +``` + +```swift +let result = ↓myList.filter(where: { $0 % 2 == 0 }).count == 0 + +``` + +```swift +let result = ↓myList.filter { $0 % 2 == 0 }.count == 0 + +``` + +```swift +let result = ↓myList.filter(where: someFunction).count == 0 + +``` + +```swift +let result = ↓myList.filter(where: { $0 % 2 == 0 }).count != 0 + +``` + +```swift +let result = ↓myList.filter { $0 % 2 == 0 }.count != 0 + +``` + +```swift +let result = ↓myList.filter(where: someFunction).count != 0 + +``` \ No newline at end of file diff --git a/docs/description/contains_over_filter_is_empty.md b/docs/description/contains_over_filter_is_empty.md new file mode 100644 index 0000000..9f534b5 --- /dev/null +++ b/docs/description/contains_over_filter_is_empty.md @@ -0,0 +1,80 @@ +# Contains Over Filter Is Empty + +Prefer `contains` over using `filter(where:).isEmpty` + +* **Identifier:** contains_over_filter_is_empty +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let result = myList.filter(where: { $0 % 2 == 0 }).count > 1 + +``` + +```swift +let result = myList.filter { $0 % 2 == 0 }.count > 1 + +``` + +```swift +let result = myList.filter(where: { $0 % 2 == 0 }).count == 1 + +``` + +```swift +let result = myList.filter { $0 % 2 == 0 }.count == 1 + +``` + +```swift +let result = myList.filter(where: { $0 % 2 == 0 }).count != 1 + +``` + +```swift +let result = myList.filter { $0 % 2 == 0 }.count != 1 + +``` + +```swift +let result = myList.contains(where: { $0 % 2 == 0 }) + +``` + +```swift +let result = !myList.contains(where: { $0 % 2 == 0 }) + +``` + +```swift +let result = myList.contains(10) + +``` + +## Triggering Examples + +```swift +let result = ↓myList.filter(where: { $0 % 2 == 0 }).isEmpty + +``` + +```swift +let result = !↓myList.filter(where: { $0 % 2 == 0 }).isEmpty + +``` + +```swift +let result = ↓myList.filter { $0 % 2 == 0 }.isEmpty + +``` + +```swift +let result = ↓myList.filter(where: someFunction).isEmpty + +``` \ No newline at end of file diff --git a/docs/description/contains_over_first_not_nil.md b/docs/description/contains_over_first_not_nil.md new file mode 100644 index 0000000..94fa7a2 --- /dev/null +++ b/docs/description/contains_over_first_not_nil.md @@ -0,0 +1,155 @@ +# Contains over first not nil + +Prefer `contains` over `first(where:) != nil` and `firstIndex(where:) != nil`. + +* **Identifier:** contains_over_first_not_nil +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let first = myList.first(where: { $0 % 2 == 0 }) + +``` + +```swift +let first = myList.first { $0 % 2 == 0 } + +``` + +```swift +let firstIndex = myList.firstIndex(where: { $0 % 2 == 0 }) + +``` + +```swift +let firstIndex = myList.firstIndex { $0 % 2 == 0 } + +``` + +## Triggering Examples + +```swift +↓myList.first { $0 % 2 == 0 } != nil + +``` + +```swift +↓myList.first(where: { $0 % 2 == 0 }) != nil + +``` + +```swift +↓myList.map { $0 + 1 }.first(where: { $0 % 2 == 0 }) != nil + +``` + +```swift +↓myList.first(where: someFunction) != nil + +``` + +```swift +↓myList.map { $0 + 1 }.first { $0 % 2 == 0 } != nil + +``` + +```swift +(↓myList.first { $0 % 2 == 0 }) != nil + +``` + +```swift +↓myList.first { $0 % 2 == 0 } == nil + +``` + +```swift +↓myList.first(where: { $0 % 2 == 0 }) == nil + +``` + +```swift +↓myList.map { $0 + 1 }.first(where: { $0 % 2 == 0 }) == nil + +``` + +```swift +↓myList.first(where: someFunction) == nil + +``` + +```swift +↓myList.map { $0 + 1 }.first { $0 % 2 == 0 } == nil + +``` + +```swift +(↓myList.first { $0 % 2 == 0 }) == nil + +``` + +```swift +↓myList.firstIndex { $0 % 2 == 0 } != nil + +``` + +```swift +↓myList.firstIndex(where: { $0 % 2 == 0 }) != nil + +``` + +```swift +↓myList.map { $0 + 1 }.firstIndex(where: { $0 % 2 == 0 }) != nil + +``` + +```swift +↓myList.firstIndex(where: someFunction) != nil + +``` + +```swift +↓myList.map { $0 + 1 }.firstIndex { $0 % 2 == 0 } != nil + +``` + +```swift +(↓myList.firstIndex { $0 % 2 == 0 }) != nil + +``` + +```swift +↓myList.firstIndex { $0 % 2 == 0 } == nil + +``` + +```swift +↓myList.firstIndex(where: { $0 % 2 == 0 }) == nil + +``` + +```swift +↓myList.map { $0 + 1 }.firstIndex(where: { $0 % 2 == 0 }) == nil + +``` + +```swift +↓myList.firstIndex(where: someFunction) == nil + +``` + +```swift +↓myList.map { $0 + 1 }.firstIndex { $0 % 2 == 0 } == nil + +``` + +```swift +(↓myList.firstIndex { $0 % 2 == 0 }) == nil + +``` \ No newline at end of file diff --git a/docs/description/contains_over_range_nil_comparison.md b/docs/description/contains_over_range_nil_comparison.md new file mode 100644 index 0000000..1841402 --- /dev/null +++ b/docs/description/contains_over_range_nil_comparison.md @@ -0,0 +1,39 @@ +# Contains over range(of:) comparison to nil + +Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`. + +* **Identifier:** contains_over_range_nil_comparison +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let range = myString.range(of: "Test") +``` + +```swift +myString.contains("Test") +``` + +```swift +!myString.contains("Test") +``` + +```swift +resourceString.range(of: rule.regex, options: .regularExpression) != nil +``` + +## Triggering Examples + +```swift +↓myString.range(of: "Test") != nil +``` + +```swift +↓myString.range(of: "Test") == nil +``` \ No newline at end of file diff --git a/docs/description/control_statement.md b/docs/description/control_statement.md new file mode 100644 index 0000000..71602d9 --- /dev/null +++ b/docs/description/control_statement.md @@ -0,0 +1,206 @@ +# Control Statement + +`if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses. + +* **Identifier:** control_statement +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +if condition { + +``` + +```swift +if (a, b) == (0, 1) { + +``` + +```swift +if (a || b) && (c || d) { + +``` + +```swift +if (min...max).contains(value) { + +``` + +```swift +if renderGif(data) { + +``` + +```swift +renderGif(data) + +``` + +```swift +for item in collection { + +``` + +```swift +for (key, value) in dictionary { + +``` + +```swift +for (index, value) in enumerate(array) { + +``` + +```swift +for var index = 0; index < 42; index++ { + +``` + +```swift +guard condition else { + +``` + +```swift +while condition { + +``` + +```swift +} while condition { + +``` + +```swift +do { ; } while condition { + +``` + +```swift +switch foo { + +``` + +```swift +do { +} catch let error as NSError { +} +``` + +```swift +foo().catch(all: true) {} +``` + +```swift +if max(a, b) < c { + +``` + +```swift +switch (lhs, rhs) { + +``` + +## Triggering Examples + +```swift +↓if (condition) { + +``` + +```swift +↓if(condition) { + +``` + +```swift +↓if (condition == endIndex) { + +``` + +```swift +↓if ((a || b) && (c || d)) { + +``` + +```swift +↓if ((min...max).contains(value)) { + +``` + +```swift +↓for (item in collection) { + +``` + +```swift +↓for (var index = 0; index < 42; index++) { + +``` + +```swift +↓for(item in collection) { + +``` + +```swift +↓for(var index = 0; index < 42; index++) { + +``` + +```swift +↓guard (condition) else { + +``` + +```swift +↓while (condition) { + +``` + +```swift +↓while(condition) { + +``` + +```swift +} ↓while (condition) { + +``` + +```swift +} ↓while(condition) { + +``` + +```swift +do { ; } ↓while(condition) { + +``` + +```swift +do { ; } ↓while (condition) { + +``` + +```swift +↓switch (foo) { + +``` + +```swift +do { +} ↓catch(let error as NSError) { +} +``` + +```swift +↓if (max(a, b) < c) { + +``` \ No newline at end of file diff --git a/docs/description/convenience_type.md b/docs/description/convenience_type.md new file mode 100644 index 0000000..6f0736d --- /dev/null +++ b/docs/description/convenience_type.md @@ -0,0 +1,64 @@ +# Convenience Type + +Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation. + +* **Identifier:** convenience_type +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +enum Math { // enum + public static let pi = 3.14 +} +``` + +```swift +// class with inheritance +class MathViewController: UIViewController { + public static let pi = 3.14 +} +``` + +```swift +@objc class Math: NSObject { // class visible to Obj-C + public static let pi = 3.14 +} +``` + +```swift +struct Math { // type with non-static declarations + public static let pi = 3.14 + public let randomNumber = 2 +} +``` + +```swift +class DummyClass {} +``` + +## Triggering Examples + +```swift +↓struct Math { + public static let pi = 3.14 +} +``` + +```swift +↓class Math { + public static let pi = 3.14 +} +``` + +```swift +↓struct Math { + public static let pi = 3.14 + @available(*, unavailable) init() {} +} +``` \ No newline at end of file diff --git a/docs/description/custom_rules.md b/docs/description/custom_rules.md new file mode 100644 index 0000000..5d63236 --- /dev/null +++ b/docs/description/custom_rules.md @@ -0,0 +1,11 @@ +# Custom Rules + +Create custom rules by providing a regex string. Optionally specify what syntax kinds to match against, the severity level, and what message to display. + +* **Identifier:** custom_rules +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** user-defined \ No newline at end of file diff --git a/docs/description/cyclomatic_complexity.md b/docs/description/cyclomatic_complexity.md new file mode 100644 index 0000000..0f96c48 --- /dev/null +++ b/docs/description/cyclomatic_complexity.md @@ -0,0 +1,74 @@ +# Cyclomatic Complexity + +Complexity of function bodies should be limited. + +* **Identifier:** cyclomatic_complexity +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** metrics +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning: 10, error: 20, ignores_case_statements: false + +## Non Triggering Examples + +```swift +func f1() { + if true { + for _ in 1..5 { } + } + if false { } +} +``` + +```swift +func f(code: Int) -> Int { + switch code { + case 0: fallthrough + case 0: return 1 + case 0: return 1 + case 0: return 1 + case 0: return 1 + case 0: return 1 + case 0: return 1 + case 0: return 1 + case 0: return 1 + default: return 1 + } +} +``` + +```swift +func f1() { + if true {}; if true {}; if true {}; if true {}; if true {}; if true {} + func f2() { + if true {}; if true {}; if true {}; if true {}; if true {} + } +} +``` + +## Triggering Examples + +```swift +↓func f1() { + if true { + if true { + if false {} + } + } + if false {} + let i = 0 + switch i { + case 1: break + case 2: break + case 3: break + case 4: break + default: break + } + for _ in 1...5 { + guard true else { + return + } + } +} +``` \ No newline at end of file diff --git a/docs/description/deployment_target.md b/docs/description/deployment_target.md new file mode 100644 index 0000000..7dc560d --- /dev/null +++ b/docs/description/deployment_target.md @@ -0,0 +1,103 @@ +# Deployment Target + +Availability checks or attributes shouldn't be using older versions that are satisfied by the deployment target. + +* **Identifier:** deployment_target +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.1.0 +* **Default configuration:** warning, iOS_deployment_target: 7.0, macOS_deployment_target: 10.9, watchOS_deployment_target: 1.0, tvOS_deployment_target: 9.0 + +## Non Triggering Examples + +```swift +@available(iOS 12.0, *) +class A {} +``` + +```swift +@available(watchOS 4.0, *) +class A {} +``` + +```swift +@available(swift 3.0.2) +class A {} +``` + +```swift +class A {} +``` + +```swift +if #available(iOS 10.0, *) {} +``` + +```swift +if #available(iOS 10, *) {} +``` + +```swift +guard #available(iOS 12.0, *) else { return } +``` + +## Triggering Examples + +```swift +↓@available(iOS 6.0, *) +class A {} +``` + +```swift +↓@available(iOS 7.0, *) +class A {} +``` + +```swift +↓@available(iOS 6, *) +class A {} +``` + +```swift +↓@available(iOS 6.0, macOS 10.12, *) + class A {} +``` + +```swift +↓@available(macOS 10.12, iOS 6.0, *) + class A {} +``` + +```swift +↓@available(macOS 10.7, *) +class A {} +``` + +```swift +↓@available(OSX 10.7, *) +class A {} +``` + +```swift +↓@available(watchOS 0.9, *) +class A {} +``` + +```swift +↓@available(tvOS 8, *) +class A {} +``` + +```swift +if ↓#available(iOS 6.0, *) {} +``` + +```swift +if ↓#available(iOS 6, *) {} +``` + +```swift +guard ↓#available(iOS 6.0, *) else { return } +``` \ No newline at end of file diff --git a/docs/description/description.json b/docs/description/description.json old mode 100755 new mode 100644 index 879988d..45cf6f9 --- a/docs/description/description.json +++ b/docs/description/description.json @@ -1,740 +1,957 @@ [ + { + "patternId": "anyobject_protocol", + "title": "AnyObject Protocol", + "description": "Prefer using `AnyObject` over `class` for class-only protocols." + }, + { + "patternId": "array_init", + "title": "Array Init", + "description": "Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array." + }, { "patternId": "attributes", "title": "Attributes", - "timeToFix": 5, "description": "Attributes should be on their own lines in functions and types, but on the same line as variables and imports." }, + { + "patternId": "block_based_kvo", + "title": "Block Based KVO", + "description": "Prefer the new block based KVO API with keypaths when using Swift 3.2 or later." + }, { "patternId": "class_delegate_protocol", "title": "Class Delegate Protocol", - "timeToFix": 5, "description": "Delegate protocols should be class-only so they can be weakly referenced." }, { "patternId": "closing_brace", "title": "Closing Brace Spacing", - "timeToFix": 5, "description": "Closing brace with closing parenthesis should not have any whitespaces in the middle." }, + { + "patternId": "closure_body_length", + "title": "Closure Body Length", + "description": "Closure bodies should not span too many lines." + }, { "patternId": "closure_end_indentation", "title": "Closure End Indentation", - "timeToFix": 5, "description": "Closure end should have the same indentation as the line that started it." }, { "patternId": "closure_parameter_position", "title": "Closure Parameter Position", - "timeToFix": 5, "description": "Closure parameters should be on the same line as opening brace." }, { "patternId": "closure_spacing", "title": "Closure Spacing", - "timeToFix": 5, "description": "Closure expressions should have a single space inside each brace." }, + { + "patternId": "collection_alignment", + "title": "Collection Element Alignment", + "description": "All elements in a collection literal should be vertically aligned" + }, { "patternId": "colon", "title": "Colon", - "timeToFix": 5, "description": "Colons should be next to the identifier when specifying a type and next to the key in dictionary literals." }, { "patternId": "comma", "title": "Comma Spacing", - "timeToFix": 5, "description": "There should be no space before and one after any comma." }, { "patternId": "compiler_protocol_init", "title": "Compiler Protocol Init", - "timeToFix": 5, - "description": "The initializers declared in compiler protocols such as ExpressibleByArrayLiteral shouldn't be called directly." + "description": "The initializers declared in compiler protocols such as `ExpressibleByArrayLiteral` shouldn't be called directly." }, { "patternId": "conditional_returns_on_newline", "title": "Conditional Returns on Newline", - "timeToFix": 5, "description": "Conditional statements should always return on the next line" }, + { + "patternId": "contains_over_filter_count", + "title": "Contains Over Filter Count", + "description": "Prefer `contains` over comparing `filter(where:).count` to 0." + }, + { + "patternId": "contains_over_filter_is_empty", + "title": "Contains Over Filter Is Empty", + "description": "Prefer `contains` over using `filter(where:).isEmpty`" + }, + { + "patternId": "contains_over_first_not_nil", + "title": "Contains over first not nil", + "description": "Prefer `contains` over `first(where:) != nil` and `firstIndex(where:) != nil`." + }, + { + "patternId": "contains_over_range_nil_comparison", + "title": "Contains over range(of:) comparison to nil", + "description": "Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`." + }, { "patternId": "control_statement", "title": "Control Statement", - "timeToFix": 5, - "description": "if,for,while,do statements shouldn't wrap their conditionals in parentheses." + "description": "`if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses." + }, + { + "patternId": "convenience_type", + "title": "Convenience Type", + "description": "Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation." }, { "patternId": "custom_rules", "title": "Custom Rules", - "timeToFix": 5, "description": "Create custom rules by providing a regex string. Optionally specify what syntax kinds to match against, the severity level, and what message to display." }, { "patternId": "cyclomatic_complexity", "title": "Cyclomatic Complexity", - "timeToFix": 5, "description": "Complexity of function bodies should be limited." }, + { + "patternId": "deployment_target", + "title": "Deployment Target", + "description": "Availability checks or attributes shouldn't be using older versions that are satisfied by the deployment target." + }, { "patternId": "discarded_notification_center_observer", "title": "Discarded Notification Center Observer", - "timeToFix": 5, "description": "When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later." }, + { + "patternId": "discouraged_direct_init", + "title": "Discouraged Direct Initialization", + "description": "Discouraged direct initialization of types that can be harmful." + }, + { + "patternId": "discouraged_object_literal", + "title": "Discouraged Object Literal", + "description": "Prefer initializers over object literals." + }, + { + "patternId": "discouraged_optional_boolean", + "title": "Discouraged Optional Boolean", + "description": "Prefer non-optional booleans over optional booleans." + }, + { + "patternId": "discouraged_optional_collection", + "title": "Discouraged Optional Collection", + "description": "Prefer empty collection over optional collection." + }, + { + "patternId": "duplicate_enum_cases", + "title": "Duplicate Enum Cases", + "description": "Enum can't contain multiple cases with the same name." + }, + { + "patternId": "duplicate_imports", + "title": "Duplicate Imports", + "description": "Imports should be unique." + }, { "patternId": "dynamic_inline", "title": "Dynamic Inline", - "timeToFix": 5, - "description": "avoid using 'dynamic' and '@inline(__always)' together." + "description": "Avoid using 'dynamic' and '@inline(__always)' together." + }, + { + "patternId": "empty_collection_literal", + "title": "Empty Collection Literal", + "description": "Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal." }, { "patternId": "empty_count", "title": "Empty Count", - "timeToFix": 5, - "description": "Prefer checking isEmpty over comparing count to zero." + "description": "Prefer checking `isEmpty` over comparing `count` to zero." }, { "patternId": "empty_enum_arguments", "title": "Empty Enum Arguments", - "timeToFix": 5, "description": "Arguments can be omitted when matching enums with associated types if they are not used." }, { "patternId": "empty_parameters", "title": "Empty Parameters", - "timeToFix": 5, - "description": "Prefer () -> over Void -> ." + "description": "Prefer `() -> ` over `Void -> `." }, { "patternId": "empty_parentheses_with_trailing_closure", "title": "Empty Parentheses with Trailing Closure", - "timeToFix": 5, "description": "When using trailing closures, empty parentheses should be avoided after the method call." }, + { + "patternId": "empty_string", + "title": "Empty String", + "description": "Prefer checking `isEmpty` over comparing `string` to an empty string literal." + }, + { + "patternId": "empty_xctest_method", + "title": "Empty XCTest Method", + "description": "Empty XCTest method should be avoided." + }, + { + "patternId": "enum_case_associated_values_count", + "title": "Enum Case Associated Values Count", + "description": "Number of associated values in an enum case should be low" + }, + { + "patternId": "expiring_todo", + "title": "ExpiringTodo", + "description": "TODOs and FIXMEs should be resolved prior to their expiry date." + }, + { + "patternId": "explicit_acl", + "title": "Explicit ACL", + "description": "All declarations should specify Access Control Level keywords explicitly." + }, + { + "patternId": "explicit_enum_raw_value", + "title": "Explicit Enum Raw Value", + "description": "Enums should be explicitly assigned their raw values." + }, { "patternId": "explicit_init", "title": "Explicit Init", - "timeToFix": 5, "description": "Explicitly calling .init() should be avoided." }, + { + "patternId": "explicit_self", + "title": "Explicit Self", + "description": "Instance variables and functions should be explicitly accessed with 'self.'." + }, { "patternId": "explicit_top_level_acl", "title": "Explicit Top Level ACL", - "timeToFix": 5, "description": "Top-level declarations should specify Access Control Level keywords explicitly." }, { "patternId": "explicit_type_interface", "title": "Explicit Type Interface", - "timeToFix": 5, "description": "Properties should have a type interface" }, { "patternId": "extension_access_modifier", "title": "Extension Access Modifier", - "timeToFix": 5, "description": "Prefer to use extension access modifiers" }, + { + "patternId": "fallthrough", + "title": "Fallthrough", + "description": "Fallthrough should be avoided." + }, { "patternId": "fatal_error_message", "title": "Fatal Error Message", - "timeToFix": 5, "description": "A fatalError call should have a message." }, { "patternId": "file_header", "title": "File Header", - "timeToFix": 5, - "description": "Files should have consistent header comments." + "description": "Header comments should be consistent with project patterns. The SWIFTLINT_CURRENT_FILENAME placeholder can optionally be used in the required and forbidden patterns. It will be replaced by the real file name." }, { "patternId": "file_length", "title": "File Line Length", - "timeToFix": 5, "description": "Files should not span too many lines." }, + { + "patternId": "file_name", + "title": "File Name", + "description": "File name should match a type or extension declared in the file (if any)." + }, + { + "patternId": "file_name_no_space", + "title": "File Name No Space", + "description": "File name should not contain any whitespace." + }, + { + "patternId": "file_types_order", + "title": "File Types Order", + "description": "Specifies how the types within a file should be ordered." + }, { "patternId": "first_where", "title": "First Where", - "timeToFix": 5, - "description": "Prefer using .first(where:) over .filter { }.first in collections." + "description": "Prefer using `.first(where:)` over `.filter { }.first` in collections." + }, + { + "patternId": "flatmap_over_map_reduce", + "title": "FlatMap over map and reduce", + "description": "Prefer `flatMap` over `map` followed by `reduce([], +)`." }, { "patternId": "for_where", "title": "For Where", - "timeToFix": 5, - "description": "where clauses are preferred over a single if inside a for." + "description": "`where` clauses are preferred over a single `if` inside a `for`." }, { "patternId": "force_cast", "title": "Force Cast", - "timeToFix": 5, "description": "Force casts should be avoided." }, { "patternId": "force_try", "title": "Force Try", - "timeToFix": 5, "description": "Force tries should be avoided." }, { "patternId": "force_unwrapping", "title": "Force Unwrapping", - "timeToFix": 5, "description": "Force unwrapping should be avoided." }, { "patternId": "function_body_length", "title": "Function Body Length", - "timeToFix": 5, "description": "Functions bodies should not span too many lines." }, + { + "patternId": "function_default_parameter_at_end", + "title": "Function Default Parameter at End", + "description": "Prefer to locate parameters with defaults toward the end of the parameter list." + }, { "patternId": "function_parameter_count", "title": "Function Parameter Count", - "timeToFix": 5, "description": "Number of function parameters should be low." }, { "patternId": "generic_type_name", "title": "Generic Type Name", - "timeToFix": 5, "description": "Generic type name should only contain alphanumeric characters, start with an uppercase character and span between 1 and 20 characters in length." }, + { + "patternId": "identical_operands", + "title": "Identical Operands", + "description": "Comparing two identical operands is likely a mistake." + }, { "patternId": "identifier_name", "title": "Identifier Name", - "timeToFix": 5, "description": "Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared static and immutable. Variable names should not be too long or too short." }, { "patternId": "implicit_getter", "title": "Implicit Getter", - "timeToFix": 5, - "description": "Computed read-only properties should avoid using the get keyword." + "description": "Computed read-only properties and subscripts should avoid using the get keyword." }, { "patternId": "implicit_return", "title": "Implicit Return", - "timeToFix": 5, - "description": "Prefer implicit returns in closures." + "description": "Prefer implicit returns in closures, functions and getters." }, { "patternId": "implicitly_unwrapped_optional", "title": "Implicitly Unwrapped Optional", - "timeToFix": 5, "description": "Implicitly unwrapped optionals should be avoided when possible." }, + { + "patternId": "indentation_width", + "title": "Indentation Width", + "description": "Indent code using either one tab or the configured amount of spaces, unindent to match previous indentations. Don't indent the first line." + }, + { + "patternId": "inert_defer", + "title": "Inert Defer", + "description": "If defer is at the end of its parent scope, it will be executed right where it is anyway." + }, + { + "patternId": "is_disjoint", + "title": "Is Disjoint", + "description": "Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty`." + }, + { + "patternId": "joined_default_parameter", + "title": "Joined Default Parameter", + "description": "Discouraged explicit usage of the default separator." + }, { "patternId": "large_tuple", "title": "Large Tuple", - "timeToFix": 5, "description": "Tuples shouldn't have too many members. Create a custom type instead." }, + { + "patternId": "last_where", + "title": "Last Where", + "description": "Prefer using `.last(where:)` over `.filter { }.last` in collections." + }, { "patternId": "leading_whitespace", "title": "Leading Whitespace", - "timeToFix": 5, "description": "Files should not contain leading whitespace." }, { "patternId": "legacy_cggeometry_functions", "title": "Legacy CGGeometry Functions", - "timeToFix": 5, "description": "Struct extension properties and methods are preferred over legacy functions" }, { "patternId": "legacy_constant", "title": "Legacy Constant", - "timeToFix": 5, "description": "Struct-scoped constants are preferred over legacy global constants." }, { "patternId": "legacy_constructor", "title": "Legacy Constructor", - "timeToFix": 5, "description": "Swift constructors are preferred over legacy convenience functions." }, + { + "patternId": "legacy_hashing", + "title": "Legacy Hashing", + "description": "Prefer using the `hash(into:)` function instead of overriding `hashValue`" + }, + { + "patternId": "legacy_multiple", + "title": "Legacy Multiple", + "description": "Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`)." + }, { "patternId": "legacy_nsgeometry_functions", "title": "Legacy NSGeometry Functions", - "timeToFix": 5, "description": "Struct extension properties and methods are preferred over legacy functions" }, + { + "patternId": "legacy_random", + "title": "Legacy Random", + "description": "Prefer using `type.random(in:)` over legacy functions." + }, + { + "patternId": "let_var_whitespace", + "title": "Variable Declaration Whitespace", + "description": "Let and var should be separated from other statements by a blank line." + }, { "patternId": "line_length", "title": "Line Length", - "timeToFix": 5, "description": "Lines should not span too many characters." }, + { + "patternId": "literal_expression_end_indentation", + "title": "Literal Expression End Indentation", + "description": "Array and dictionary literal end should have the same indentation as the line that started it." + }, + { + "patternId": "lower_acl_than_parent", + "title": "Lower ACL than parent", + "description": "Ensure definitions have a lower access control level than their enclosing parent" + }, { "patternId": "mark", "title": "Mark", - "timeToFix": 5, "description": "MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...'" }, + { + "patternId": "missing_docs", + "title": "Missing Docs", + "description": "Declarations should be documented." + }, + { + "patternId": "modifier_order", + "title": "Modifier Order", + "description": "Modifier order should be consistent." + }, + { + "patternId": "multiline_arguments", + "title": "Multiline Arguments", + "description": "Arguments should be either on the same line, or one per line." + }, + { + "patternId": "multiline_arguments_brackets", + "title": "Multiline Arguments Brackets", + "description": "Multiline arguments should have their surrounding brackets in a new line." + }, + { + "patternId": "multiline_function_chains", + "title": "Multiline Function Chains", + "description": "Chained function calls should be either on the same line, or one per line." + }, + { + "patternId": "multiline_literal_brackets", + "title": "Multiline Literal Brackets", + "description": "Multiline literals should have their surrounding brackets in a new line." + }, { "patternId": "multiline_parameters", "title": "Multiline Parameters", - "timeToFix": 5, "description": "Functions and methods parameters should be either on the same line, or one per line." }, + { + "patternId": "multiline_parameters_brackets", + "title": "Multiline Parameters Brackets", + "description": "Multiline parameters should have their surrounding brackets in a new line." + }, + { + "patternId": "multiple_closures_with_trailing_closure", + "title": "Multiple Closures with Trailing Closure", + "description": "Trailing closure syntax should not be used when passing more than one closure argument." + }, { "patternId": "nesting", "title": "Nesting", - "timeToFix": 5, "description": "Types should be nested at most 1 level deep, and statements should be nested at most 5 levels deep." }, { "patternId": "nimble_operator", "title": "Nimble Operator", - "timeToFix": 5, "description": "Prefer Nimble operator overloads over free matcher functions." }, { "patternId": "no_extension_access_modifier", "title": "No Extension Access Modifier", - "timeToFix": 5, "description": "Prefer not to use extension access modifiers" }, + { + "patternId": "no_fallthrough_only", + "title": "No Fallthrough Only", + "description": "Fallthroughs can only be used if the `case` contains at least one other statement." + }, + { + "patternId": "no_grouping_extension", + "title": "No Grouping Extension", + "description": "Extensions shouldn't be used to group code within the same source file." + }, + { + "patternId": "no_space_in_method_call", + "title": "No Space in Method Call", + "description": "Don't add a space between the method name and the parentheses." + }, { "patternId": "notification_center_detachment", "title": "Notification Center Detachment", - "timeToFix": 5, - "description": "An object should only remove itself as an observer in deinit." + "description": "An object should only remove itself as an observer in `deinit`." + }, + { + "patternId": "nslocalizedstring_key", + "title": "NSLocalizedString Key", + "description": "Static strings should be used as key in NSLocalizedString in order to genstrings work." + }, + { + "patternId": "nslocalizedstring_require_bundle", + "title": "NSLocalizedString Require Bundle", + "description": "Calls to NSLocalizedString should specify the bundle which contains the strings file." + }, + { + "patternId": "nsobject_prefer_isequal", + "title": "NSObject Prefer isEqual", + "description": "NSObject subclasses should implement isEqual instead of ==." }, { "patternId": "number_separator", "title": "Number Separator", - "timeToFix": 5, "description": "Underscores should be used as thousand separator in large decimal numbers." }, { "patternId": "object_literal", "title": "Object Literal", - "timeToFix": 5, "description": "Prefer object literals over image and color inits." }, { "patternId": "opening_brace", "title": "Opening Brace Spacing", - "timeToFix": 5, "description": "Opening braces should be preceded by a single space and on the same line as the declaration." }, { "patternId": "operator_usage_whitespace", "title": "Operator Usage Whitespace", - "timeToFix": 5, "description": "Operators should be surrounded by a single whitespace when they are being used." }, { "patternId": "operator_whitespace", "title": "Operator Function Whitespace", - "timeToFix": 5, "description": "Operators should be surrounded by a single whitespace when defining them." }, + { + "patternId": "optional_enum_case_matching", + "title": "Optional Enum Case Match", + "description": "Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above." + }, + { + "patternId": "orphaned_doc_comment", + "title": "Orphaned Doc Comment", + "description": "A doc comment should be attached to a declaration." + }, { "patternId": "overridden_super_call", "title": "Overridden methods call super", - "timeToFix": 5, "description": "Some overridden methods should always call super" }, + { + "patternId": "override_in_extension", + "title": "Override in Extension", + "description": "Extensions shouldn't override declarations." + }, + { + "patternId": "pattern_matching_keywords", + "title": "Pattern Matching Keywords", + "description": "Combine multiple pattern matching bindings by moving keywords out of tuples." + }, + { + "patternId": "prefer_self_type_over_type_of_self", + "title": "Prefer Self Type Over Type of Self", + "description": "Prefer `Self` over `type(of: self)` when accessing properties or calling methods." + }, + { + "patternId": "prefixed_toplevel_constant", + "title": "Prefixed Top-Level Constant", + "description": "Top-level constants should be prefixed by `k`." + }, + { + "patternId": "private_action", + "title": "Private Actions", + "description": "IBActions should be private." + }, { "patternId": "private_outlet", "title": "Private Outlets", - "timeToFix": 5, "description": "IBOutlets should be private to avoid leaking UIKit to higher layers." }, + { + "patternId": "private_over_fileprivate", + "title": "Private over fileprivate", + "description": "Prefer `private` over `fileprivate` declarations." + }, { "patternId": "private_unit_test", "title": "Private Unit Test", - "timeToFix": 5, "description": "Unit tests marked private are silently skipped." }, + { + "patternId": "prohibited_interface_builder", + "title": "Prohibited Interface Builder", + "description": "Creating views using Interface Builder should be avoided." + }, { "patternId": "prohibited_super_call", "title": "Prohibited calls to super", - "timeToFix": 5, "description": "Some methods should not call super" }, { "patternId": "protocol_property_accessors_order", "title": "Protocol Property Accessors Order", - "timeToFix": 5, - "description": "When declaring properties in protocols, the order of accessors should be get set." + "description": "When declaring properties in protocols, the order of accessors should be `get set`." + }, + { + "patternId": "quick_discouraged_call", + "title": "Quick Discouraged Call", + "description": "Discouraged call inside 'describe' and/or 'context' block." + }, + { + "patternId": "quick_discouraged_focused_test", + "title": "Quick Discouraged Focused Test", + "description": "Discouraged focused test. Other tests won't run while this one is focused." + }, + { + "patternId": "quick_discouraged_pending_test", + "title": "Quick Discouraged Pending Test", + "description": "Discouraged pending test. This test won't run while it's marked as pending." + }, + { + "patternId": "raw_value_for_camel_cased_codable_enum", + "title": "Raw Value For Camel Cased Codable Enum", + "description": "Camel cased cases of Codable String enums should have raw value." + }, + { + "patternId": "reduce_boolean", + "title": "Reduce Boolean", + "description": "Prefer using `.allSatisfy()` or `.contains()` over `reduce(true)` or `reduce(false)`" + }, + { + "patternId": "reduce_into", + "title": "Reduce Into", + "description": "Prefer `reduce(into:_:)` over `reduce(_:_:)` for copy-on-write types" }, { "patternId": "redundant_discardable_let", "title": "Redundant Discardable Let", - "timeToFix": 5, - "description": "Prefer _ = foo() over let _ = foo() when discarding a result from a function." + "description": "Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function." }, { "patternId": "redundant_nil_coalescing", "title": "Redundant Nil Coalescing", - "timeToFix": 5, "description": "nil coalescing operator is only evaluated if the lhs is nil, coalescing operator with nil as rhs is redundant" }, + { + "patternId": "redundant_objc_attribute", + "title": "Redundant @objc Attribute", + "description": "Objective-C attribute (@objc) is redundant in declaration." + }, { "patternId": "redundant_optional_initialization", "title": "Redundant Optional Initialization", - "timeToFix": 5, "description": "Initializing an optional variable with nil is redundant." }, + { + "patternId": "redundant_set_access_control", + "title": "Redundant Set Access Control Rule", + "description": "Property setter access level shouldn't be explicit if it's the same as the variable access level." + }, { "patternId": "redundant_string_enum_value", "title": "Redundant String Enum Value", - "timeToFix": 5, "description": "String enum values can be omitted when they are equal to the enumcase name." }, + { + "patternId": "redundant_type_annotation", + "title": "Redundant Type Annotation", + "description": "Variables should not have redundant type annotation" + }, { "patternId": "redundant_void_return", "title": "Redundant Void Return", - "timeToFix": 5, "description": "Returning Void in a function declaration is redundant." }, + { + "patternId": "required_deinit", + "title": "Required Deinit", + "description": "Classes should have an explicit deinit method." + }, + { + "patternId": "required_enum_case", + "title": "Required Enum Case", + "description": "Enums conforming to a specified protocol must implement a specific case(s)." + }, { "patternId": "return_arrow_whitespace", "title": "Returning Whitespace", - "timeToFix": 5, "description": "Return arrow and return type should be separated by a single space or on a separate line." }, { "patternId": "shorthand_operator", "title": "Shorthand Operator", - "timeToFix": 5, "description": "Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning." }, + { + "patternId": "single_test_class", + "title": "Single Test Class", + "description": "Test files should contain a single QuickSpec or XCTestCase class." + }, + { + "patternId": "sorted_first_last", + "title": "Min or Max over Sorted First or Last", + "description": "Prefer using `min()` or `max()` over `sorted().first` or `sorted().last`" + }, { "patternId": "sorted_imports", "title": "Sorted Imports", - "timeToFix": 5, "description": "Imports should be sorted." }, { "patternId": "statement_position", "title": "Statement Position", - "timeToFix": 5, "description": "Else and catch should be on the same line, one space after the previous declaration." }, + { + "patternId": "static_operator", + "title": "Static Operator", + "description": "Operators should be declared as static functions, not free functions." + }, + { + "patternId": "strict_fileprivate", + "title": "Strict fileprivate", + "description": "`fileprivate` should be avoided." + }, + { + "patternId": "strong_iboutlet", + "title": "Strong IBOutlet", + "description": "@IBOutlets shouldn't be declared as weak." + }, + { + "patternId": "superfluous_disable_command", + "title": "Superfluous Disable Command", + "description": "SwiftLint 'disable' commands are superfluous when the disabled rule would not have triggered a violation in the disabled region. Use \" - \" if you wish to document a command." + }, + { + "patternId": "switch_case_alignment", + "title": "Switch and Case Statement Alignment", + "description": "Case statements should vertically align with their enclosing switch statement, or indented if configured otherwise." + }, { "patternId": "switch_case_on_newline", "title": "Switch Case on Newline", - "timeToFix": 5, "description": "Cases inside a switch should always be on a newline" }, { "patternId": "syntactic_sugar", "title": "Syntactic Sugar", - "timeToFix": 5, - "description": "Shorthand syntactic sugar should be used, i.e. [Int] instead of Array" + "description": "Shorthand syntactic sugar should be used, i.e. [Int] instead of Array." }, { "patternId": "todo", "title": "Todo", - "timeToFix": 5, - "description": "TODOs and FIXMEs should be avoided." + "description": "TODOs and FIXMEs should be resolved." + }, + { + "patternId": "toggle_bool", + "title": "Toggle Bool", + "description": "Prefer `someBool.toggle()` over `someBool = !someBool`." + }, + { + "patternId": "trailing_closure", + "title": "Trailing Closure", + "description": "Trailing closure syntax should be used whenever possible." }, { "patternId": "trailing_comma", "title": "Trailing Comma", - "timeToFix": 5, "description": "Trailing commas in arrays and dictionaries should be avoided/enforced." }, { "patternId": "trailing_newline", "title": "Trailing Newline", - "timeToFix": 5, "description": "Files should have a single trailing newline." }, { "patternId": "trailing_semicolon", "title": "Trailing Semicolon", - "timeToFix": 5, "description": "Lines should not have trailing semicolons." }, { "patternId": "trailing_whitespace", "title": "Trailing Whitespace", - "timeToFix": 5, "description": "Lines should not have trailing whitespace." }, { "patternId": "type_body_length", "title": "Type Body Length", - "timeToFix": 5, "description": "Type bodies should not span too many lines." }, + { + "patternId": "type_contents_order", + "title": "Type Contents Order", + "description": "Specifies the order of subtypes, properties, methods & more within a type." + }, { "patternId": "type_name", "title": "Type Name", - "timeToFix": 5, "description": "Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 40 characters in length." }, { - "patternId": "unused_closure_parameter", - "title": "Unused Closure Parameter", - "timeToFix": 5, - "description": "Unused parameter in a closure should be replaced with _." - }, - { - "patternId": "unused_enumerated", - "title": "Unused Enumerated", - "timeToFix": 5, - "description": "When the index or the item is not used, .enumerated() can be removed." - }, - { - "patternId": "unused_optional_binding", - "title": "Unused Optional Binding", - "timeToFix": 5, - "description": "Prefer != nil over let _ =" - }, - { - "patternId": "valid_ibinspectable", - "title": "Valid IBInspectable", - "timeToFix": 5, - "description": "@IBInspectable should be applied to variables only, have its type explicit and be of a supported type" - }, - { - "patternId": "vertical_parameter_alignment", - "title": "Vertical Parameter Alignment", - "timeToFix": 5, - "description": "Function parameters should be aligned vertically if they're in multiple lines in a declaration." - }, - { - "patternId": "vertical_parameter_alignment_on_call", - "title": "Vertical Parameter Alignment On Call", - "timeToFix": 5, - "description": "Function parameters should be aligned vertically if they're in multiple lines in a method call." - }, - { - "patternId": "vertical_whitespace", - "title": "Vertical Whitespace", - "timeToFix": 5, - "description": "Limit vertical whitespace to a single empty line." - }, - { - "patternId": "void_return", - "title": "Void Return", - "timeToFix": 5, - "description": "Prefer -> Void over -> ()." - }, - { - "patternId": "weak_delegate", - "title": "Weak Delegate", - "timeToFix": 5, - "description": "Delegates should be weak to avoid reference cycles." - }, - { - "patternId": "array_init", - "title": "Array Init", - "timeToFix": 5, - "description": "Prefer using Array(seq) than seq.map { $0 } to convert a sequence into an Array." - }, - { - "patternId": "block_based_kvo", - "title": "Block Based KVO", - "timeToFix": 5, - "description": "Prefer the new block based KVO API with keypaths when using Swift 3.2 or later." - }, - { - "patternId": "contains_over_first_not_nil", - "title": "Contains over first not nil", - "timeToFix": 5, - "description": "Prefer 'contains' over 'first(where:) != nil'" - }, - { - "patternId": "discouraged_direct_init", - "title": "Discouraged Direct Initialization", - "timeToFix": 5, - "description": "Discouraged direct initialization of types that can be harmful." - }, - { - "patternId": "discouraged_object_literal", - "title": "Discouraged Object Literal", - "timeToFix": 5, - "description": "Prefer initializers over object literals." - }, - { - "patternId": "discouraged_optional_boolean", - "title": "Discouraged Optional Boolean", - "timeToFix": 5, - "description": "Prefer non-optional booleans over optional booleans." - }, - { - "patternId": "explicit_acl", - "title": "Explicit ACL", - "timeToFix": 5, - "description": "All declarations should specify Access Control Level keywords explicitly." - }, - { - "patternId": "explicit_enum_raw_value", - "title": "Explicit Enum Raw Value", - "timeToFix": 5, - "description": "Enums should be explicitly assigned their raw values." - }, - { - "patternId": "fallthrough", - "title": "Fallthrough", - "timeToFix": 5, - "description": "Fallthrough should be avoided." - }, - { - "patternId": "is_disjoint", - "title": "Is Disjoint", - "timeToFix": 5, - "description": "Prefer using 'Set.isDisjoint(with:)' over 'Set.intersection(_:).isEmpty'." - }, - { - "patternId": "joined_default_parameter", - "title": "Joined Default Parameter", - "timeToFix": 5, - "description": "Discouraged explicit usage of the default separator." + "patternId": "unavailable_function", + "title": "Unavailable Function", + "description": "Unimplemented functions should be marked as unavailable." }, { - "patternId": "let_var_whitespace", - "title": "Variable Declaration Whitespace", - "timeToFix": 5, - "description": "Let and var should be separated from other statements by a blank line." + "patternId": "unneeded_break_in_switch", + "title": "Unneeded Break in Switch", + "description": "Avoid using unneeded break statements." }, { - "patternId": "literal_expression_end_indentation", - "title": "Literal Expression End Indentation", - "timeToFix": 5, - "description": "Array and dictionary literal end should have the same indentation as the line that started it." + "patternId": "unneeded_parentheses_in_closure_argument", + "title": "Unneeded Parentheses in Closure Argument", + "description": "Parentheses are not needed when declaring closure arguments." }, { - "patternId": "multiline_arguments", - "title": "Multiline Arguments", - "timeToFix": 5, - "description": "Arguments should be either on the same line, or one per line." + "patternId": "unowned_variable_capture", + "title": "Unowned Variable Capture", + "description": "Prefer capturing references as weak to avoid potential crashes." }, { - "patternId": "multiple_closures_with_trailing_closure", - "title": "Multiple Closures with Trailing Closure", - "timeToFix": 5, - "description": "Trailing closure syntax should not be used when passing more than one closure argument." + "patternId": "untyped_error_in_catch", + "title": "Untyped Error in Catch", + "description": "Catch statements should not declare error variables without type casting." }, { - "patternId": "no_grouping_extension", - "title": "No Grouping Extension", - "timeToFix": 5, - "description": "Extensions shouldn't be used to group code within the same source file." + "patternId": "unused_capture_list", + "title": "Unused Capture List", + "description": "Unused reference in a capture list should be removed." }, { - "patternId": "override_in_extension", - "title": "Override in Extension", - "timeToFix": 5, - "description": "Extensions shouldn't override declarations." + "patternId": "unused_closure_parameter", + "title": "Unused Closure Parameter", + "description": "Unused parameter in a closure should be replaced with _." }, { - "patternId": "pattern_matching_keywords", - "title": "Pattern Matching Keywords", - "timeToFix": 5, - "description": "Combine multiple pattern matching bindings by moving keywords out of tuples." + "patternId": "unused_control_flow_label", + "title": "Unused Control Flow Label", + "description": "Unused control flow label should be removed." }, { - "patternId": "prefixed_toplevel_constant", - "title": "Prefixed Top-Level Constant", - "timeToFix": 5, - "description": "Top-level constants should be prefixed by 'k'." + "patternId": "unused_declaration", + "title": "Unused Declaration", + "description": "Declarations should be referenced at least once within all files linted." }, { - "patternId": "private_action", - "title": "Private Actions", - "timeToFix": 5, - "description": "IBActions should be private." + "patternId": "unused_enumerated", + "title": "Unused Enumerated", + "description": "When the index or the item is not used, `.enumerated()` can be removed." }, { - "patternId": "private_over_fileprivate", - "title": "Private over fileprivate", - "timeToFix": 5, - "description": "Prefer 'private' over 'fileprivate' declarations." + "patternId": "unused_import", + "title": "Unused Import", + "description": "All imported modules should be required to make the file compile." }, { - "patternId": "quick_discouraged_call", - "title": "Quick Discouraged Call", - "timeToFix": 5, - "description": "Discouraged call inside 'describe' and/or 'context' block." + "patternId": "unused_optional_binding", + "title": "Unused Optional Binding", + "description": "Prefer `!= nil` over `let _ =`" }, { - "patternId": "quick_discouraged_focused_test", - "title": "Quick Discouraged Focused Test", - "timeToFix": 5, - "description": "Discouraged focused test. Other tests won't run while this one is focused." + "patternId": "unused_setter_value", + "title": "Unused Setter Value", + "description": "Setter value is not used." }, { - "patternId": "quick_discouraged_pending_test", - "title": "Quick Discouraged Pending Test", - "timeToFix": 5, - "description": "Discouraged pending test. This test won't run while it's marked as pending." + "patternId": "valid_ibinspectable", + "title": "Valid IBInspectable", + "description": "@IBInspectable should be applied to variables only, have its type explicit and be of a supported type" }, { - "patternId": "required_enum_case", - "title": "Required Enum Case", - "timeToFix": 5, - "description": "Enums conforming to a specified protocol must implement a specific case(s)." + "patternId": "vertical_parameter_alignment", + "title": "Vertical Parameter Alignment", + "description": "Function parameters should be aligned vertically if they're in multiple lines in a declaration." }, { - "patternId": "single_test_class", - "title": "Single Test Class", - "timeToFix": 5, - "description": "Test files should contain a single QuickSpec or XCTestCase class." + "patternId": "vertical_parameter_alignment_on_call", + "title": "Vertical Parameter Alignment On Call", + "description": "Function parameters should be aligned vertically if they're in multiple lines in a method call." }, { - "patternId": "sorted_first_last", - "title": "Min or Max over Sorted First or Last", - "timeToFix": 5, - "description": "Prefer using 'min()' or 'max()' over 'sorted().first' or 'sorted().last'" + "patternId": "vertical_whitespace", + "title": "Vertical Whitespace", + "description": "Limit vertical whitespace to a single empty line." }, { - "patternId": "strict_fileprivate", - "title": "Strict fileprivate", - "timeToFix": 5, - "description": "'fileprivate' should be avoided." + "patternId": "vertical_whitespace_between_cases", + "title": "Vertical Whitespace Between Cases", + "description": "Include a single empty line between switch cases." }, { - "patternId": "superfluous_disable_command", - "title": "Superfluous Disable Command", - "timeToFix": 5, - "description": "SwiftLint 'disable' commands are superfluous when the disabled rule would not have triggered a violation in the disabled region." + "patternId": "vertical_whitespace_closing_braces", + "title": "Vertical Whitespace before Closing Braces", + "description": "Don't include vertical whitespace (empty line) before closing braces." }, { - "patternId": "switch_case_alignment", - "title": "Switch and Case Statement Alignment", - "timeToFix": 5, - "description": "Case statements should vertically align with the enclosing switch statement." + "patternId": "vertical_whitespace_opening_braces", + "title": "Vertical Whitespace after Opening Braces", + "description": "Don't include vertical whitespace (empty line) after opening braces." }, { - "patternId": "trailing_closure", - "title": "Trailing Closure", - "timeToFix": 5, - "description": "Trailing closure syntax should be used whenever possible." + "patternId": "void_return", + "title": "Void Return", + "description": "Prefer `-> Void` over `-> ()`." }, { - "patternId": "unneeded_break_in_switch", - "title": "Unneeded Break in Switch", - "timeToFix": 5, - "description": "Avoid using unneeded break statements." + "patternId": "weak_delegate", + "title": "Weak Delegate", + "description": "Delegates should be weak to avoid reference cycles." }, { - "patternId": "unneeded_parentheses_in_closure_argument", - "title": "Unneeded Parentheses in Closure Argument", - "timeToFix": 5, - "description": "Parentheses are not needed when declaring closure arguments." + "patternId": "xct_specific_matcher", + "title": "XCTest Specific Matcher", + "description": "Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual`" }, { "patternId": "xctfail_message", "title": "XCTFail Message", - "timeToFix": 5, "description": "An XCTFail call should include a description of the assertion." }, { "patternId": "yoda_condition", "title": "Yoda condition rule", - "timeToFix": 5, "description": "The variable should be placed on the left, the constant on the right of a comparison operator." } ] diff --git a/docs/description/discarded_notification_center_observer.md b/docs/description/discarded_notification_center_observer.md new file mode 100644 index 0000000..2b677db --- /dev/null +++ b/docs/description/discarded_notification_center_observer.md @@ -0,0 +1,79 @@ +# Discarded Notification Center Observer + +When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later. + +* **Identifier:** discarded_notification_center_observer +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let foo = nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { } + +``` + +```swift +let foo = nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { }) +``` + +```swift +func foo() -> Any { + return nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { }) +} + +``` + +```swift +var obs: [Any?] = [] +obs.append(nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { })) + +``` + +```swift +var obs: [String: Any?] = [] +obs["foo"] = nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { }) +``` + +```swift +var obs: [Any?] = [] +obs.append(nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { })) + +``` + +```swift +func foo(_ notif: Any) { + obs.append(notif) +} +foo(nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { })) + +``` + +```swift +var obs: [NSObjectProtocol] = [ + nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { }), + nc.addObserver(forName: .CKAccountChanged, object: nil, queue: nil, using: { }) +] +``` + +## Triggering Examples + +```swift +↓nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { } + +``` + +```swift +↓nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { }) + +``` + +```swift +@discardableResult func foo() -> Any { + return ↓nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { }) +} +``` \ No newline at end of file diff --git a/docs/description/discouraged_direct_init.md b/docs/description/discouraged_direct_init.md new file mode 100644 index 0000000..3a59ac8 --- /dev/null +++ b/docs/description/discouraged_direct_init.md @@ -0,0 +1,79 @@ +# Discouraged Direct Initialization + +Discouraged direct initialization of types that can be harmful. + +* **Identifier:** discouraged_direct_init +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, types: ["Bundle", "Bundle.init", "UIDevice", "UIDevice.init"] + +## Non Triggering Examples + +```swift +let foo = UIDevice.current +``` + +```swift +let foo = Bundle.main +``` + +```swift +let foo = Bundle(path: "bar") +``` + +```swift +let foo = Bundle(identifier: "bar") +``` + +```swift +let foo = Bundle.init(path: "bar") +``` + +```swift +let foo = Bundle.init(identifier: "bar") +``` + +## Triggering Examples + +```swift +↓UIDevice() +``` + +```swift +↓Bundle() +``` + +```swift +let foo = ↓UIDevice() +``` + +```swift +let foo = ↓Bundle() +``` + +```swift +let foo = bar(bundle: ↓Bundle(), device: ↓UIDevice()) +``` + +```swift +↓UIDevice.init() +``` + +```swift +↓Bundle.init() +``` + +```swift +let foo = ↓UIDevice.init() +``` + +```swift +let foo = ↓Bundle.init() +``` + +```swift +let foo = bar(bundle: ↓Bundle.init(), device: ↓UIDevice.init()) +``` \ No newline at end of file diff --git a/docs/description/discouraged_object_literal.md b/docs/description/discouraged_object_literal.md new file mode 100644 index 0000000..708a48b --- /dev/null +++ b/docs/description/discouraged_object_literal.md @@ -0,0 +1,47 @@ +# Discouraged Object Literal + +Prefer initializers over object literals. + +* **Identifier:** discouraged_object_literal +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, image_literal: true, color_literal: true + +## Non Triggering Examples + +```swift +let image = UIImage(named: aVariable) +``` + +```swift +let image = UIImage(named: "interpolated \(variable)") +``` + +```swift +let color = UIColor(red: value, green: value, blue: value, alpha: 1) +``` + +```swift +let image = NSImage(named: aVariable) +``` + +```swift +let image = NSImage(named: "interpolated \(variable)") +``` + +```swift +let color = NSColor(red: value, green: value, blue: value, alpha: 1) +``` + +## Triggering Examples + +```swift +let image = ↓#imageLiteral(resourceName: "image.jpg") +``` + +```swift +let color = ↓#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1) +``` \ No newline at end of file diff --git a/docs/description/discouraged_optional_boolean.md b/docs/description/discouraged_optional_boolean.md new file mode 100644 index 0000000..de9c2dc --- /dev/null +++ b/docs/description/discouraged_optional_boolean.md @@ -0,0 +1,627 @@ +# Discouraged Optional Boolean + +Prefer non-optional booleans over optional booleans. + +* **Identifier:** discouraged_optional_boolean +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +var foo: Bool +``` + +```swift +var foo: [String: Bool] +``` + +```swift +var foo: [Bool] +``` + +```swift +let foo: Bool = true +``` + +```swift +let foo: Bool = false +``` + +```swift +let foo: [String: Bool] = [:] +``` + +```swift +let foo: [Bool] = [] +``` + +```swift +var foo: Bool { return true } +``` + +```swift +let foo: Bool { return false }() +``` + +```swift +func foo() -> Bool {} +``` + +```swift +func foo() -> [String: Bool] {} +``` + +```swift +func foo() -> ([Bool]) -> String {} +``` + +```swift +func foo(input: Bool = true) {} +``` + +```swift +func foo(input: [String: Bool] = [:]) {} +``` + +```swift +func foo(input: [Bool] = []) {} +``` + +```swift +class Foo { + func foo() -> Bool {} +} +``` + +```swift +class Foo { + func foo() -> [String: Bool] {} +} +``` + +```swift +class Foo { + func foo() -> ([Bool]) -> String {} +} +``` + +```swift +struct Foo { + func foo() -> Bool {} +} +``` + +```swift +struct Foo { + func foo() -> [String: Bool] {} +} +``` + +```swift +struct Foo { + func foo() -> ([Bool]) -> String {} +} +``` + +```swift +enum Foo { + func foo() -> Bool {} +} +``` + +```swift +enum Foo { + func foo() -> [String: Bool] {} +} +``` + +```swift +enum Foo { + func foo() -> ([Bool]) -> String {} +} +``` + +```swift +class Foo { + func foo(input: Bool = true) {} +} +``` + +```swift +class Foo { + func foo(input: [String: Bool] = [:]) {} +} +``` + +```swift +class Foo { + func foo(input: [Bool] = []) {} +} +``` + +```swift +struct Foo { + func foo(input: Bool = true) {} +} +``` + +```swift +struct Foo { + func foo(input: [String: Bool] = [:]) {} +} +``` + +```swift +struct Foo { + func foo(input: [Bool] = []) {} +} +``` + +```swift +enum Foo { + func foo(input: Bool = true) {} +} +``` + +```swift +enum Foo { + func foo(input: [String: Bool] = [:]) {} +} +``` + +```swift +enum Foo { + func foo(input: [Bool] = []) {} +} +``` + +## Triggering Examples + +```swift +var foo: ↓Bool? +``` + +```swift +var foo: [String: ↓Bool?] +``` + +```swift +var foo: [↓Bool?] +``` + +```swift +let foo: ↓Bool? = nil +``` + +```swift +let foo: [String: ↓Bool?] = [:] +``` + +```swift +let foo: [↓Bool?] = [] +``` + +```swift +let foo = ↓Optional.some(false) +``` + +```swift +let foo = ↓Optional.some(true) +``` + +```swift +var foo: ↓Bool? { return nil } +``` + +```swift +let foo: ↓Bool? { return nil }() +``` + +```swift +func foo() -> ↓Bool? {} +``` + +```swift +func foo() -> [String: ↓Bool?] {} +``` + +```swift +func foo() -> [↓Bool?] {} +``` + +```swift +static func foo() -> ↓Bool? {} +``` + +```swift +static func foo() -> [String: ↓Bool?] {} +``` + +```swift +static func foo() -> [↓Bool?] {} +``` + +```swift +func foo() -> (↓Bool?) -> String {} +``` + +```swift +func foo() -> ([Int]) -> ↓Bool? {} +``` + +```swift +func foo(input: ↓Bool?) {} +``` + +```swift +func foo(input: [String: ↓Bool?]) {} +``` + +```swift +func foo(input: [↓Bool?]) {} +``` + +```swift +static func foo(input: ↓Bool?) {} +``` + +```swift +static func foo(input: [String: ↓Bool?]) {} +``` + +```swift +static func foo(input: [↓Bool?]) {} +``` + +```swift +class Foo { + var foo: ↓Bool? +} +``` + +```swift +class Foo { + var foo: [String: ↓Bool?] +} +``` + +```swift +class Foo { + let foo: ↓Bool? = nil +} +``` + +```swift +class Foo { + let foo: [String: ↓Bool?] = [:] +} +``` + +```swift +class Foo { + let foo: [↓Bool?] = [] +} +``` + +```swift +struct Foo { + var foo: ↓Bool? +} +``` + +```swift +struct Foo { + var foo: [String: ↓Bool?] +} +``` + +```swift +struct Foo { + let foo: ↓Bool? = nil +} +``` + +```swift +struct Foo { + let foo: [String: ↓Bool?] = [:] +} +``` + +```swift +struct Foo { + let foo: [↓Bool?] = [] +} +``` + +```swift +class Foo { + var foo: ↓Bool? { return nil } +} +``` + +```swift +class Foo { + let foo: ↓Bool? { return nil }() +} +``` + +```swift +struct Foo { + var foo: ↓Bool? { return nil } +} +``` + +```swift +struct Foo { + let foo: ↓Bool? { return nil }() +} +``` + +```swift +enum Foo { + var foo: ↓Bool? { return nil } +} +``` + +```swift +enum Foo { + let foo: ↓Bool? { return nil }() +} +``` + +```swift +class Foo { + func foo() -> ↓Bool? {} +} +``` + +```swift +class Foo { + func foo() -> [String: ↓Bool?] {} +} +``` + +```swift +class Foo { + func foo() -> [↓Bool?] {} +} +``` + +```swift +class Foo { + static func foo() -> ↓Bool? {} +} +``` + +```swift +class Foo { + static func foo() -> [String: ↓Bool?] {} +} +``` + +```swift +class Foo { + static func foo() -> [↓Bool?] {} +} +``` + +```swift +class Foo { + func foo() -> (↓Bool?) -> String {} +} +``` + +```swift +class Foo { + func foo() -> ([Int]) -> ↓Bool? {} +} +``` + +```swift +struct Foo { + func foo() -> ↓Bool? {} +} +``` + +```swift +struct Foo { + func foo() -> [String: ↓Bool?] {} +} +``` + +```swift +struct Foo { + func foo() -> [↓Bool?] {} +} +``` + +```swift +struct Foo { + static func foo() -> ↓Bool? {} +} +``` + +```swift +struct Foo { + static func foo() -> [String: ↓Bool?] {} +} +``` + +```swift +struct Foo { + static func foo() -> [↓Bool?] {} +} +``` + +```swift +struct Foo { + func foo() -> (↓Bool?) -> String {} +} +``` + +```swift +struct Foo { + func foo() -> ([Int]) -> ↓Bool? {} +} +``` + +```swift +enum Foo { + func foo() -> ↓Bool? {} +} +``` + +```swift +enum Foo { + func foo() -> [String: ↓Bool?] {} +} +``` + +```swift +enum Foo { + func foo() -> [↓Bool?] {} +} +``` + +```swift +enum Foo { + static func foo() -> ↓Bool? {} +} +``` + +```swift +enum Foo { + static func foo() -> [String: ↓Bool?] {} +} +``` + +```swift +enum Foo { + static func foo() -> [↓Bool?] {} +} +``` + +```swift +enum Foo { + func foo() -> (↓Bool?) -> String {} +} +``` + +```swift +enum Foo { + func foo() -> ([Int]) -> ↓Bool? {} +} +``` + +```swift +class Foo { + func foo(input: ↓Bool?) {} +} +``` + +```swift +class Foo { + func foo(input: [String: ↓Bool?]) {} +} +``` + +```swift +class Foo { + func foo(input: [↓Bool?]) {} +} +``` + +```swift +class Foo { + static func foo(input: ↓Bool?) {} +} +``` + +```swift +class Foo { + static func foo(input: [String: ↓Bool?]) {} +} +``` + +```swift +class Foo { + static func foo(input: [↓Bool?]) {} +} +``` + +```swift +struct Foo { + func foo(input: ↓Bool?) {} +} +``` + +```swift +struct Foo { + func foo(input: [String: ↓Bool?]) {} +} +``` + +```swift +struct Foo { + func foo(input: [↓Bool?]) {} +} +``` + +```swift +struct Foo { + static func foo(input: ↓Bool?) {} +} +``` + +```swift +struct Foo { + static func foo(input: [String: ↓Bool?]) {} +} +``` + +```swift +struct Foo { + static func foo(input: [↓Bool?]) {} +} +``` + +```swift +enum Foo { + func foo(input: ↓Bool?) {} +} +``` + +```swift +enum Foo { + func foo(input: [String: ↓Bool?]) {} +} +``` + +```swift +enum Foo { + func foo(input: [↓Bool?]) {} +} +``` + +```swift +enum Foo { + static func foo(input: ↓Bool?) {} +} +``` + +```swift +enum Foo { + static func foo(input: [String: ↓Bool?]) {} +} +``` + +```swift +enum Foo { + static func foo(input: [↓Bool?]) {} +} +``` \ No newline at end of file diff --git a/docs/description/discouraged_optional_collection.md b/docs/description/discouraged_optional_collection.md new file mode 100644 index 0000000..1f8a9c2 --- /dev/null +++ b/docs/description/discouraged_optional_collection.md @@ -0,0 +1,909 @@ +# Discouraged Optional Collection + +Prefer empty collection over optional collection. + +* **Identifier:** discouraged_optional_collection +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +var foo: [Int] +``` + +```swift +var foo: [String: Int] +``` + +```swift +var foo: Set +``` + +```swift +var foo: [String: [String: Int]] +``` + +```swift +let foo: [Int] = [] +``` + +```swift +let foo: [String: Int] = [:] +``` + +```swift +let foo: Set = [] +``` + +```swift +let foo: [String: [String: Int]] = [:] +``` + +```swift +var foo: [Int] { return [] } +``` + +```swift +func foo() -> [Int] {} +``` + +```swift +func foo() -> [String: String] {} +``` + +```swift +func foo() -> Set {} +``` + +```swift +func foo() -> ([Int]) -> String {} +``` + +```swift +func foo(input: [String] = []) {} +``` + +```swift +func foo(input: [String: String] = [:]) {} +``` + +```swift +func foo(input: Set = []) {} +``` + +```swift +class Foo { + func foo() -> [Int] {} +} +``` + +```swift +class Foo { + func foo() -> [String: String] {} +} +``` + +```swift +class Foo { + func foo() -> Set {} +} +``` + +```swift +class Foo { + func foo() -> ([Int]) -> String {} +} +``` + +```swift +struct Foo { + func foo() -> [Int] {} +} +``` + +```swift +struct Foo { + func foo() -> [String: String] {} +} +``` + +```swift +struct Foo { + func foo() -> Set {} +} +``` + +```swift +struct Foo { + func foo() -> ([Int]) -> String {} +} +``` + +```swift +enum Foo { + func foo() -> [Int] {} +} +``` + +```swift +enum Foo { + func foo() -> [String: String] {} +} +``` + +```swift +enum Foo { + func foo() -> Set {} +} +``` + +```swift +enum Foo { + func foo() -> ([Int]) -> String {} +} +``` + +```swift +class Foo { + func foo(input: [String] = []) {} +} +``` + +```swift +class Foo { + func foo(input: [String: String] = [:]) {} +} +``` + +```swift +class Foo { + func foo(input: Set = []) {} +} +``` + +```swift +struct Foo { + func foo(input: [String] = []) {} +} +``` + +```swift +struct Foo { + func foo(input: [String: String] = [:]) {} +} +``` + +```swift +struct Foo { + func foo(input: Set = []) {} +} +``` + +```swift +enum Foo { + func foo(input: [String] = []) {} +} +``` + +```swift +enum Foo { + func foo(input: [String: String] = [:]) {} +} +``` + +```swift +enum Foo { + func foo(input: Set = []) {} +} +``` + +## Triggering Examples + +```swift +↓var foo: [Int]? +``` + +```swift +↓var foo: [String: Int]? +``` + +```swift +↓var foo: Set? +``` + +```swift +↓let foo: [Int]? = nil +``` + +```swift +↓let foo: [String: Int]? = nil +``` + +```swift +↓let foo: Set? = nil +``` + +```swift +↓var foo: [Int]? { return nil } +``` + +```swift +↓let foo: [Int]? { return nil }() +``` + +```swift +func ↓foo() -> [T]? {} +``` + +```swift +func ↓foo() -> [String: String]? {} +``` + +```swift +func ↓foo() -> [String: [String: String]]? {} +``` + +```swift +func ↓foo() -> [String: [String: String]?] {} +``` + +```swift +func ↓foo() -> Set? {} +``` + +```swift +static func ↓foo() -> [T]? {} +``` + +```swift +static func ↓foo() -> [String: String]? {} +``` + +```swift +static func ↓foo() -> [String: [String: String]]? {} +``` + +```swift +static func ↓foo() -> [String: [String: String]?] {} +``` + +```swift +static func ↓foo() -> Set? {} +``` + +```swift +func ↓foo() -> ([Int]?) -> String {} +``` + +```swift +func ↓foo() -> ([Int]) -> [String]? {} +``` + +```swift +func foo(↓input: [String: String]?) {} +``` + +```swift +func foo(↓input: [String: [String: String]]?) {} +``` + +```swift +func foo(↓input: [String: [String: String]?]) {} +``` + +```swift +func foo(↓↓input: [String: [String: String]?]?) {} +``` + +```swift +func foo(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V] +``` + +```swift +func foo(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V] +``` + +```swift +static func foo(↓input: [String: String]?) {} +``` + +```swift +static func foo(↓input: [String: [String: String]]?) {} +``` + +```swift +static func foo(↓input: [String: [String: String]?]) {} +``` + +```swift +static func foo(↓↓input: [String: [String: String]?]?) {} +``` + +```swift +static func foo(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V] +``` + +```swift +static func foo(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V] +``` + +```swift +class Foo { + ↓var foo: [Int]? +} +``` + +```swift +class Foo { + ↓var foo: [String: Int]? +} +``` + +```swift +class Foo { + ↓var foo: Set? +} +``` + +```swift +class Foo { + ↓let foo: [Int]? = nil +} +``` + +```swift +class Foo { + ↓let foo: [String: Int]? = nil +} +``` + +```swift +class Foo { + ↓let foo: Set? = nil +} +``` + +```swift +struct Foo { + ↓var foo: [Int]? +} +``` + +```swift +struct Foo { + ↓var foo: [String: Int]? +} +``` + +```swift +struct Foo { + ↓var foo: Set? +} +``` + +```swift +struct Foo { + ↓let foo: [Int]? = nil +} +``` + +```swift +struct Foo { + ↓let foo: [String: Int]? = nil +} +``` + +```swift +struct Foo { + ↓let foo: Set? = nil +} +``` + +```swift +class Foo { + ↓var foo: [Int]? { return nil } +} +``` + +```swift +class Foo { + ↓let foo: [Int]? { return nil }() +} +``` + +```swift +class Foo { + ↓var foo: Set? { return nil } +} +``` + +```swift +class Foo { + ↓let foo: Set? { return nil }() +} +``` + +```swift +struct Foo { + ↓var foo: [Int]? { return nil } +} +``` + +```swift +struct Foo { + ↓let foo: [Int]? { return nil }() +} +``` + +```swift +struct Foo { + ↓var foo: Set? { return nil } +} +``` + +```swift +struct Foo { + ↓let foo: Set? { return nil }() +} +``` + +```swift +enum Foo { + ↓var foo: [Int]? { return nil } +} +``` + +```swift +enum Foo { + ↓let foo: [Int]? { return nil }() +} +``` + +```swift +enum Foo { + ↓var foo: Set? { return nil } +} +``` + +```swift +enum Foo { + ↓let foo: Set? { return nil }() +} +``` + +```swift +class Foo { + func ↓foo() -> [T]? {} +} +``` + +```swift +class Foo { + func ↓foo() -> [String: String]? {} +} +``` + +```swift +class Foo { + func ↓foo() -> [String: [String: String]]? {} +} +``` + +```swift +class Foo { + func ↓foo() -> [String: [String: String]?] {} +} +``` + +```swift +class Foo { + func ↓foo() -> Set? {} +} +``` + +```swift +class Foo { + static func ↓foo() -> [T]? {} +} +``` + +```swift +class Foo { + static func ↓foo() -> [String: String]? {} +} +``` + +```swift +class Foo { + static func ↓foo() -> [String: [String: String]]? {} +} +``` + +```swift +class Foo { + static func ↓foo() -> [String: [String: String]?] {} +} +``` + +```swift +class Foo { + static func ↓foo() -> Set? {} +} +``` + +```swift +class Foo { + func ↓foo() -> ([Int]?) -> String {} +} +``` + +```swift +class Foo { + func ↓foo() -> ([Int]) -> [String]? {} +} +``` + +```swift +struct Foo { + func ↓foo() -> [T]? {} +} +``` + +```swift +struct Foo { + func ↓foo() -> [String: String]? {} +} +``` + +```swift +struct Foo { + func ↓foo() -> [String: [String: String]]? {} +} +``` + +```swift +struct Foo { + func ↓foo() -> [String: [String: String]?] {} +} +``` + +```swift +struct Foo { + func ↓foo() -> Set? {} +} +``` + +```swift +struct Foo { + static func ↓foo() -> [T]? {} +} +``` + +```swift +struct Foo { + static func ↓foo() -> [String: String]? {} +} +``` + +```swift +struct Foo { + static func ↓foo() -> [String: [String: String]]? {} +} +``` + +```swift +struct Foo { + static func ↓foo() -> [String: [String: String]?] {} +} +``` + +```swift +struct Foo { + static func ↓foo() -> Set? {} +} +``` + +```swift +struct Foo { + func ↓foo() -> ([Int]?) -> String {} +} +``` + +```swift +struct Foo { + func ↓foo() -> ([Int]) -> [String]? {} +} +``` + +```swift +enum Foo { + func ↓foo() -> [T]? {} +} +``` + +```swift +enum Foo { + func ↓foo() -> [String: String]? {} +} +``` + +```swift +enum Foo { + func ↓foo() -> [String: [String: String]]? {} +} +``` + +```swift +enum Foo { + func ↓foo() -> [String: [String: String]?] {} +} +``` + +```swift +enum Foo { + func ↓foo() -> Set? {} +} +``` + +```swift +enum Foo { + static func ↓foo() -> [T]? {} +} +``` + +```swift +enum Foo { + static func ↓foo() -> [String: String]? {} +} +``` + +```swift +enum Foo { + static func ↓foo() -> [String: [String: String]]? {} +} +``` + +```swift +enum Foo { + static func ↓foo() -> [String: [String: String]?] {} +} +``` + +```swift +enum Foo { + static func ↓foo() -> Set? {} +} +``` + +```swift +enum Foo { + func ↓foo() -> ([Int]?) -> String {} +} +``` + +```swift +enum Foo { + func ↓foo() -> ([Int]) -> [String]? {} +} +``` + +```swift +class Foo { + func foo(↓input: [String: String]?) {} +} +``` + +```swift +class Foo { + func foo(↓input: [String: [String: String]]?) {} +} +``` + +```swift +class Foo { + func foo(↓input: [String: [String: String]?]) {} +} +``` + +```swift +class Foo { + func foo(↓↓input: [String: [String: String]?]?) {} +} +``` + +```swift +class Foo { + func foo(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V] +} +``` + +```swift +class Foo { + func foo(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V] +} +``` + +```swift +class Foo { + static func foo(↓input: [String: String]?) {} +} +``` + +```swift +class Foo { + static func foo(↓input: [String: [String: String]]?) {} +} +``` + +```swift +class Foo { + static func foo(↓input: [String: [String: String]?]) {} +} +``` + +```swift +class Foo { + static func foo(↓↓input: [String: [String: String]?]?) {} +} +``` + +```swift +class Foo { + static func foo(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V] +} +``` + +```swift +class Foo { + static func foo(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V] +} +``` + +```swift +struct Foo { + func foo(↓input: [String: String]?) {} +} +``` + +```swift +struct Foo { + func foo(↓input: [String: [String: String]]?) {} +} +``` + +```swift +struct Foo { + func foo(↓input: [String: [String: String]?]) {} +} +``` + +```swift +struct Foo { + func foo(↓↓input: [String: [String: String]?]?) {} +} +``` + +```swift +struct Foo { + func foo(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V] +} +``` + +```swift +struct Foo { + func foo(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V] +} +``` + +```swift +struct Foo { + static func foo(↓input: [String: String]?) {} +} +``` + +```swift +struct Foo { + static func foo(↓input: [String: [String: String]]?) {} +} +``` + +```swift +struct Foo { + static func foo(↓input: [String: [String: String]?]) {} +} +``` + +```swift +struct Foo { + static func foo(↓↓input: [String: [String: String]?]?) {} +} +``` + +```swift +struct Foo { + static func foo(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V] +} +``` + +```swift +struct Foo { + static func foo(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V] +} +``` + +```swift +enum Foo { + func foo(↓input: [String: String]?) {} +} +``` + +```swift +enum Foo { + func foo(↓input: [String: [String: String]]?) {} +} +``` + +```swift +enum Foo { + func foo(↓input: [String: [String: String]?]) {} +} +``` + +```swift +enum Foo { + func foo(↓↓input: [String: [String: String]?]?) {} +} +``` + +```swift +enum Foo { + func foo(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V] +} +``` + +```swift +enum Foo { + func foo(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V] +} +``` + +```swift +enum Foo { + static func foo(↓input: [String: String]?) {} +} +``` + +```swift +enum Foo { + static func foo(↓input: [String: [String: String]]?) {} +} +``` + +```swift +enum Foo { + static func foo(↓input: [String: [String: String]?]) {} +} +``` + +```swift +enum Foo { + static func foo(↓↓input: [String: [String: String]?]?) {} +} +``` + +```swift +enum Foo { + static func foo(_ dict1: [K: V], ↓_ dict2: [K: V]?) -> [K: V] +} +``` + +```swift +enum Foo { + static func foo(dict1: [K: V], ↓dict2: [K: V]?) -> [K: V] +} +``` \ No newline at end of file diff --git a/docs/description/duplicate_enum_cases.md b/docs/description/duplicate_enum_cases.md new file mode 100644 index 0000000..4f8dd91 --- /dev/null +++ b/docs/description/duplicate_enum_cases.md @@ -0,0 +1,39 @@ +# Duplicate Enum Cases + +Enum can't contain multiple cases with the same name. + +* **Identifier:** duplicate_enum_cases +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** error + +## Non Triggering Examples + +```swift +enum PictureImport { + case addImage(image: UIImage) + case addData(data: Data) +} +``` + +```swift +enum A { + case add(image: UIImage) +} +enum B { + case add(image: UIImage) +} +``` + +## Triggering Examples + +```swift +enum PictureImport { + case ↓add(image: UIImage) + case addURL(url: URL) + case ↓add(data: Data) +} +``` \ No newline at end of file diff --git a/docs/description/duplicate_imports.md b/docs/description/duplicate_imports.md new file mode 100644 index 0000000..9fe9228 --- /dev/null +++ b/docs/description/duplicate_imports.md @@ -0,0 +1,201 @@ +# Duplicate Imports + +Imports should be unique. + +* **Identifier:** duplicate_imports +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +import A +import B +import C +``` + +```swift +import A.B +import A.C +``` + +```swift +#if DEBUG + @testable import KsApi +#else + import KsApi +#endif +``` + +```swift +import A // module +import B // module +``` + +```swift +#if TEST +func test() { +} +``` + +## Triggering Examples + +```swift +import Foundation +import Dispatch +↓import Foundation +``` + +```swift +import Foundation +↓import Foundation.NSString +``` + +```swift +↓import Foundation.NSString +import Foundation +``` + +```swift +↓import A.B.C +import A.B +``` + +```swift +import A.B +↓import A.B.C +``` + +```swift +import A +#if DEBUG + @testable import KsApi +#else + import KsApi +#endif +↓import A +``` + +```swift +import A +↓import typealias A.Foo +``` + +```swift +import A +↓import struct A.Foo +``` + +```swift +import A +↓import class A.Foo +``` + +```swift +import A +↓import enum A.Foo +``` + +```swift +import A +↓import protocol A.Foo +``` + +```swift +import A +↓import let A.Foo +``` + +```swift +import A +↓import var A.Foo +``` + +```swift +import A +↓import func A.Foo +``` + +```swift +import A +↓import typealias A.B.Foo +``` + +```swift +import A +↓import struct A.B.Foo +``` + +```swift +import A +↓import class A.B.Foo +``` + +```swift +import A +↓import enum A.B.Foo +``` + +```swift +import A +↓import protocol A.B.Foo +``` + +```swift +import A +↓import let A.B.Foo +``` + +```swift +import A +↓import var A.B.Foo +``` + +```swift +import A +↓import func A.B.Foo +``` + +```swift +import A.B +↓import typealias A.B.Foo +``` + +```swift +import A.B +↓import struct A.B.Foo +``` + +```swift +import A.B +↓import class A.B.Foo +``` + +```swift +import A.B +↓import enum A.B.Foo +``` + +```swift +import A.B +↓import protocol A.B.Foo +``` + +```swift +import A.B +↓import let A.B.Foo +``` + +```swift +import A.B +↓import var A.B.Foo +``` + +```swift +import A.B +↓import func A.B.Foo +``` \ No newline at end of file diff --git a/docs/description/dynamic_inline.md b/docs/description/dynamic_inline.md new file mode 100644 index 0000000..644716f --- /dev/null +++ b/docs/description/dynamic_inline.md @@ -0,0 +1,63 @@ +# Dynamic Inline + +Avoid using 'dynamic' and '@inline(__always)' together. + +* **Identifier:** dynamic_inline +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** error + +## Non Triggering Examples + +```swift +class C { +dynamic func f() {}} +``` + +```swift +class C { +@inline(__always) func f() {}} +``` + +```swift +class C { +@inline(never) dynamic func f() {}} +``` + +## Triggering Examples + +```swift +class C { +@inline(__always) dynamic ↓func f() {} +} +``` + +```swift +class C { +@inline(__always) public dynamic ↓func f() {} +} +``` + +```swift +class C { +@inline(__always) dynamic internal ↓func f() {} +} +``` + +```swift +class C { +@inline(__always) +dynamic ↓func f() {} +} +``` + +```swift +class C { +@inline(__always) +dynamic +↓func f() {} +} +``` \ No newline at end of file diff --git a/docs/description/empty_collection_literal.md b/docs/description/empty_collection_literal.md new file mode 100644 index 0000000..99aa2b7 --- /dev/null +++ b/docs/description/empty_collection_literal.md @@ -0,0 +1,63 @@ +# Empty Collection Literal + +Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal. + +* **Identifier:** empty_collection_literal +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +myArray = [] +``` + +```swift +myArray.isEmpty +``` + +```swift +!myArray.isEmpty +``` + +```swift +myDict = [:] +``` + +## Triggering Examples + +```swift +myArray↓ == [] +``` + +```swift +myArray↓ != [] +``` + +```swift +myArray↓ == [ ] +``` + +```swift +myDict↓ == [:] +``` + +```swift +myDict↓ != [:] +``` + +```swift +myDict↓ == [: ] +``` + +```swift +myDict↓ == [ :] +``` + +```swift +myDict↓ == [ : ] +``` \ No newline at end of file diff --git a/docs/description/empty_count.md b/docs/description/empty_count.md new file mode 100644 index 0000000..c3d2380 --- /dev/null +++ b/docs/description/empty_count.md @@ -0,0 +1,100 @@ +# Empty Count + +Prefer checking `isEmpty` over comparing `count` to zero. + +* **Identifier:** empty_count +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** error, only_after_dot: false + +## Non Triggering Examples + +```swift +var count = 0 + +``` + +```swift +[Int]().isEmpty + +``` + +```swift +[Int]().count > 1 + +``` + +```swift +[Int]().count == 1 + +``` + +```swift +[Int]().count == 0xff + +``` + +```swift +[Int]().count == 0b01 + +``` + +```swift +[Int]().count == 0o07 + +``` + +```swift +discount == 0 + +``` + +```swift +order.discount == 0 + +``` + +## Triggering Examples + +```swift +[Int]().↓count == 0 + +``` + +```swift +[Int]().↓count > 0 + +``` + +```swift +[Int]().↓count != 0 + +``` + +```swift +[Int]().↓count == 0x0 + +``` + +```swift +[Int]().↓count == 0x00_00 + +``` + +```swift +[Int]().↓count == 0b00 + +``` + +```swift +[Int]().↓count == 0o00 + +``` + +```swift +↓count == 0 + +``` \ No newline at end of file diff --git a/docs/description/empty_enum_arguments.md b/docs/description/empty_enum_arguments.md new file mode 100644 index 0000000..d2c1034 --- /dev/null +++ b/docs/description/empty_enum_arguments.md @@ -0,0 +1,96 @@ +# Empty Enum Arguments + +Arguments can be omitted when matching enums with associated types if they are not used. + +* **Identifier:** empty_enum_arguments +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +switch foo { +case .bar: break +} +``` + +```swift +switch foo { +case .bar(let x): break +} +``` + +```swift +switch foo { +case let .bar(x): break +} +``` + +```swift +switch (foo, bar) { +case (_, _): break +} +``` + +```swift +switch foo { +case "bar".uppercased(): break +} +``` + +```swift +switch (foo, bar) { +case (_, _) where !something: break +} +``` + +```swift +switch foo { +case (let f as () -> String)?: break +} +``` + +```swift +switch foo { +default: break +} +``` + +## Triggering Examples + +```swift +switch foo { +case .bar↓(_): break +} +``` + +```swift +switch foo { +case .bar↓(): break +} +``` + +```swift +switch foo { +case .bar↓(_), .bar2↓(_): break +} +``` + +```swift +switch foo { +case .bar↓() where method() > 2: break +} +``` + +```swift +func example(foo: Foo) { + switch foo { + case case .bar↓(_): + break + } +} +``` \ No newline at end of file diff --git a/docs/description/empty_parameters.md b/docs/description/empty_parameters.md new file mode 100644 index 0000000..524d318 --- /dev/null +++ b/docs/description/empty_parameters.md @@ -0,0 +1,65 @@ +# Empty Parameters + +Prefer `() -> ` over `Void -> `. + +* **Identifier:** empty_parameters +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let abc: () -> Void = {} + +``` + +```swift +func foo(completion: () -> Void) + +``` + +```swift +func foo(completion: () thows -> Void) + +``` + +```swift +let foo: (ConfigurationTests) -> Void throws -> Void) + +``` + +```swift +let foo: (ConfigurationTests) -> Void throws -> Void) + +``` + +```swift +let foo: (ConfigurationTests) ->Void throws -> Void) + +``` + +## Triggering Examples + +```swift +let abc: ↓(Void) -> Void = {} + +``` + +```swift +func foo(completion: ↓(Void) -> Void) + +``` + +```swift +func foo(completion: ↓(Void) throws -> Void) + +``` + +```swift +let foo: ↓(Void) -> () throws -> Void) + +``` \ No newline at end of file diff --git a/docs/description/empty_parentheses_with_trailing_closure.md b/docs/description/empty_parentheses_with_trailing_closure.md new file mode 100644 index 0000000..df2cd9e --- /dev/null +++ b/docs/description/empty_parentheses_with_trailing_closure.md @@ -0,0 +1,80 @@ +# Empty Parentheses with Trailing Closure + +When using trailing closures, empty parentheses should be avoided after the method call. + +* **Identifier:** empty_parentheses_with_trailing_closure +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +[1, 2].map { $0 + 1 } + +``` + +```swift +[1, 2].map({ $0 + 1 }) + +``` + +```swift +[1, 2].reduce(0) { $0 + $1 } +``` + +```swift +[1, 2].map { number in + number + 1 +} + +``` + +```swift +let isEmpty = [1, 2].isEmpty() + +``` + +```swift +UIView.animateWithDuration(0.3, animations: { + self.disableInteractionRightView.alpha = 0 +}, completion: { _ in + () +}) +``` + +## Triggering Examples + +```swift +[1, 2].map↓() { $0 + 1 } + +``` + +```swift +[1, 2].map↓( ) { $0 + 1 } + +``` + +```swift +[1, 2].map↓() { number in + number + 1 +} + +``` + +```swift +[1, 2].map↓( ) { number in + number + 1 +} + +``` + +```swift +func foo() -> [Int] { + return [1, 2].map↓() { $0 + 1 } +} + +``` \ No newline at end of file diff --git a/docs/description/empty_string.md b/docs/description/empty_string.md new file mode 100644 index 0000000..6c71bde --- /dev/null +++ b/docs/description/empty_string.md @@ -0,0 +1,37 @@ +# Empty String + +Prefer checking `isEmpty` over comparing `string` to an empty string literal. + +* **Identifier:** empty_string +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +myString.isEmpty +``` + +```swift +!myString.isEmpty +``` + +```swift +""" +foo== +""" +``` + +## Triggering Examples + +```swift +myString↓ == "" +``` + +```swift +myString↓ != "" +``` \ No newline at end of file diff --git a/docs/description/empty_xctest_method.md b/docs/description/empty_xctest_method.md new file mode 100644 index 0000000..983f422 --- /dev/null +++ b/docs/description/empty_xctest_method.md @@ -0,0 +1,154 @@ +# Empty XCTest Method + +Empty XCTest method should be avoided. + +* **Identifier:** empty_xctest_method +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class TotoTests: XCTestCase { + var foobar: Foobar? + + override func setUp() { + super.setUp() + foobar = Foobar() + } + + override func tearDown() { + foobar = nil + super.tearDown() + } + + func testFoo() { + XCTAssertTrue(foobar?.foo) + } + + func testBar() { + // comment... + + XCTAssertFalse(foobar?.bar) + + // comment... + } +} +``` + +```swift +class Foobar { + func setUp() {} + + func tearDown() {} + + func testFoo() {} +} +``` + +```swift +class TotoTests: XCTestCase { + func setUp(with object: Foobar) {} + + func tearDown(object: Foobar) {} + + func testFoo(_ foo: Foobar) {} + + func testBar(bar: (String) -> Int) {} +} +``` + +```swift +class TotoTests: XCTestCase { + func testFoo() { XCTAssertTrue(foobar?.foo) } + + func testBar() { XCTAssertFalse(foobar?.bar) } +} +``` + +## Triggering Examples + +```swift +class TotoTests: XCTestCase { + override ↓func setUp() { + } + + override ↓func tearDown() { + + } + + ↓func testFoo() { + + + } + + ↓func testBar() { + + + + } + + func helperFunction() { + } +} +``` + +```swift +class TotoTests: XCTestCase { + override ↓func setUp() {} + + override ↓func tearDown() {} + + ↓func testFoo() {} + + func helperFunction() {} +} +``` + +```swift +class TotoTests: XCTestCase { + override ↓func setUp() { + // comment... + } + + override ↓func tearDown() { + // comment... + // comment... + } + + ↓func testFoo() { + // comment... + + // comment... + + // comment... + } + + ↓func testBar() { + /* + * comment... + * + * comment... + * + * comment... + */ + } + + func helperFunction() { + } +} +``` + +```swift +class FooTests: XCTestCase { + override ↓func setUp() {} +} + +class BarTests: XCTestCase { + ↓func testFoo() {} +} +``` \ No newline at end of file diff --git a/docs/description/enum_case_associated_values_count.md b/docs/description/enum_case_associated_values_count.md new file mode 100644 index 0000000..58b95ee --- /dev/null +++ b/docs/description/enum_case_associated_values_count.md @@ -0,0 +1,41 @@ +# Enum Case Associated Values Count + +Number of associated values in an enum case should be low + +* **Identifier:** enum_case_associated_values_count +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** metrics +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning: 5, error: 6 + +## Non Triggering Examples + +```swift +enum Employee { + case fullTime(name: String, retirement: Date, designation: String, contactNumber: Int) + case partTime(name: String, age: Int, contractEndDate: Date) +} +``` + +```swift +enum Barcode { + case upc(Int, Int, Int, Int) +} +``` + +## Triggering Examples + +```swift +enum Employee { + case ↓fullTime(name: String, retirement: Date, age: Int, designation: String, contactNumber: Int) + case ↓partTime(name: String, contractEndDate: Date, age: Int, designation: String, contactNumber: Int) +} +``` + +```swift +enum Barcode { + case ↓upc(Int, Int, Int, Int, Int, Int) +} +``` \ No newline at end of file diff --git a/docs/description/expiring_todo.md b/docs/description/expiring_todo.md new file mode 100644 index 0000000..9d2c666 --- /dev/null +++ b/docs/description/expiring_todo.md @@ -0,0 +1,70 @@ +# ExpiringTodo + +TODOs and FIXMEs should be resolved prior to their expiry date. + +* **Identifier:** expiring_todo +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** (approaching_expiry_severity) warning, (reached_or_passed_expiry_severity) error + +## Non Triggering Examples + +```swift +// notaTODO: + +``` + +```swift +// notaFIXME: + +``` + +```swift +// TODO: [12/31/9999] + +``` + +```swift +// TODO(note) + +``` + +```swift +// FIXME(note) + +``` + +```swift +/* FIXME: */ + +``` + +```swift +/* TODO: */ + +``` + +```swift +/** FIXME: */ + +``` + +```swift +/** TODO: */ + +``` + +## Triggering Examples + +```swift +// TODO: [10/14/2019] + +``` + +```swift +// FIXME: [10/14/2019] + +``` \ No newline at end of file diff --git a/docs/description/explicit_acl.md b/docs/description/explicit_acl.md new file mode 100644 index 0000000..1ae7aa3 --- /dev/null +++ b/docs/description/explicit_acl.md @@ -0,0 +1,119 @@ +# Explicit ACL + +All declarations should specify Access Control Level keywords explicitly. + +* **Identifier:** explicit_acl +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +internal enum A {} + +``` + +```swift +public final class B {} + +``` + +```swift +private struct C {} + +``` + +```swift +internal enum A { + internal enum B {} +} +``` + +```swift +internal final class Foo {} +``` + +```swift +internal +class Foo { + private let bar = 5 +} +``` + +```swift +internal func a() { let a = } + +``` + +```swift +private func a() { func innerFunction() { } } +``` + +```swift +private enum Foo { enum Bar { } } +``` + +```swift +private struct C { let d = 5 } +``` + +```swift +internal protocol A { + func b() +} +``` + +```swift +internal protocol A { + var b: Int +} +``` + +```swift +internal class A { deinit {} } +``` + +```swift +extension A: Equatable {} +``` + +```swift +extension A {} +``` + +## Triggering Examples + +```swift +enum A {} + +``` + +```swift +final class B {} + +``` + +```swift +internal struct C { let d = 5 } + +``` + +```swift +public struct C { let d = 5 } + +``` + +```swift +func a() {} + +``` + +```swift +internal let a = 0 +func b() {} + +``` \ No newline at end of file diff --git a/docs/description/explicit_enum_raw_value.md b/docs/description/explicit_enum_raw_value.md new file mode 100644 index 0000000..580dc25 --- /dev/null +++ b/docs/description/explicit_enum_raw_value.md @@ -0,0 +1,81 @@ +# Explicit Enum Raw Value + +Enums should be explicitly assigned their raw values. + +* **Identifier:** explicit_enum_raw_value +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +enum Numbers { + case int(Int) + case short(Int16) +} +``` + +```swift +enum Numbers: Int { + case one = 1 + case two = 2 +} +``` + +```swift +enum Numbers: Double { + case one = 1.1 + case two = 2.2 +} +``` + +```swift +enum Numbers: String { + case one = "one" + case two = "two" +} +``` + +```swift +protocol Algebra {} +enum Numbers: Algebra { + case one +} +``` + +## Triggering Examples + +```swift +enum Numbers: Int { + case one = 10, ↓two, three = 30 +} +``` + +```swift +enum Numbers: NSInteger { + case ↓one +} +``` + +```swift +enum Numbers: String { + case ↓one + case ↓two +} +``` + +```swift +enum Numbers: String { + case ↓one, two = "two" +} +``` + +```swift +enum Numbers: Decimal { + case ↓one, ↓two +} +``` \ No newline at end of file diff --git a/docs/description/explicit_init.md b/docs/description/explicit_init.md new file mode 100644 index 0000000..02b96a4 --- /dev/null +++ b/docs/description/explicit_init.md @@ -0,0 +1,69 @@ +# Explicit Init + +Explicitly calling .init() should be avoided. + +* **Identifier:** explicit_init +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +import Foundation; class C: NSObject { override init() { super.init() }} +``` + +```swift +struct S { let n: Int }; extension S { init() { self.init(n: 1) } } +``` + +```swift +[1].flatMap(String.init) +``` + +```swift +[String.self].map { $0.init(1) } +``` + +```swift +[String.self].map { type in type.init(1) } +``` + +```swift +Observable.zip(obs1, obs2, resultSelector: MyType.init).asMaybe() +``` + +```swift +Observable.zip( + obs1, + obs2, + resultSelector: MyType.init +).asMaybe() +``` + +## Triggering Examples + +```swift +[1].flatMap{String↓.init($0)} +``` + +```swift +[String.self].map { Type in Type↓.init(1) } +``` + +```swift +func foo() -> [String] { + return [1].flatMap { String↓.init($0) } +} +``` + +```swift +Observable.zip( + obs1, + obs2, + resultSelector: { MyType.init($0, $1) } +).asMaybe() +``` \ No newline at end of file diff --git a/docs/description/explicit_self.md b/docs/description/explicit_self.md new file mode 100644 index 0000000..b4e97ef --- /dev/null +++ b/docs/description/explicit_self.md @@ -0,0 +1,51 @@ +# Explicit Self + +Instance variables and functions should be explicitly accessed with 'self.'. + +* **Identifier:** explicit_self +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** Yes +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +struct A { + func f1() {} + func f2() { + self.f1() + } +} +``` + +```swift +struct A { + let p1: Int + func f1() { + _ = self.p1 + } +} +``` + +## Triggering Examples + +```swift +struct A { + func f1() {} + func f2() { + ↓f1() + } +} +``` + +```swift +struct A { + let p1: Int + func f1() { + _ = ↓p1 + } +} +``` \ No newline at end of file diff --git a/docs/description/explicit_top_level_acl.md b/docs/description/explicit_top_level_acl.md new file mode 100644 index 0000000..700ab9a --- /dev/null +++ b/docs/description/explicit_top_level_acl.md @@ -0,0 +1,84 @@ +# Explicit Top Level ACL + +Top-level declarations should specify Access Control Level keywords explicitly. + +* **Identifier:** explicit_top_level_acl +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +internal enum A {} + +``` + +```swift +public final class B {} + +``` + +```swift +private struct C {} + +``` + +```swift +internal enum A { + enum B {} +} +``` + +```swift +internal final class Foo {} +``` + +```swift +internal +class Foo {} +``` + +```swift +internal func a() {} + +``` + +```swift +extension A: Equatable {} +``` + +```swift +extension A {} +``` + +## Triggering Examples + +```swift +enum A {} + +``` + +```swift +final class B {} + +``` + +```swift +struct C {} + +``` + +```swift +func a() {} + +``` + +```swift +internal let a = 0 +func b() {} + +``` \ No newline at end of file diff --git a/docs/description/explicit_type_interface.md b/docs/description/explicit_type_interface.md new file mode 100644 index 0000000..ad4d8f4 --- /dev/null +++ b/docs/description/explicit_type_interface.md @@ -0,0 +1,75 @@ +# Explicit Type Interface + +Properties should have a type interface + +* **Identifier:** explicit_type_interface +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, excluded: [], allow_redundancy: false + +## Non Triggering Examples + +```swift +class Foo { + var myVar: Int? = 0 +} +``` + +```swift +class Foo { + let myVar: Int? = 0 +} +``` + +```swift +class Foo { + static var myVar: Int? = 0 +} +``` + +```swift +class Foo { + class var myVar: Int? = 0 +} +``` + +## Triggering Examples + +```swift +class Foo { + ↓var myVar = 0 +} +``` + +```swift +class Foo { + ↓let mylet = 0 +} +``` + +```swift +class Foo { + ↓static var myStaticVar = 0 +} +``` + +```swift +class Foo { + ↓class var myClassVar = 0 +} +``` + +```swift +class Foo { + ↓let myVar = Int(0) +} +``` + +```swift +class Foo { + ↓let myVar = Set(0) +} +``` \ No newline at end of file diff --git a/docs/description/extension_access_modifier.md b/docs/description/extension_access_modifier.md new file mode 100644 index 0000000..44e3907 --- /dev/null +++ b/docs/description/extension_access_modifier.md @@ -0,0 +1,84 @@ +# Extension Access Modifier + +Prefer to use extension access modifiers + +* **Identifier:** extension_access_modifier +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +extension Foo: SomeProtocol { + public var bar: Int { return 1 } +} +``` + +```swift +extension Foo { + private var bar: Int { return 1 } + public var baz: Int { return 1 } +} +``` + +```swift +extension Foo { + private var bar: Int { return 1 } + public func baz() {} +} +``` + +```swift +extension Foo { + var bar: Int { return 1 } + var baz: Int { return 1 } +} +``` + +```swift +public extension Foo { + var bar: Int { return 1 } + var baz: Int { return 1 } +} +``` + +```swift +extension Foo { + private bar: Int { return 1 } + private baz: Int { return 1 } +} +``` + +```swift +extension Foo { + open bar: Int { return 1 } + open baz: Int { return 1 } +} +``` + +## Triggering Examples + +```swift +↓extension Foo { + public var bar: Int { return 1 } + public var baz: Int { return 1 } +} +``` + +```swift +↓extension Foo { + public var bar: Int { return 1 } + public func baz() {} +} +``` + +```swift +public extension Foo { + public ↓func bar() {} + public ↓func baz() {} +} +``` \ No newline at end of file diff --git a/docs/description/fallthrough.md b/docs/description/fallthrough.md new file mode 100644 index 0000000..62ac6c2 --- /dev/null +++ b/docs/description/fallthrough.md @@ -0,0 +1,31 @@ +# Fallthrough + +Fallthrough should be avoided. + +* **Identifier:** fallthrough +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +switch foo { +case .bar, .bar2, .bar3: + something() +} +``` + +## Triggering Examples + +```swift +switch foo { +case .bar: + ↓fallthrough +case .bar2: + something() +} +``` \ No newline at end of file diff --git a/docs/description/fatal_error_message.md b/docs/description/fatal_error_message.md new file mode 100644 index 0000000..c706f74 --- /dev/null +++ b/docs/description/fatal_error_message.md @@ -0,0 +1,39 @@ +# Fatal Error Message + +A fatalError call should have a message. + +* **Identifier:** fatal_error_message +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func foo() { + fatalError("Foo") +} +``` + +```swift +func foo() { + fatalError(x) +} +``` + +## Triggering Examples + +```swift +func foo() { + ↓fatalError("") +} +``` + +```swift +func foo() { + ↓fatalError() +} +``` \ No newline at end of file diff --git a/docs/description/file_header.md b/docs/description/file_header.md new file mode 100644 index 0000000..c790009 --- /dev/null +++ b/docs/description/file_header.md @@ -0,0 +1,48 @@ +# File Header + +Header comments should be consistent with project patterns. The SWIFTLINT_CURRENT_FILENAME placeholder can optionally be used in the required and forbidden patterns. It will be replaced by the real file name. + +* **Identifier:** file_header +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, required_string: None, required_pattern: None, forbidden_string: None, forbidden_pattern: None + +## Non Triggering Examples + +```swift +let foo = "Copyright" +``` + +```swift +let foo = 2 // Copyright +``` + +```swift +let foo = 2 + // Copyright +``` + +## Triggering Examples + +```swift +// ↓Copyright + +``` + +```swift +// +// ↓Copyright +``` + +```swift +// +// FileHeaderRule.swift +// SwiftLint +// +// Created by Marcelo Fabri on 27/11/16. +// ↓Copyright © 2016 Realm. All rights reserved. +// +``` \ No newline at end of file diff --git a/docs/description/file_length.md b/docs/description/file_length.md new file mode 100644 index 0000000..805601e --- /dev/null +++ b/docs/description/file_length.md @@ -0,0 +1,1229 @@ +# File Line Length + +Files should not span too many lines. + +* **Identifier:** file_length +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** metrics +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning: 400, error: 1000, ignore_comment_only_lines: false + +## Non Triggering Examples + +```swift +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") + +``` + +## Triggering Examples + +```swift +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") + +``` + +```swift +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +print("swiftlint") +// + +``` \ No newline at end of file diff --git a/docs/description/file_name.md b/docs/description/file_name.md new file mode 100644 index 0000000..72938d3 --- /dev/null +++ b/docs/description/file_name.md @@ -0,0 +1,11 @@ +# File Name + +File name should match a type or extension declared in the file (if any). + +* **Identifier:** file_name +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** (severity) warning, excluded: ["LinuxMain.swift", "main.swift"], prefixPattern: , suffixPattern: \+.*, nestedTypeSeparator: . \ No newline at end of file diff --git a/docs/description/file_name_no_space.md b/docs/description/file_name_no_space.md new file mode 100644 index 0000000..3ac0ead --- /dev/null +++ b/docs/description/file_name_no_space.md @@ -0,0 +1,11 @@ +# File Name No Space + +File name should not contain any whitespace. + +* **Identifier:** file_name_no_space +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** (severity) warning, excluded: [] \ No newline at end of file diff --git a/docs/description/file_types_order.md b/docs/description/file_types_order.md new file mode 100644 index 0000000..634056b --- /dev/null +++ b/docs/description/file_types_order.md @@ -0,0 +1,211 @@ +# File Types Order + +Specifies how the types within a file should be ordered. + +* **Identifier:** file_types_order +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, order: [[SwiftLintFramework.FileType.supportingType], [SwiftLintFramework.FileType.mainType], [SwiftLintFramework.FileType.extension]] + +## Non Triggering Examples + +```swift +// Supporting Types +protocol TestViewControllerDelegate { + func didPressTrackedButton() +} + +// Main Type +class TestViewController: UIViewController { + // Type Aliases + typealias CompletionHandler = ((TestEnum) -> Void) + + // Subtypes + class TestClass { + // 10 lines + } + + struct TestStruct { + // 3 lines + } + + enum TestEnum { + // 5 lines + } + + // Stored Type Properties + static let cellIdentifier: String = "AmazingCell" + + // Stored Instance Properties + var shouldLayoutView1: Bool! + weak var delegate: TestViewControllerDelegate? + private var hasLayoutedView1: Bool = false + private var hasLayoutedView2: Bool = false + + // Computed Instance Properties + private var hasAnyLayoutedView: Bool { + return hasLayoutedView1 || hasLayoutedView2 + } + + // IBOutlets + @IBOutlet private var view1: UIView! + @IBOutlet private var view2: UIView! + + // Initializers + override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // Type Methods + static func makeViewController() -> TestViewController { + // some code + } + + // Life-Cycle Methods + override func viewDidLoad() { + super.viewDidLoad() + + view1.setNeedsLayout() + view1.layoutIfNeeded() + hasLayoutedView1 = true + } + + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + + view2.setNeedsLayout() + view2.layoutIfNeeded() + hasLayoutedView2 = true + } + + // IBActions + @IBAction func goNextButtonPressed() { + goToNextVc() + delegate?.didPressTrackedButton() + } + + @objc + func goToRandomVcButtonPressed() { + goToRandomVc() + } + + // MARK: Other Methods + func goToNextVc() { /* TODO */ } + + func goToInfoVc() { /* TODO */ } + + func goToRandomVc() { + let viewCtrl = getRandomVc() + present(viewCtrl, animated: true) + } + + private func getRandomVc() -> UIViewController { return UIViewController() } + + // Subscripts + subscript(_ someIndexThatIsNotEvenUsed: Int) -> String { + get { + return "This is just a test" + } + + set { + log.warning("Just a test", newValue) + } + } +} + +// Extensions +extension TestViewController: UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 1 + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return UITableViewCell() + } +} +``` + +```swift +// Only extensions +extension Foo {} +extension Bar { +} +``` + +## Triggering Examples + +```swift +↓class TestViewController: UIViewController {} + +// Supporting Types +protocol TestViewControllerDelegate { + func didPressTrackedButton() +} +``` + +```swift +// Extensions +↓extension TestViewController: UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 1 + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return UITableViewCell() + } +} + +class TestViewController: UIViewController {} +``` + +```swift +// Supporting Types +protocol TestViewControllerDelegate { + func didPressTrackedButton() +} + +↓class TestViewController: UIViewController {} + +// Supporting Types +protocol TestViewControllerDelegate { + func didPressTrackedButton() +} +``` + +```swift +// Supporting Types +protocol TestViewControllerDelegate { + func didPressTrackedButton() +} + +// Extensions +↓extension TestViewController: UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 1 + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return UITableViewCell() + } +} + +class TestViewController: UIViewController {} + +// Extensions +extension TestViewController: UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 1 + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return UITableViewCell() + } +} +``` \ No newline at end of file diff --git a/docs/description/first_where.md b/docs/description/first_where.md new file mode 100644 index 0000000..c58a96d --- /dev/null +++ b/docs/description/first_where.md @@ -0,0 +1,83 @@ +# First Where + +Prefer using `.first(where:)` over `.filter { }.first` in collections. + +* **Identifier:** first_where +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +kinds.filter(excludingKinds.contains).isEmpty && kinds.first == .identifier + +``` + +```swift +myList.first(where: { $0 % 2 == 0 }) + +``` + +```swift +match(pattern: pattern).filter { $0.first == .identifier } + +``` + +```swift +(myList.filter { $0 == 1 }.suffix(2)).first + +``` + +```swift +collection.filter("stringCol = '3'").first +``` + +```swift +realm?.objects(User.self).filter(NSPredicate(format: "email ==[c] %@", email)).first +``` + +```swift +if let pause = timeTracker.pauses.filter("beginDate < %@", beginDate).first { print(pause) } +``` + +## Triggering Examples + +```swift +↓myList.filter { $0 % 2 == 0 }.first + +``` + +```swift +↓myList.filter({ $0 % 2 == 0 }).first + +``` + +```swift +↓myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).first + +``` + +```swift +↓myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).first?.something() + +``` + +```swift +↓myList.filter(someFunction).first + +``` + +```swift +↓myList.filter({ $0 % 2 == 0 }) +.first + +``` + +```swift +(↓myList.filter { $0 == 1 }).first + +``` \ No newline at end of file diff --git a/docs/description/flatmap_over_map_reduce.md b/docs/description/flatmap_over_map_reduce.md new file mode 100644 index 0000000..a7f7ede --- /dev/null +++ b/docs/description/flatmap_over_map_reduce.md @@ -0,0 +1,27 @@ +# FlatMap over map and reduce + +Prefer `flatMap` over `map` followed by `reduce([], +)`. + +* **Identifier:** flatmap_over_map_reduce +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let foo = bar.map { $0.count }.reduce(0, +) +``` + +```swift +let foo = bar.flatMap { $0.array } +``` + +## Triggering Examples + +```swift +let foo = ↓bar.map { $0.array }.reduce([], +) +``` \ No newline at end of file diff --git a/docs/description/for_where.md b/docs/description/for_where.md new file mode 100644 index 0000000..d7f5fa3 --- /dev/null +++ b/docs/description/for_where.md @@ -0,0 +1,85 @@ +# For Where + +`where` clauses are preferred over a single `if` inside a `for`. + +* **Identifier:** for_where +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +for user in users where user.id == 1 { } +``` + +```swift +for user in users { + if let id = user.id { } +} +``` + +```swift +for user in users { + if var id = user.id { } +} +``` + +```swift +for user in users { + if user.id == 1 { } else { } +} +``` + +```swift +for user in users { + if user.id == 1 { + } else if user.id == 2 { } +} +``` + +```swift +for user in users { + if user.id == 1 { } + print(user) +} +``` + +```swift +for user in users { + let id = user.id + if id == 1 { } +} +``` + +```swift +for user in users { + if user.id == 1 { } + return true +} +``` + +```swift +for user in users { + if user.id == 1 && user.age > 18 { } +} +``` + +```swift +for (index, value) in array.enumerated() { + if case .valueB(_) = value { + return index + } +} +``` + +## Triggering Examples + +```swift +for user in users { + ↓if user.id == 1 { return true } +} +``` \ No newline at end of file diff --git a/docs/description/force_cast.md b/docs/description/force_cast.md new file mode 100644 index 0000000..caf6638 --- /dev/null +++ b/docs/description/force_cast.md @@ -0,0 +1,25 @@ +# Force Cast + +Force casts should be avoided. + +* **Identifier:** force_cast +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** error + +## Non Triggering Examples + +```swift +NSNumber() as? Int + +``` + +## Triggering Examples + +```swift +NSNumber() ↓as! Int + +``` \ No newline at end of file diff --git a/docs/description/force_try.md b/docs/description/force_try.md new file mode 100644 index 0000000..75f4dff --- /dev/null +++ b/docs/description/force_try.md @@ -0,0 +1,27 @@ +# Force Try + +Force tries should be avoided. + +* **Identifier:** force_try +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** error + +## Non Triggering Examples + +```swift +func a() throws {} +do { + try a() +} catch {} +``` + +## Triggering Examples + +```swift +func a() throws {} +↓try! a() +``` \ No newline at end of file diff --git a/docs/description/force_unwrapping.md b/docs/description/force_unwrapping.md new file mode 100644 index 0000000..a4df152 --- /dev/null +++ b/docs/description/force_unwrapping.md @@ -0,0 +1,145 @@ +# Force Unwrapping + +Force unwrapping should be avoided. + +* **Identifier:** force_unwrapping +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +if let url = NSURL(string: query) +``` + +```swift +navigationController?.pushViewController(viewController, animated: true) +``` + +```swift +let s as! Test +``` + +```swift +try! canThrowErrors() +``` + +```swift +let object: Any! +``` + +```swift +@IBOutlet var constraints: [NSLayoutConstraint]! +``` + +```swift +setEditing(!editing, animated: true) +``` + +```swift +navigationController.setNavigationBarHidden(!navigationController.navigationBarHidden, animated: true) +``` + +```swift +if addedToPlaylist && (!self.selectedFilters.isEmpty || self.searchBar?.text?.isEmpty == false) {} +``` + +```swift +print("\(xVar)!") +``` + +```swift +var test = (!bar) +``` + +```swift +var a: [Int]! +``` + +```swift +private var myProperty: (Void -> Void)! +``` + +```swift +func foo(_ options: [AnyHashable: Any]!) { +``` + +```swift +func foo() -> [Int]! +``` + +```swift +func foo() -> [AnyHashable: Any]! +``` + +```swift +func foo() -> [Int]! { return [] } +``` + +```swift +return self +``` + +## Triggering Examples + +```swift +let url = NSURL(string: query)↓! +``` + +```swift +navigationController↓!.pushViewController(viewController, animated: true) +``` + +```swift +let unwrapped = optional↓! +``` + +```swift +return cell↓! +``` + +```swift +let url = NSURL(string: "http://www.google.com")↓! +``` + +```swift +let dict = ["Boooo": "👻"]func bla() -> String { return dict["Boooo"]↓! } +``` + +```swift +let dict = ["Boooo": "👻"]func bla() -> String { return dict["Boooo"]↓!.contains("B") } +``` + +```swift +let a = dict["abc"]↓!.contains("B") +``` + +```swift +dict["abc"]↓!.bar("B") +``` + +```swift +if dict["a"]↓!!!! { +``` + +```swift +var foo: [Bool]! = dict["abc"]↓! +``` + +```swift +context("abc") { + var foo: [Bool]! = dict["abc"]↓! +} +``` + +```swift +open var computed: String { return foo.bar↓! } +``` + +```swift +return self↓! +``` \ No newline at end of file diff --git a/docs/description/function_body_length.md b/docs/description/function_body_length.md new file mode 100644 index 0000000..6b694fd --- /dev/null +++ b/docs/description/function_body_length.md @@ -0,0 +1,11 @@ +# Function Body Length + +Functions bodies should not span too many lines. + +* **Identifier:** function_body_length +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** metrics +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning: 40, error: 100 \ No newline at end of file diff --git a/docs/description/function_default_parameter_at_end.md b/docs/description/function_default_parameter_at_end.md new file mode 100644 index 0000000..4e04488 --- /dev/null +++ b/docs/description/function_default_parameter_at_end.md @@ -0,0 +1,63 @@ +# Function Default Parameter at End + +Prefer to locate parameters with defaults toward the end of the parameter list. + +* **Identifier:** function_default_parameter_at_end +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func foo(baz: String, bar: Int = 0) {} +``` + +```swift +func foo(x: String, y: Int = 0, z: CGFloat = 0) {} +``` + +```swift +func foo(bar: String, baz: Int = 0, z: () -> Void) {} +``` + +```swift +func foo(bar: String, z: () -> Void, baz: Int = 0) {} +``` + +```swift +func foo(bar: Int = 0) {} +``` + +```swift +func foo() {} +``` + +```swift +class A: B { + override func foo(bar: Int = 0, baz: String) {} +``` + +```swift +func foo(bar: Int = 0, completion: @escaping CompletionHandler) {} +``` + +```swift +func foo(a: Int, b: CGFloat = 0) { + let block = { (error: Error?) in } +} +``` + +```swift +func foo(a: String, b: String? = nil, + c: String? = nil, d: @escaping AlertActionHandler = { _ in }) {} +``` + +## Triggering Examples + +```swift +↓func foo(bar: Int = 0, baz: String) {} +``` \ No newline at end of file diff --git a/docs/description/function_parameter_count.md b/docs/description/function_parameter_count.md new file mode 100644 index 0000000..028fe36 --- /dev/null +++ b/docs/description/function_parameter_count.md @@ -0,0 +1,74 @@ +# Function Parameter Count + +Number of function parameters should be low. + +* **Identifier:** function_parameter_count +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** metrics +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning: 5, error: 8ignores_default_parameters: true + +## Non Triggering Examples + +```swift +init(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {} +``` + +```swift +init (a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {} +``` + +```swift +`init`(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {} +``` + +```swift +init?(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {} +``` + +```swift +init?(a: T, b: Int, c: Int, d: Int, e: Int, f: Int) {} +``` + +```swift +init?(a: T, b: Int, c: Int, d: Int, e: Int, f: Int) {} +``` + +```swift +func f2(p1: Int, p2: Int) { } +``` + +```swift +func f(a: Int, b: Int, c: Int, d: Int, x: Int = 42) {} +``` + +```swift +func f(a: [Int], b: Int, c: Int, d: Int, f: Int) -> [Int] { + let s = a.flatMap { $0 as? [String: Int] } ?? []}} +``` + +```swift +override func f(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {} +``` + +## Triggering Examples + +```swift +↓func f(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {} +``` + +```swift +↓func initialValue(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {} +``` + +```swift +↓func f(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int = 2, g: Int) {} +``` + +```swift +struct Foo { + init(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {} + ↓func bar(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {}} +``` \ No newline at end of file diff --git a/docs/description/generic_type_name.md b/docs/description/generic_type_name.md new file mode 100644 index 0000000..963cc4d --- /dev/null +++ b/docs/description/generic_type_name.md @@ -0,0 +1,195 @@ +# Generic Type Name + +Generic type name should only contain alphanumeric characters, start with an uppercase character and span between 1 and 20 characters in length. + +* **Identifier:** generic_type_name +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** (min_length) w/e: 1/0, (max_length) w/e: 20/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true + +## Non Triggering Examples + +```swift +func foo() {} + +``` + +```swift +func foo() -> T {} + +``` + +```swift +func foo(param: U) -> T {} + +``` + +```swift +func foo(param: U) -> T {} + +``` + +```swift +struct Foo {} + +``` + +```swift +class Foo {} + +``` + +```swift +enum Foo {} + +``` + +```swift +func run(_ options: NoOptions>) {} + +``` + +```swift +func foo(_ options: Set) {} + +``` + +```swift +func < (lhs: T?, rhs: T?) -> Bool + +``` + +```swift +func configureWith(data: Either) + +``` + +```swift +typealias StringDictionary = Dictionary + +``` + +```swift +typealias BackwardTriple = (T3, T2, T1) + +``` + +```swift +typealias DictionaryOfStrings = Dictionary + +``` + +## Triggering Examples + +```swift +func foo<↓T_Foo>() {} + +``` + +```swift +func foo(param: U_Foo) -> T {} + +``` + +```swift +func foo<↓TTTTTTTTTTTTTTTTTTTTT>() {} + +``` + +```swift +func foo<↓type>() {} + +``` + +```swift +typealias StringDictionary<↓T_Foo> = Dictionary + +``` + +```swift +typealias BackwardTriple = (T3, T2_Bar, T1) + +``` + +```swift +typealias DictionaryOfStrings<↓T_Foo: Hashable> = Dictionary + +``` + +```swift +class Foo<↓T_Foo> {} + +``` + +```swift +class Foo {} + +``` + +```swift +class Foo<↓T_Foo, ↓U_Foo> {} + +``` + +```swift +class Foo<↓TTTTTTTTTTTTTTTTTTTTT> {} + +``` + +```swift +class Foo<↓type> {} + +``` + +```swift +struct Foo<↓T_Foo> {} + +``` + +```swift +struct Foo {} + +``` + +```swift +struct Foo<↓T_Foo, ↓U_Foo> {} + +``` + +```swift +struct Foo<↓TTTTTTTTTTTTTTTTTTTTT> {} + +``` + +```swift +struct Foo<↓type> {} + +``` + +```swift +enum Foo<↓T_Foo> {} + +``` + +```swift +enum Foo {} + +``` + +```swift +enum Foo<↓T_Foo, ↓U_Foo> {} + +``` + +```swift +enum Foo<↓TTTTTTTTTTTTTTTTTTTTT> {} + +``` + +```swift +enum Foo<↓type> {} + +``` \ No newline at end of file diff --git a/docs/description/identical_operands.md b/docs/description/identical_operands.md new file mode 100644 index 0000000..b014c92 --- /dev/null +++ b/docs/description/identical_operands.md @@ -0,0 +1,815 @@ +# Identical Operands + +Comparing two identical operands is likely a mistake. + +* **Identifier:** identical_operands +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +1 == 2 +``` + +```swift +foo == bar +``` + +```swift +prefixedFoo == foo +``` + +```swift +foo.aProperty == foo.anotherProperty +``` + +```swift +self.aProperty == self.anotherProperty +``` + +```swift +"1 == 1" +``` + +```swift +self.aProperty == aProperty +``` + +```swift +lhs.aProperty == rhs.aProperty +``` + +```swift +lhs.identifier == rhs.identifier +``` + +```swift +i == index +``` + +```swift +$0 == 0 +``` + +```swift +keyValues?.count ?? 0 == 0 +``` + +```swift +string == string.lowercased() +``` + +```swift +let num: Int? = 0 +_ = num != nil && num == num?.byteSwapped +``` + +```swift +num == num!.byteSwapped +``` + +```swift +1 != 2 +``` + +```swift +foo != bar +``` + +```swift +prefixedFoo != foo +``` + +```swift +foo.aProperty != foo.anotherProperty +``` + +```swift +self.aProperty != self.anotherProperty +``` + +```swift +"1 != 1" +``` + +```swift +self.aProperty != aProperty +``` + +```swift +lhs.aProperty != rhs.aProperty +``` + +```swift +lhs.identifier != rhs.identifier +``` + +```swift +i != index +``` + +```swift +$0 != 0 +``` + +```swift +keyValues?.count ?? 0 != 0 +``` + +```swift +string != string.lowercased() +``` + +```swift +let num: Int? = 0 +_ = num != nil && num != num?.byteSwapped +``` + +```swift +num != num!.byteSwapped +``` + +```swift +1 === 2 +``` + +```swift +foo === bar +``` + +```swift +prefixedFoo === foo +``` + +```swift +foo.aProperty === foo.anotherProperty +``` + +```swift +self.aProperty === self.anotherProperty +``` + +```swift +"1 === 1" +``` + +```swift +self.aProperty === aProperty +``` + +```swift +lhs.aProperty === rhs.aProperty +``` + +```swift +lhs.identifier === rhs.identifier +``` + +```swift +i === index +``` + +```swift +$0 === 0 +``` + +```swift +keyValues?.count ?? 0 === 0 +``` + +```swift +string === string.lowercased() +``` + +```swift +let num: Int? = 0 +_ = num != nil && num === num?.byteSwapped +``` + +```swift +num === num!.byteSwapped +``` + +```swift +1 !== 2 +``` + +```swift +foo !== bar +``` + +```swift +prefixedFoo !== foo +``` + +```swift +foo.aProperty !== foo.anotherProperty +``` + +```swift +self.aProperty !== self.anotherProperty +``` + +```swift +"1 !== 1" +``` + +```swift +self.aProperty !== aProperty +``` + +```swift +lhs.aProperty !== rhs.aProperty +``` + +```swift +lhs.identifier !== rhs.identifier +``` + +```swift +i !== index +``` + +```swift +$0 !== 0 +``` + +```swift +keyValues?.count ?? 0 !== 0 +``` + +```swift +string !== string.lowercased() +``` + +```swift +let num: Int? = 0 +_ = num != nil && num !== num?.byteSwapped +``` + +```swift +num !== num!.byteSwapped +``` + +```swift +1 > 2 +``` + +```swift +foo > bar +``` + +```swift +prefixedFoo > foo +``` + +```swift +foo.aProperty > foo.anotherProperty +``` + +```swift +self.aProperty > self.anotherProperty +``` + +```swift +"1 > 1" +``` + +```swift +self.aProperty > aProperty +``` + +```swift +lhs.aProperty > rhs.aProperty +``` + +```swift +lhs.identifier > rhs.identifier +``` + +```swift +i > index +``` + +```swift +$0 > 0 +``` + +```swift +keyValues?.count ?? 0 > 0 +``` + +```swift +string > string.lowercased() +``` + +```swift +let num: Int? = 0 +_ = num != nil && num > num?.byteSwapped +``` + +```swift +num > num!.byteSwapped +``` + +```swift +1 >= 2 +``` + +```swift +foo >= bar +``` + +```swift +prefixedFoo >= foo +``` + +```swift +foo.aProperty >= foo.anotherProperty +``` + +```swift +self.aProperty >= self.anotherProperty +``` + +```swift +"1 >= 1" +``` + +```swift +self.aProperty >= aProperty +``` + +```swift +lhs.aProperty >= rhs.aProperty +``` + +```swift +lhs.identifier >= rhs.identifier +``` + +```swift +i >= index +``` + +```swift +$0 >= 0 +``` + +```swift +keyValues?.count ?? 0 >= 0 +``` + +```swift +string >= string.lowercased() +``` + +```swift +let num: Int? = 0 +_ = num != nil && num >= num?.byteSwapped +``` + +```swift +num >= num!.byteSwapped +``` + +```swift +1 < 2 +``` + +```swift +foo < bar +``` + +```swift +prefixedFoo < foo +``` + +```swift +foo.aProperty < foo.anotherProperty +``` + +```swift +self.aProperty < self.anotherProperty +``` + +```swift +"1 < 1" +``` + +```swift +self.aProperty < aProperty +``` + +```swift +lhs.aProperty < rhs.aProperty +``` + +```swift +lhs.identifier < rhs.identifier +``` + +```swift +i < index +``` + +```swift +$0 < 0 +``` + +```swift +keyValues?.count ?? 0 < 0 +``` + +```swift +string < string.lowercased() +``` + +```swift +let num: Int? = 0 +_ = num != nil && num < num?.byteSwapped +``` + +```swift +num < num!.byteSwapped +``` + +```swift +1 <= 2 +``` + +```swift +foo <= bar +``` + +```swift +prefixedFoo <= foo +``` + +```swift +foo.aProperty <= foo.anotherProperty +``` + +```swift +self.aProperty <= self.anotherProperty +``` + +```swift +"1 <= 1" +``` + +```swift +self.aProperty <= aProperty +``` + +```swift +lhs.aProperty <= rhs.aProperty +``` + +```swift +lhs.identifier <= rhs.identifier +``` + +```swift +i <= index +``` + +```swift +$0 <= 0 +``` + +```swift +keyValues?.count ?? 0 <= 0 +``` + +```swift +string <= string.lowercased() +``` + +```swift +let num: Int? = 0 +_ = num != nil && num <= num?.byteSwapped +``` + +```swift +num <= num!.byteSwapped +``` + +```swift +func evaluate(_ mode: CommandMode) -> Result>> +``` + +```swift +let array = Array>() +``` + +```swift +guard Set(identifiers).count != identifiers.count else { return } +``` + +```swift +expect("foo") == "foo" +``` + +```swift +type(of: model).cachePrefix == cachePrefix +``` + +```swift +histogram[156].0 == 0x003B8D96 && histogram[156].1 == 1 +``` + +## Triggering Examples + +```swift +↓1 == 1 +``` + +```swift +↓foo == foo +``` + +```swift +↓foo.aProperty == foo.aProperty +``` + +```swift +↓self.aProperty == self.aProperty +``` + +```swift +↓$0 == $0 +``` + +```swift +↓a?.b == a?.b +``` + +```swift +if (↓elem == elem) {} +``` + +```swift +XCTAssertTrue(↓s3 == s3) +``` + +```swift +if let tab = tabManager.selectedTab, ↓tab.webView == tab.webView +``` + +```swift +↓1 != 1 +``` + +```swift +↓foo != foo +``` + +```swift +↓foo.aProperty != foo.aProperty +``` + +```swift +↓self.aProperty != self.aProperty +``` + +```swift +↓$0 != $0 +``` + +```swift +↓a?.b != a?.b +``` + +```swift +if (↓elem != elem) {} +``` + +```swift +XCTAssertTrue(↓s3 != s3) +``` + +```swift +if let tab = tabManager.selectedTab, ↓tab.webView != tab.webView +``` + +```swift +↓1 === 1 +``` + +```swift +↓foo === foo +``` + +```swift +↓foo.aProperty === foo.aProperty +``` + +```swift +↓self.aProperty === self.aProperty +``` + +```swift +↓$0 === $0 +``` + +```swift +↓a?.b === a?.b +``` + +```swift +if (↓elem === elem) {} +``` + +```swift +XCTAssertTrue(↓s3 === s3) +``` + +```swift +if let tab = tabManager.selectedTab, ↓tab.webView === tab.webView +``` + +```swift +↓1 !== 1 +``` + +```swift +↓foo !== foo +``` + +```swift +↓foo.aProperty !== foo.aProperty +``` + +```swift +↓self.aProperty !== self.aProperty +``` + +```swift +↓$0 !== $0 +``` + +```swift +↓a?.b !== a?.b +``` + +```swift +if (↓elem !== elem) {} +``` + +```swift +XCTAssertTrue(↓s3 !== s3) +``` + +```swift +if let tab = tabManager.selectedTab, ↓tab.webView !== tab.webView +``` + +```swift +↓1 > 1 +``` + +```swift +↓foo > foo +``` + +```swift +↓foo.aProperty > foo.aProperty +``` + +```swift +↓self.aProperty > self.aProperty +``` + +```swift +↓$0 > $0 +``` + +```swift +↓a?.b > a?.b +``` + +```swift +if (↓elem > elem) {} +``` + +```swift +XCTAssertTrue(↓s3 > s3) +``` + +```swift +if let tab = tabManager.selectedTab, ↓tab.webView > tab.webView +``` + +```swift +↓1 >= 1 +``` + +```swift +↓foo >= foo +``` + +```swift +↓foo.aProperty >= foo.aProperty +``` + +```swift +↓self.aProperty >= self.aProperty +``` + +```swift +↓$0 >= $0 +``` + +```swift +↓a?.b >= a?.b +``` + +```swift +if (↓elem >= elem) {} +``` + +```swift +XCTAssertTrue(↓s3 >= s3) +``` + +```swift +if let tab = tabManager.selectedTab, ↓tab.webView >= tab.webView +``` + +```swift +↓1 < 1 +``` + +```swift +↓foo < foo +``` + +```swift +↓foo.aProperty < foo.aProperty +``` + +```swift +↓self.aProperty < self.aProperty +``` + +```swift +↓$0 < $0 +``` + +```swift +↓a?.b < a?.b +``` + +```swift +if (↓elem < elem) {} +``` + +```swift +XCTAssertTrue(↓s3 < s3) +``` + +```swift +if let tab = tabManager.selectedTab, ↓tab.webView < tab.webView +``` + +```swift +↓1 <= 1 +``` + +```swift +↓foo <= foo +``` + +```swift +↓foo.aProperty <= foo.aProperty +``` + +```swift +↓self.aProperty <= self.aProperty +``` + +```swift +↓$0 <= $0 +``` + +```swift +↓a?.b <= a?.b +``` + +```swift +if (↓elem <= elem) {} +``` + +```swift +XCTAssertTrue(↓s3 <= s3) +``` + +```swift +if let tab = tabManager.selectedTab, ↓tab.webView <= tab.webView +``` \ No newline at end of file diff --git a/docs/description/identifier_name.md b/docs/description/identifier_name.md new file mode 100644 index 0000000..a6f10dd --- /dev/null +++ b/docs/description/identifier_name.md @@ -0,0 +1,115 @@ +# Identifier Name + +Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared static and immutable. Variable names should not be too long or too short. + +* **Identifier:** identifier_name +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** (min_length) w/e: 3/2, (max_length) w/e: 40/60, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true + +## Non Triggering Examples + +```swift +let myLet = 0 +``` + +```swift +var myVar = 0 +``` + +```swift +private let _myLet = 0 +``` + +```swift +class Abc { static let MyLet = 0 } +``` + +```swift +let URL: NSURL? = nil +``` + +```swift +let XMLString: String? = nil +``` + +```swift +override var i = 0 +``` + +```swift +enum Foo { case myEnum } +``` + +```swift +func isOperator(name: String) -> Bool +``` + +```swift +func typeForKind(_ kind: SwiftDeclarationKind) -> String +``` + +```swift +func == (lhs: SyntaxToken, rhs: SyntaxToken) -> Bool +``` + +```swift +override func IsOperator(name: String) -> Bool +``` + +```swift +enum Foo { case `private` } +``` + +```swift +enum Foo { case value(String) } +``` + +## Triggering Examples + +```swift +↓let MyLet = 0 +``` + +```swift +↓let _myLet = 0 +``` + +```swift +private ↓let myLet_ = 0 +``` + +```swift +↓let myExtremelyVeryVeryVeryVeryVeryVeryLongLet = 0 +``` + +```swift +↓var myExtremelyVeryVeryVeryVeryVeryVeryLongVar = 0 +``` + +```swift +private ↓let _myExtremelyVeryVeryVeryVeryVeryVeryLongLet = 0 +``` + +```swift +↓let i = 0 +``` + +```swift +↓var id = 0 +``` + +```swift +private ↓let _i = 0 +``` + +```swift +↓func IsOperator(name: String) -> Bool +``` + +```swift +enum Foo { case ↓MyEnum } +``` \ No newline at end of file diff --git a/docs/description/implicit_getter.md b/docs/description/implicit_getter.md new file mode 100644 index 0000000..0baf504 --- /dev/null +++ b/docs/description/implicit_getter.md @@ -0,0 +1,260 @@ +# Implicit Getter + +Computed read-only properties and subscripts should avoid using the get keyword. + +* **Identifier:** implicit_getter +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class Foo { + var foo: Int { + get { return 3 } + set { _abc = newValue } + } +} +``` + +```swift +class Foo { + var foo: Int { + return 20 + } +} +``` + +```swift +class Foo { + static var foo: Int { + return 20 + } +} +``` + +```swift +class Foo { + static var foo: Int { + get { return 3 } + set { _abc = newValue } + } +} +``` + +```swift +class Foo { + var foo: Int +} +``` + +```swift +class Foo { + var foo: Int { + return getValueFromDisk() + } +} +``` + +```swift +class Foo { + var foo: String { + return "get" + } +} +``` + +```swift +protocol Foo { + var foo: Int { get } +``` + +```swift +protocol Foo { + var foo: Int { get set } +``` + +```swift +class Foo { + var foo: Int { + struct Bar { + var bar: Int { + get { return 1 } + set { _ = newValue } + } + } + + return Bar().bar + } +} +``` + +```swift +var _objCTaggedPointerBits: UInt { + @inline(__always) get { return 0 } +} +``` + +```swift +var next: Int? { + mutating get { + defer { self.count += 1 } + return self.count + } +} +``` + +```swift +extension Foo { + var bar: Bool { + get { _bar } + set { self._bar = newValue } + } +} +``` + +```swift +extension Foo { + var bar: Bool { + get { _bar } + set(newValue) { self._bar = newValue } + } +} +``` + +```swift +extension Float { + var clamped: Float { + set { + self = min(1, max(0, newValue)) + } + get { + min(1, max(0, self)) + } + } +} +``` + +```swift +extension Reactive where Base: UITapGestureRecognizer { + var tapped: CocoaAction? { + get { + return associatedAction.withValue { $0.flatMap { $0.action } } + } + nonmutating set { + setAction(newValue) + } + } +} +``` + +```swift +extension Test { + var foo: Bool { + get { + bar?.boolValue ?? true // Comment mentioning word set which triggers violation + } + set { + bar = NSNumber(value: newValue as Bool) + } + } +} +``` + +```swift +class Foo { + subscript(i: Int) -> Int { + return 20 + } +} +``` + +```swift +class Foo { + subscript(i: Int) -> Int { + get { return 3 } + set { _abc = newValue } + } +} +``` + +```swift +protocol Foo { + subscript(i: Int) -> Int { get } +} +``` + +```swift +protocol Foo { + subscript(i: Int) -> Int { get set } +} +``` + +## Triggering Examples + +```swift +class Foo { + var foo: Int { + ↓get { + return 20 + } + } +} +``` + +```swift +class Foo { + var foo: Int { + ↓get{ return 20 } + } +} +``` + +```swift +class Foo { + static var foo: Int { + ↓get { + return 20 + } + } +} +``` + +```swift +var foo: Int { + ↓get { return 20 } +} +``` + +```swift +class Foo { + @objc func bar() {} + var foo: Int { + ↓get { + return 20 + } + } +} +``` + +```swift +extension Foo { + var bar: Bool { + ↓get { _bar } + } +} +``` + +```swift +class Foo { + subscript(i: Int) -> Int { + ↓get { + return 20 + } + } +} +``` \ No newline at end of file diff --git a/docs/description/implicit_return.md b/docs/description/implicit_return.md new file mode 100644 index 0000000..91a1076 --- /dev/null +++ b/docs/description/implicit_return.md @@ -0,0 +1,129 @@ +# Implicit Return + +Prefer implicit returns in closures, functions and getters. + +* **Identifier:** implicit_return +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, included: [closure, function, getter] + +## Non Triggering Examples + +```swift +if foo { + return 0 +} +``` + +```swift +foo.map { $0 + 1 } +``` + +```swift +foo.map({ $0 + 1 }) +``` + +```swift +foo.map { value in value + 1 } +``` + +```swift +[1, 2].first(where: { + true +}) +``` + +```swift +func foo() -> Int { + 0 +} +``` + +```swift +class Foo { + func foo() -> Int { 0 } +} +``` + +```swift +var foo: Bool { true } +``` + +```swift +class Foo { + var bar: Int { + get { + 0 + } + } +} +``` + +```swift +class Foo { + static var bar: Int { + 0 + } +} +``` + +## Triggering Examples + +```swift +foo.map { value in + return value + 1 +} +``` + +```swift +foo.map { + return $0 + 1 +} +``` + +```swift +foo.map({ return $0 + 1}) +``` + +```swift +[1, 2].first(where: { + return true +}) +``` + +```swift +func foo() -> Int { + return 0 +} +``` + +```swift +class Foo { + func foo() -> Int { return 0 } +} +``` + +```swift +var foo: Bool { return true } +``` + +```swift +class Foo { + var bar: Int { + get { + return 0 + } + } +} +``` + +```swift +class Foo { + static var bar: Int { + return 0 + } +} +``` \ No newline at end of file diff --git a/docs/description/implicitly_unwrapped_optional.md b/docs/description/implicitly_unwrapped_optional.md new file mode 100644 index 0000000..79db81d --- /dev/null +++ b/docs/description/implicitly_unwrapped_optional.md @@ -0,0 +1,83 @@ +# Implicitly Unwrapped Optional + +Implicitly unwrapped optionals should be avoided when possible. + +* **Identifier:** implicitly_unwrapped_optional +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, mode: allExceptIBOutlets + +## Non Triggering Examples + +```swift +@IBOutlet private var label: UILabel! +``` + +```swift +@IBOutlet var label: UILabel! +``` + +```swift +@IBOutlet var label: [UILabel!] +``` + +```swift +if !boolean {} +``` + +```swift +let int: Int? = 42 +``` + +```swift +let int: Int? = nil +``` + +## Triggering Examples + +```swift +let label: UILabel! +``` + +```swift +let IBOutlet: UILabel! +``` + +```swift +let labels: [UILabel!] +``` + +```swift +var ints: [Int!] = [42, nil, 42] +``` + +```swift +let label: IBOutlet! +``` + +```swift +let int: Int! = 42 +``` + +```swift +let int: Int! = nil +``` + +```swift +var int: Int! = 42 +``` + +```swift +let int: ImplicitlyUnwrappedOptional +``` + +```swift +let collection: AnyCollection +``` + +```swift +func foo(int: Int!) {} +``` \ No newline at end of file diff --git a/docs/description/indentation_width.md b/docs/description/indentation_width.md new file mode 100644 index 0000000..3a3d011 --- /dev/null +++ b/docs/description/indentation_width.md @@ -0,0 +1,71 @@ +# Indentation Width + +Indent code using either one tab or the configured amount of spaces, unindent to match previous indentations. Don't indent the first line. + +* **Identifier:** indentation_width +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** severity: warning, indentation_width: 4include_comments: true + +## Non Triggering Examples + +```swift +firstLine +secondLine +``` + +```swift +firstLine + secondLine +``` + +```swift +firstLine + secondLine + thirdLine + + fourthLine +``` + +```swift +firstLine + secondLine + thirdLine +//test + fourthLine +``` + +```swift +firstLine + secondLine + thirdLine +fourthLine +``` + +## Triggering Examples + +```swift + firstLine +``` + +```swift +firstLine + secondLine +``` + +```swift +firstLine + secondLine + + fourthLine +``` + +```swift +firstLine + secondLine + thirdLine + fourthLine +``` \ No newline at end of file diff --git a/docs/description/inert_defer.md b/docs/description/inert_defer.md new file mode 100644 index 0000000..3fd0c4d --- /dev/null +++ b/docs/description/inert_defer.md @@ -0,0 +1,54 @@ +# Inert Defer + +If defer is at the end of its parent scope, it will be executed right where it is anyway. + +* **Identifier:** inert_defer +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func example3() { + defer { /* deferred code */ } + + print("other code") +} +``` + +```swift +func example4() { + if condition { + defer { /* deferred code */ } + print("other code") + } +} +``` + +## Triggering Examples + +```swift +func example0() { + ↓defer { /* deferred code */ } +} +``` + +```swift +func example1() { + ↓defer { /* deferred code */ } + // comment +} +``` + +```swift +func example2() { + if condition { + ↓defer { /* deferred code */ } + // comment + } +} +``` \ No newline at end of file diff --git a/docs/description/is_disjoint.md b/docs/description/is_disjoint.md new file mode 100644 index 0000000..9ce3ff8 --- /dev/null +++ b/docs/description/is_disjoint.md @@ -0,0 +1,39 @@ +# Is Disjoint + +Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty`. + +* **Identifier:** is_disjoint +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +_ = Set(syntaxKinds).isDisjoint(with: commentAndStringKindsSet) +``` + +```swift +let isObjc = !objcAttributes.isDisjoint(with: dictionary.enclosedSwiftAttributes) +``` + +```swift +_ = Set(syntaxKinds).intersection(commentAndStringKindsSet) +``` + +```swift +_ = !objcAttributes.intersection(dictionary.enclosedSwiftAttributes) +``` + +## Triggering Examples + +```swift +_ = Set(syntaxKinds).↓intersection(commentAndStringKindsSet).isEmpty +``` + +```swift +let isObjc = !objcAttributes.↓intersection(dictionary.enclosedSwiftAttributes).isEmpty +``` \ No newline at end of file diff --git a/docs/description/joined_default_parameter.md b/docs/description/joined_default_parameter.md new file mode 100644 index 0000000..07ad272 --- /dev/null +++ b/docs/description/joined_default_parameter.md @@ -0,0 +1,42 @@ +# Joined Default Parameter + +Discouraged explicit usage of the default separator. + +* **Identifier:** joined_default_parameter +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let foo = bar.joined() +``` + +```swift +let foo = bar.joined(separator: ",") +``` + +```swift +let foo = bar.joined(separator: toto) +``` + +## Triggering Examples + +```swift +let foo = bar.joined(↓separator: "") +``` + +```swift +let foo = bar.filter(toto) + .joined(↓separator: ""), +``` + +```swift +func foo() -> String { + return ["1", "2"].joined(↓separator: "") +} +``` \ No newline at end of file diff --git a/docs/description/large_tuple.md b/docs/description/large_tuple.md new file mode 100644 index 0000000..e31b65a --- /dev/null +++ b/docs/description/large_tuple.md @@ -0,0 +1,155 @@ +# Large Tuple + +Tuples shouldn't have too many members. Create a custom type instead. + +* **Identifier:** large_tuple +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** metrics +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning: 2, error: 3 + +## Non Triggering Examples + +```swift +let foo: (Int, Int) + +``` + +```swift +let foo: (start: Int, end: Int) + +``` + +```swift +let foo: (Int, (Int, String)) + +``` + +```swift +func foo() -> (Int, Int) + +``` + +```swift +func foo() -> (Int, Int) {} + +``` + +```swift +func foo(bar: String) -> (Int, Int) + +``` + +```swift +func foo(bar: String) -> (Int, Int) {} + +``` + +```swift +func foo() throws -> (Int, Int) + +``` + +```swift +func foo() throws -> (Int, Int) {} + +``` + +```swift +let foo: (Int, Int, Int) -> Void + +``` + +```swift +let foo: (Int, Int, Int) throws -> Void + +``` + +```swift +func foo(bar: (Int, String, Float) -> Void) + +``` + +```swift +func foo(bar: (Int, String, Float) throws -> Void) + +``` + +```swift +var completionHandler: ((_ data: Data?, _ resp: URLResponse?, _ e: NSError?) -> Void)! + +``` + +```swift +func getDictionaryAndInt() -> (Dictionary, Int)? + +``` + +```swift +func getGenericTypeAndInt() -> (Type, Int)? + +``` + +## Triggering Examples + +```swift +↓let foo: (Int, Int, Int) + +``` + +```swift +↓let foo: (start: Int, end: Int, value: String) + +``` + +```swift +↓let foo: (Int, (Int, Int, Int)) + +``` + +```swift +func foo(↓bar: (Int, Int, Int)) + +``` + +```swift +func foo() -> ↓(Int, Int, Int) + +``` + +```swift +func foo() -> ↓(Int, Int, Int) {} + +``` + +```swift +func foo(bar: String) -> ↓(Int, Int, Int) + +``` + +```swift +func foo(bar: String) -> ↓(Int, Int, Int) {} + +``` + +```swift +func foo() throws -> ↓(Int, Int, Int) + +``` + +```swift +func foo() throws -> ↓(Int, Int, Int) {} + +``` + +```swift +func foo() throws -> ↓(Int, ↓(String, String, String), Int) {} + +``` + +```swift +func getDictionaryAndInt() -> (Dictionary, Int)? + +``` \ No newline at end of file diff --git a/docs/description/last_where.md b/docs/description/last_where.md new file mode 100644 index 0000000..1c4c00e --- /dev/null +++ b/docs/description/last_where.md @@ -0,0 +1,75 @@ +# Last Where + +Prefer using `.last(where:)` over `.filter { }.last` in collections. + +* **Identifier:** last_where +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.2.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +kinds.filter(excludingKinds.contains).isEmpty && kinds.last == .identifier + +``` + +```swift +myList.last(where: { $0 % 2 == 0 }) + +``` + +```swift +match(pattern: pattern).filter { $0.last == .identifier } + +``` + +```swift +(myList.filter { $0 == 1 }.suffix(2)).last + +``` + +```swift +collection.filter("stringCol = '3'").last +``` + +## Triggering Examples + +```swift +↓myList.filter { $0 % 2 == 0 }.last + +``` + +```swift +↓myList.filter({ $0 % 2 == 0 }).last + +``` + +```swift +↓myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).last + +``` + +```swift +↓myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).last?.something() + +``` + +```swift +↓myList.filter(someFunction).last + +``` + +```swift +↓myList.filter({ $0 % 2 == 0 }) +.last + +``` + +```swift +(↓myList.filter { $0 == 1 }).last + +``` \ No newline at end of file diff --git a/docs/description/leading_whitespace.md b/docs/description/leading_whitespace.md new file mode 100644 index 0000000..11c4ac0 --- /dev/null +++ b/docs/description/leading_whitespace.md @@ -0,0 +1,30 @@ +# Leading Whitespace + +Files should not contain leading whitespace. + +* **Identifier:** leading_whitespace +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +// + +``` + +## Triggering Examples + +```swift + + +``` + +```swift + // + +``` \ No newline at end of file diff --git a/docs/description/legacy_cggeometry_functions.md b/docs/description/legacy_cggeometry_functions.md new file mode 100644 index 0000000..c610702 --- /dev/null +++ b/docs/description/legacy_cggeometry_functions.md @@ -0,0 +1,175 @@ +# Legacy CGGeometry Functions + +Struct extension properties and methods are preferred over legacy functions + +* **Identifier:** legacy_cggeometry_functions +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +rect.width +``` + +```swift +rect.height +``` + +```swift +rect.minX +``` + +```swift +rect.midX +``` + +```swift +rect.maxX +``` + +```swift +rect.minY +``` + +```swift +rect.midY +``` + +```swift +rect.maxY +``` + +```swift +rect.isNull +``` + +```swift +rect.isEmpty +``` + +```swift +rect.isInfinite +``` + +```swift +rect.standardized +``` + +```swift +rect.integral +``` + +```swift +rect.insetBy(dx: 5.0, dy: -7.0) +``` + +```swift +rect.offsetBy(dx: 5.0, dy: -7.0) +``` + +```swift +rect1.union(rect2) +``` + +```swift +rect1.intersect(rect2) +``` + +```swift +rect1.contains(rect2) +``` + +```swift +rect.contains(point) +``` + +```swift +rect1.intersects(rect2) +``` + +## Triggering Examples + +```swift +↓CGRectGetWidth(rect) +``` + +```swift +↓CGRectGetHeight(rect) +``` + +```swift +↓CGRectGetMinX(rect) +``` + +```swift +↓CGRectGetMidX(rect) +``` + +```swift +↓CGRectGetMaxX(rect) +``` + +```swift +↓CGRectGetMinY(rect) +``` + +```swift +↓CGRectGetMidY(rect) +``` + +```swift +↓CGRectGetMaxY(rect) +``` + +```swift +↓CGRectIsNull(rect) +``` + +```swift +↓CGRectIsEmpty(rect) +``` + +```swift +↓CGRectIsInfinite(rect) +``` + +```swift +↓CGRectStandardize(rect) +``` + +```swift +↓CGRectIntegral(rect) +``` + +```swift +↓CGRectInset(rect, 10, 5) +``` + +```swift +↓CGRectOffset(rect, -2, 8.3) +``` + +```swift +↓CGRectUnion(rect1, rect2) +``` + +```swift +↓CGRectIntersection(rect1, rect2) +``` + +```swift +↓CGRectContainsRect(rect1, rect2) +``` + +```swift +↓CGRectContainsPoint(rect, point) +``` + +```swift +↓CGRectIntersectsRect(rect1, rect2) +``` \ No newline at end of file diff --git a/docs/description/legacy_constant.md b/docs/description/legacy_constant.md new file mode 100644 index 0000000..364cf7a --- /dev/null +++ b/docs/description/legacy_constant.md @@ -0,0 +1,95 @@ +# Legacy Constant + +Struct-scoped constants are preferred over legacy global constants. + +* **Identifier:** legacy_constant +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +CGRect.infinite +``` + +```swift +CGPoint.zero +``` + +```swift +CGRect.zero +``` + +```swift +CGSize.zero +``` + +```swift +NSPoint.zero +``` + +```swift +NSRect.zero +``` + +```swift +NSSize.zero +``` + +```swift +CGRect.null +``` + +```swift +CGFloat.pi +``` + +```swift +Float.pi +``` + +## Triggering Examples + +```swift +↓CGRectInfinite +``` + +```swift +↓CGPointZero +``` + +```swift +↓CGRectZero +``` + +```swift +↓CGSizeZero +``` + +```swift +↓NSZeroPoint +``` + +```swift +↓NSZeroRect +``` + +```swift +↓NSZeroSize +``` + +```swift +↓CGRectNull +``` + +```swift +↓CGFloat(M_PI) +``` + +```swift +↓Float(M_PI) +``` \ No newline at end of file diff --git a/docs/description/legacy_constructor.md b/docs/description/legacy_constructor.md new file mode 100644 index 0000000..e7be026 --- /dev/null +++ b/docs/description/legacy_constructor.md @@ -0,0 +1,201 @@ +# Legacy Constructor + +Swift constructors are preferred over legacy convenience functions. + +* **Identifier:** legacy_constructor +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +CGPoint(x: 10, y: 10) +``` + +```swift +CGPoint(x: xValue, y: yValue) +``` + +```swift +CGSize(width: 10, height: 10) +``` + +```swift +CGSize(width: aWidth, height: aHeight) +``` + +```swift +CGRect(x: 0, y: 0, width: 10, height: 10) +``` + +```swift +CGRect(x: xVal, y: yVal, width: aWidth, height: aHeight) +``` + +```swift +CGVector(dx: 10, dy: 10) +``` + +```swift +CGVector(dx: deltaX, dy: deltaY) +``` + +```swift +NSPoint(x: 10, y: 10) +``` + +```swift +NSPoint(x: xValue, y: yValue) +``` + +```swift +NSSize(width: 10, height: 10) +``` + +```swift +NSSize(width: aWidth, height: aHeight) +``` + +```swift +NSRect(x: 0, y: 0, width: 10, height: 10) +``` + +```swift +NSRect(x: xVal, y: yVal, width: aWidth, height: aHeight) +``` + +```swift +NSRange(location: 10, length: 1) +``` + +```swift +NSRange(location: loc, length: len) +``` + +```swift +UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 10) +``` + +```swift +UIEdgeInsets(top: aTop, left: aLeft, bottom: aBottom, right: aRight) +``` + +```swift +NSEdgeInsets(top: 0, left: 0, bottom: 10, right: 10) +``` + +```swift +NSEdgeInsets(top: aTop, left: aLeft, bottom: aBottom, right: aRight) +``` + +```swift +UIOffset(horizontal: 0, vertical: 10) +``` + +```swift +UIOffset(horizontal: horizontal, vertical: vertical) +``` + +## Triggering Examples + +```swift +↓CGPointMake(10, 10) +``` + +```swift +↓CGPointMake(xVal, yVal) +``` + +```swift +↓CGPointMake(calculateX(), 10) + +``` + +```swift +↓CGSizeMake(10, 10) +``` + +```swift +↓CGSizeMake(aWidth, aHeight) +``` + +```swift +↓CGRectMake(0, 0, 10, 10) +``` + +```swift +↓CGRectMake(xVal, yVal, width, height) +``` + +```swift +↓CGVectorMake(10, 10) +``` + +```swift +↓CGVectorMake(deltaX, deltaY) +``` + +```swift +↓NSMakePoint(10, 10) +``` + +```swift +↓NSMakePoint(xVal, yVal) +``` + +```swift +↓NSMakeSize(10, 10) +``` + +```swift +↓NSMakeSize(aWidth, aHeight) +``` + +```swift +↓NSMakeRect(0, 0, 10, 10) +``` + +```swift +↓NSMakeRect(xVal, yVal, width, height) +``` + +```swift +↓NSMakeRange(10, 1) +``` + +```swift +↓NSMakeRange(loc, len) +``` + +```swift +↓UIEdgeInsetsMake(0, 0, 10, 10) +``` + +```swift +↓UIEdgeInsetsMake(top, left, bottom, right) +``` + +```swift +↓NSEdgeInsetsMake(0, 0, 10, 10) +``` + +```swift +↓NSEdgeInsetsMake(top, left, bottom, right) +``` + +```swift +↓CGVectorMake(10, 10) +↓NSMakeRange(10, 1) +``` + +```swift +↓UIOffsetMake(0, 10) +``` + +```swift +↓UIOffsetMake(horizontal, vertical) +``` \ No newline at end of file diff --git a/docs/description/legacy_hashing.md b/docs/description/legacy_hashing.md new file mode 100644 index 0000000..d69b183 --- /dev/null +++ b/docs/description/legacy_hashing.md @@ -0,0 +1,82 @@ +# Legacy Hashing + +Prefer using the `hash(into:)` function instead of overriding `hashValue` + +* **Identifier:** legacy_hashing +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.2.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +struct Foo: Hashable { + let bar: Int = 10 + + func hash(into hasher: inout Hasher) { + hasher.combine(bar) + } +} +``` + +```swift +class Foo: Hashable { + let bar: Int = 10 + + func hash(into hasher: inout Hasher) { + hasher.combine(bar) + } +} +``` + +```swift +var hashValue: Int { return 1 } +class Foo: Hashable { + } +``` + +```swift +class Foo: Hashable { + let bar: String = "Foo" + + public var hashValue: String { + return bar + } +} +``` + +```swift +class Foo: Hashable { + let bar: String = "Foo" + + public var hashValue: String { + get { return bar } + set { bar = newValue } + } +} +``` + +## Triggering Examples + +```swift +struct Foo: Hashable { + let bar: Int = 10 + + public ↓var hashValue: Int { + return bar + } +} +``` + +```swift +class Foo: Hashable { + let bar: Int = 10 + + public ↓var hashValue: Int { + return bar + } +} +``` \ No newline at end of file diff --git a/docs/description/legacy_multiple.md b/docs/description/legacy_multiple.md new file mode 100644 index 0000000..58670da --- /dev/null +++ b/docs/description/legacy_multiple.md @@ -0,0 +1,70 @@ +# Legacy Multiple + +Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`). + +* **Identifier:** legacy_multiple +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +cell.contentView.backgroundColor = indexPath.row.isMultiple(of: 2) ? .gray : .white +``` + +```swift +guard count.isMultiple(of: 2) else { throw DecodingError.dataCorrupted(...) } +``` + +```swift +sanityCheck(bytes > 0 && bytes.isMultiple(of: 4), "capacity must be multiple of 4 bytes") +``` + +```swift +guard let i = reversedNumbers.firstIndex(where: { $0.isMultiple(of: 2) }) else { return } +``` + +```swift +let constant = 56 +let isMultiple = value.isMultiple(of: constant) +``` + +```swift +let constant = 56 +let secret = value % constant == 5 +``` + +```swift +let secretValue = (value % 3) + 2 +``` + +## Triggering Examples + +```swift +cell.contentView.backgroundColor = indexPath.row ↓% 2 == 0 ? .gray : .white +``` + +```swift +cell.contentView.backgroundColor = indexPath.row ↓% 2 != 0 ? .gray : .white +``` + +```swift +guard count ↓% 2 == 0 else { throw DecodingError.dataCorrupted(...) } +``` + +```swift +sanityCheck(bytes > 0 && bytes ↓% 4 == 0, "capacity must be multiple of 4 bytes") +``` + +```swift +guard let i = reversedNumbers.firstIndex(where: { $0 ↓% 2 == 0 }) else { return } +``` + +```swift +let constant = 56 +let isMultiple = value ↓% constant == 0 +``` \ No newline at end of file diff --git a/docs/description/legacy_nsgeometry_functions.md b/docs/description/legacy_nsgeometry_functions.md new file mode 100644 index 0000000..d7ef78a --- /dev/null +++ b/docs/description/legacy_nsgeometry_functions.md @@ -0,0 +1,167 @@ +# Legacy NSGeometry Functions + +Struct extension properties and methods are preferred over legacy functions + +* **Identifier:** legacy_nsgeometry_functions +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +rect.width +``` + +```swift +rect.height +``` + +```swift +rect.minX +``` + +```swift +rect.midX +``` + +```swift +rect.maxX +``` + +```swift +rect.minY +``` + +```swift +rect.midY +``` + +```swift +rect.maxY +``` + +```swift +rect.isEmpty +``` + +```swift +rect.integral +``` + +```swift +rect.insetBy(dx: 5.0, dy: -7.0) +``` + +```swift +rect.offsetBy(dx: 5.0, dy: -7.0) +``` + +```swift +rect1.union(rect2) +``` + +```swift +rect1.intersect(rect2) +``` + +```swift +rect1.contains(rect2) +``` + +```swift +rect.contains(point) +``` + +```swift +rect1.intersects(rect2) +``` + +## Triggering Examples + +```swift +↓NSWidth(rect) +``` + +```swift +↓NSHeight(rect) +``` + +```swift +↓NSMinX(rect) +``` + +```swift +↓NSMidX(rect) +``` + +```swift +↓NSMaxX(rect) +``` + +```swift +↓NSMinY(rect) +``` + +```swift +↓NSMidY(rect) +``` + +```swift +↓NSMaxY(rect) +``` + +```swift +↓NSEqualRects(rect1, rect2) +``` + +```swift +↓NSEqualSizes(size1, size2) +``` + +```swift +↓NSEqualPoints(point1, point2) +``` + +```swift +↓NSEdgeInsetsEqual(insets2, insets2) +``` + +```swift +↓NSIsEmptyRect(rect) +``` + +```swift +↓NSIntegralRect(rect) +``` + +```swift +↓NSInsetRect(rect, 10, 5) +``` + +```swift +↓NSOffsetRect(rect, -2, 8.3) +``` + +```swift +↓NSUnionRect(rect1, rect2) +``` + +```swift +↓NSIntersectionRect(rect1, rect2) +``` + +```swift +↓NSContainsRect(rect1, rect2) +``` + +```swift +↓NSPointInRect(rect, point) +``` + +```swift +↓NSIntersectsRect(rect1, rect2) +``` \ No newline at end of file diff --git a/docs/description/legacy_random.md b/docs/description/legacy_random.md new file mode 100644 index 0000000..190b379 --- /dev/null +++ b/docs/description/legacy_random.md @@ -0,0 +1,45 @@ +# Legacy Random + +Prefer using `type.random(in:)` over legacy functions. + +* **Identifier:** legacy_random +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.2.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +Int.random(in: 0..<10) + +``` + +```swift +Double.random(in: 8.6...111.34) + +``` + +```swift +Float.random(in: 0 ..< 1) + +``` + +## Triggering Examples + +```swift +↓arc4random(10) + +``` + +```swift +↓arc4random_uniform(83) + +``` + +```swift +↓drand48(52) + +``` \ No newline at end of file diff --git a/docs/description/let_var_whitespace.md b/docs/description/let_var_whitespace.md new file mode 100644 index 0000000..181c27f --- /dev/null +++ b/docs/description/let_var_whitespace.md @@ -0,0 +1,171 @@ +# Variable Declaration Whitespace + +Let and var should be separated from other statements by a blank line. + +* **Identifier:** let_var_whitespace +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let a = 0 +var x = 1 + +x = 2 + +``` + +```swift +a = 5 + +var x = 1 + +``` + +```swift +struct X { + var a = 0 +} + +``` + +```swift +let a = 1 + + 2 +let b = 5 + +``` + +```swift +var x: Int { + return 0 +} + +``` + +```swift +var x: Int { + let a = 0 + + return a +} + +``` + +```swift +#if os(macOS) +let a = 0 +#endif + +``` + +```swift +#warning("TODO: remove it") +let a = 0 + +``` + +```swift +#error("TODO: remove it") +let a = 0 + +``` + +```swift +@available(swift 4) +let a = 0 + +``` + +```swift +class C { + @objc + var s: String = "" +} +``` + +```swift +class C { + @objc + func a() {} +} +``` + +```swift +class C { + var x = 0 + lazy + var y = 0 +} + +``` + +```swift +@available(OSX, introduced: 10.6) +@available(*, deprecated) +var x = 0 + +``` + +```swift +// swiftlint:disable superfluous_disable_command +// swiftlint:disable force_cast + +let x = bar as! Bar +``` + +```swift +var x: Int { + let a = 0 + return a +} + +``` + +## Triggering Examples + +```swift +var x = 1 +↓x = 2 + +``` + +```swift + +a = 5 +↓var x = 1 + +``` + +```swift +struct X { + let a + ↓func x() {} +} + +``` + +```swift +var x = 0 +↓@objc func f() {} + +``` + +```swift +var x = 0 +↓@objc + func f() {} + +``` + +```swift +@objc func f() { +} +↓var x = 0 + +``` \ No newline at end of file diff --git a/docs/description/line_length.md b/docs/description/line_length.md new file mode 100644 index 0000000..03315ce --- /dev/null +++ b/docs/description/line_length.md @@ -0,0 +1,45 @@ +# Line Length + +Lines should not span too many characters. + +* **Identifier:** line_length +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** metrics +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning: 120, error: 200, ignores urls: false, ignores function declarations: false, ignores comments: false, ignores interpolated strings: false + +## Non Triggering Examples + +```swift +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +``` + +```swift +#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1) + +``` + +```swift +#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg") + +``` + +## Triggering Examples + +```swift +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +``` + +```swift +#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1) + +``` + +```swift +#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg") + +``` \ No newline at end of file diff --git a/docs/description/literal_expression_end_indentation.md b/docs/description/literal_expression_end_indentation.md new file mode 100644 index 0000000..d1499c7 --- /dev/null +++ b/docs/description/literal_expression_end_indentation.md @@ -0,0 +1,82 @@ +# Literal Expression End Indentation + +Array and dictionary literal end should have the same indentation as the line that started it. + +* **Identifier:** literal_expression_end_indentation +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +[1, 2, 3] +``` + +```swift +[1, + 2 +] +``` + +```swift +[ + 1, + 2 +] +``` + +```swift +[ + 1, + 2] +``` + +```swift + let x = [ + 1, + 2 + ] +``` + +```swift +[key: 2, key2: 3] +``` + +```swift +[key: 1, + key2: 2 +] +``` + +```swift +[ + key: 0, + key2: 20 +] +``` + +## Triggering Examples + +```swift +let x = [ + 1, + 2 + ↓] +``` + +```swift + let x = [ + 1, + 2 +↓] +``` + +```swift +let x = [ + key: value + ↓] +``` \ No newline at end of file diff --git a/docs/description/lower_acl_than_parent.md b/docs/description/lower_acl_than_parent.md new file mode 100644 index 0000000..69059ea --- /dev/null +++ b/docs/description/lower_acl_than_parent.md @@ -0,0 +1,79 @@ +# Lower ACL than parent + +Ensure definitions have a lower access control level than their enclosing parent + +* **Identifier:** lower_acl_than_parent +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +public struct Foo { public func bar() {} } +``` + +```swift +internal struct Foo { func bar() {} } +``` + +```swift +struct Foo { func bar() {} } +``` + +```swift +open class Foo { public func bar() {} } +``` + +```swift +open class Foo { open func bar() {} } +``` + +```swift +fileprivate struct Foo { private func bar() {} } +``` + +```swift +private struct Foo { private func bar(id: String) } +``` + +```swift +extension Foo { public func bar() {} } +``` + +```swift +private struct Foo { fileprivate func bar() {} } +``` + +```swift +private func foo(id: String) {} +``` + +```swift +private class Foo { func bar() {} } +``` + +## Triggering Examples + +```swift +struct Foo { public ↓func bar() {} } +``` + +```swift +enum Foo { public ↓func bar() {} } +``` + +```swift +public class Foo { open ↓func bar() } +``` + +```swift +class Foo { public private(set) ↓var bar: String? } +``` + +```swift +private class Foo { internal ↓func bar() {} } +``` \ No newline at end of file diff --git a/docs/description/mark.md b/docs/description/mark.md new file mode 100644 index 0000000..b040f92 --- /dev/null +++ b/docs/description/mark.md @@ -0,0 +1,142 @@ +# Mark + +MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...' + +* **Identifier:** mark +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +// MARK: good + +``` + +```swift +// MARK: - good + +``` + +```swift +// MARK: - + +``` + +```swift +// BOOKMARK +``` + +```swift +//BOOKMARK +``` + +```swift +// BOOKMARKS +``` + +## Triggering Examples + +```swift +↓//MARK: bad +``` + +```swift +↓// MARK:bad +``` + +```swift +↓//MARK:bad +``` + +```swift +↓// MARK: bad +``` + +```swift +↓// MARK: bad +``` + +```swift +↓// MARK: -bad +``` + +```swift +↓// MARK:- bad +``` + +```swift +↓// MARK:-bad +``` + +```swift +↓//MARK: - bad +``` + +```swift +↓//MARK:- bad +``` + +```swift +↓//MARK: -bad +``` + +```swift +↓//MARK:-bad +``` + +```swift +↓//Mark: bad +``` + +```swift +↓// Mark: bad +``` + +```swift +↓// MARK bad +``` + +```swift +↓//MARK bad +``` + +```swift +↓// MARK - bad +``` + +```swift +↓//MARK : bad +``` + +```swift +↓// MARKL: +``` + +```swift +↓// MARKR +``` + +```swift +↓// MARKK - +``` + +```swift +↓/// MARK: +``` + +```swift +↓/// MARK bad +``` + +```swift +↓//MARK:- Top-Level bad mark +↓//MARK:- Another bad mark +struct MarkTest {} +↓// MARK:- Bad mark +extension MarkTest {} +``` \ No newline at end of file diff --git a/docs/description/missing_docs.md b/docs/description/missing_docs.md new file mode 100644 index 0000000..f26397f --- /dev/null +++ b/docs/description/missing_docs.md @@ -0,0 +1,73 @@ +# Missing Docs + +Declarations should be documented. + +* **Identifier:** missing_docs +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.1.0 +* **Default configuration:** warning: open, public + +## Non Triggering Examples + +```swift +/// docs +public class A { +/// docs +public func b() {} +} +/// docs +public class B: A { override public func b() {} } +``` + +```swift +import Foundation +/// docs +public class B: NSObject { +// no docs +override public var description: String { fatalError() } } +``` + +```swift +/// docs +public class A { + deinit {} +} +``` + +```swift +public extension A {} +``` + +## Triggering Examples + +```swift +public func a() {} + +``` + +```swift +// regular comment +public func a() {} + +``` + +```swift +/* regular comment */ +public func a() {} + +``` + +```swift +/// docs +public protocol A { +// no docs +var b: Int { get } } +/// docs +public struct C: A { + +public let b: Int +} +``` \ No newline at end of file diff --git a/docs/description/modifier_order.md b/docs/description/modifier_order.md new file mode 100644 index 0000000..f10644b --- /dev/null +++ b/docs/description/modifier_order.md @@ -0,0 +1,270 @@ +# Modifier Order + +Modifier order should be consistent. + +* **Identifier:** modifier_order +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.1.0 +* **Default configuration:** warning, preferred_modifier_order: [override, acl, setterACL, dynamic, mutators, lazy, final, required, convenience, typeMethods, owned] + +## Non Triggering Examples + +```swift +public class Foo { + public convenience required init() {} +} +``` + +```swift +public class Foo { + public static let bar = 42 +} +``` + +```swift +public class Foo { + public static var bar: Int { + return + } +} +``` + +```swift +public class Foo { + public class var bar: Int { + return 42 + } +} +``` + +```swift +public class Bar { + public class var foo: String { + return "foo" + } +} +public class Foo: Bar { + override public final class var foo: String { + return "bar" + } +} +``` + +```swift +open class Bar { + public var foo: Int? { + return 42 + } +} +open class Foo: Bar { + override public var foo: Int? { + return 43 + } +} +``` + +```swift +open class Bar { + open class func foo() -> Int { + return 42 + } +} +class Foo: Bar { + override open class func foo() -> Int { + return 43 + } +} +``` + +```swift +protocol Foo: class {} +class Bar { + public private(set) weak var foo: Foo? +} +``` + +```swift +@objc +public final class Foo: NSObject {} +``` + +```swift +@objcMembers +public final class Foo: NSObject {} +``` + +```swift +@objc +override public private(set) weak var foo: Bar? +``` + +```swift +@objc +public final class Foo: NSObject {} +``` + +```swift +@objc +open final class Foo: NSObject { + open weak var weakBar: NSString? = nil +} +``` + +```swift +public final class Foo {} +``` + +```swift +class Bar { + func bar() {} +} +``` + +```swift +internal class Foo: Bar { + override internal func bar() {} +} +``` + +```swift +public struct Foo { + internal weak var weakBar: NSObject? = nil +} +``` + +```swift +class Foo { + internal lazy var bar: String = "foo" +} +``` + +## Triggering Examples + +```swift +class Foo { + convenience required public init() {} +} +``` + +```swift +public class Foo { + static public let bar = 42 +} +``` + +```swift +public class Foo { + static public var bar: Int { + return 42 + } +} +``` + +```swift +public class Foo { + class public var bar: Int { + return 42 + } +} +``` + +```swift +public class RootFoo { + class public var foo: String { + return "foo" + } +} +public class Foo: RootFoo { + override final class public var foo: String + return "bar" + } +} +``` + +```swift +open class Bar { + public var foo: Int? { + return 42 + } +} +open class Foo: Bar { + public override var foo: Int? { + return 43 + } +} +``` + +```swift +protocol Foo: class {} + class Bar { + private(set) public weak var foo: Foo? +} +``` + +```swift +open class Bar { + open class func foo() -> Int { + return 42 + } +} +class Foo: Bar { + class open override func foo() -> Int { + return 43 + } +} +``` + +```swift +open class Bar { + open class func foo() -> Int { + return 42 + } +} +class Foo: Bar { + open override class func foo() -> Int { + return 43 + } +} +``` + +```swift +@objc +final public class Foo: NSObject {} +``` + +```swift +@objcMembers +final public class Foo: NSObject {} +``` + +```swift +@objc +final open class Foo: NSObject { + weak open var weakBar: NSString? = nil +} +``` + +```swift +final public class Foo {} +``` + +```swift +internal class Foo: Bar { + internal override func bar() {} +} +``` + +```swift +public struct Foo { + weak internal var weakBar: NSObjetc? = nil +} +``` + +```swift +class Foo { + lazy internal var bar: String = "foo" +} +``` \ No newline at end of file diff --git a/docs/description/multiline_arguments.md b/docs/description/multiline_arguments.md new file mode 100644 index 0000000..6f319d0 --- /dev/null +++ b/docs/description/multiline_arguments.md @@ -0,0 +1,118 @@ +# Multiline Arguments + +Arguments should be either on the same line, or one per line. + +* **Identifier:** multiline_arguments +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, first_argument_location: any_line, only_enforce_after_first_closure_on_first_line: false + +## Non Triggering Examples + +```swift +foo() +``` + +```swift +foo( +) +``` + +```swift +foo { } +``` + +```swift +foo { + +} +``` + +```swift +foo(0) +``` + +```swift +foo(0, 1) +``` + +```swift +foo(0, 1) { } +``` + +```swift +foo(0, param1: 1) +``` + +```swift +foo(0, param1: 1) { } +``` + +```swift +foo(param1: 1) +``` + +```swift +foo(param1: 1) { } +``` + +```swift +foo(param1: 1, param2: true) { } +``` + +```swift +foo(param1: 1, param2: true, param3: [3]) { } +``` + +```swift +foo(param1: 1, param2: true, param3: [3]) { + bar() +} +``` + +```swift +foo(param1: 1, + param2: true, + param3: [3]) +``` + +```swift +foo( + param1: 1, param2: true, param3: [3] +) +``` + +```swift +foo( + param1: 1, + param2: true, + param3: [3] +) +``` + +## Triggering Examples + +```swift +foo(0, + param1: 1, ↓param2: true, ↓param3: [3]) +``` + +```swift +foo(0, ↓param1: 1, + param2: true, ↓param3: [3]) +``` + +```swift +foo(0, ↓param1: 1, ↓param2: true, + param3: [3]) +``` + +```swift +foo( + 0, ↓param1: 1, + param2: true, ↓param3: [3] +) +``` \ No newline at end of file diff --git a/docs/description/multiline_arguments_brackets.md b/docs/description/multiline_arguments_brackets.md new file mode 100644 index 0000000..c7fe99a --- /dev/null +++ b/docs/description/multiline_arguments_brackets.md @@ -0,0 +1,83 @@ +# Multiline Arguments Brackets + +Multiline arguments should have their surrounding brackets in a new line. + +* **Identifier:** multiline_arguments_brackets +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +foo(param1: "Param1", param2: "Param2", param3: "Param3") +``` + +```swift +foo( + param1: "Param1", param2: "Param2", param3: "Param3" +) +``` + +```swift +func foo( + param1: "Param1", + param2: "Param2", + param3: "Param3" +) +``` + +```swift +foo { param1, param2 in + print("hello world") +} +``` + +```swift +foo( + bar( + x: 5, + y: 7 + ) +) +``` + +```swift +AlertViewModel.AlertAction(title: "some title", style: .default) { + AlertManager.shared.presentNextDebugAlert() +} +``` + +## Triggering Examples + +```swift +foo(↓param1: "Param1", param2: "Param2", + param3: "Param3" +) +``` + +```swift +foo( + param1: "Param1", + param2: "Param2", + param3: "Param3"↓) +``` + +```swift +foo(↓bar( + x: 5, + y: 7 +) +) +``` + +```swift +foo( + bar( + x: 5, + y: 7 +)↓) +``` \ No newline at end of file diff --git a/docs/description/multiline_function_chains.md b/docs/description/multiline_function_chains.md new file mode 100644 index 0000000..9d9f24b --- /dev/null +++ b/docs/description/multiline_function_chains.md @@ -0,0 +1,110 @@ +# Multiline Function Chains + +Chained function calls should be either on the same line, or one per line. + +* **Identifier:** multiline_function_chains +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let evenSquaresSum = [20, 17, 35, 4].filter { $0 % 2 == 0 }.map { $0 * $0 }.reduce(0, +) +``` + +```swift +let evenSquaresSum = [20, 17, 35, 4] + .filter { $0 % 2 == 0 }.map { $0 * $0 }.reduce(0, +)", +``` + +```swift +let chain = a + .b(1, 2, 3) + .c { blah in + print(blah) + } + .d() +``` + +```swift +let chain = a.b(1, 2, 3) + .c { blah in + print(blah) + } + .d() +``` + +```swift +let chain = a.b(1, 2, 3) + .c { blah in print(blah) } + .d() +``` + +```swift +let chain = a.b(1, 2, 3) + .c(.init( + a: 1, + b, 2, + c, 3)) + .d() +``` + +```swift +self.viewModel.outputs.postContextualNotification + .observeForUI() + .observeValues { + NotificationCenter.default.post( + Notification( + name: .ksr_showNotificationsDialog, + userInfo: [UserInfoKeys.context: PushNotificationDialog.Context.pledge, + UserInfoKeys.viewController: self] + ) + ) + } +``` + +```swift +let remainingIDs = Array(Set(self.currentIDs).subtracting(Set(response.ids))) +``` + +```swift +self.happeningNewsletterOn = self.updateCurrentUser + .map { $0.newsletters.happening }.skipNil().skipRepeats() +``` + +## Triggering Examples + +```swift +let evenSquaresSum = [20, 17, 35, 4] + .filter { $0 % 2 == 0 }↓.map { $0 * $0 } + .reduce(0, +) +``` + +```swift +let evenSquaresSum = a.b(1, 2, 3) + .c { blah in + print(blah) + }↓.d() +``` + +```swift +let evenSquaresSum = a.b(1, 2, 3) + .c(2, 3, 4)↓.d() +``` + +```swift +let evenSquaresSum = a.b(1, 2, 3)↓.c { blah in + print(blah) + } + .d() +``` + +```swift +a.b { +// ““ +}↓.e() +``` \ No newline at end of file diff --git a/docs/description/multiline_literal_brackets.md b/docs/description/multiline_literal_brackets.md new file mode 100644 index 0000000..e941e5f --- /dev/null +++ b/docs/description/multiline_literal_brackets.md @@ -0,0 +1,106 @@ +# Multiline Literal Brackets + +Multiline literals should have their surrounding brackets in a new line. + +* **Identifier:** multiline_literal_brackets +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let trio = ["harry", "ronald", "hermione"] +let houseCup = ["gryffinder": 460, "hufflepuff": 370, "ravenclaw": 410, "slytherin": 450] +``` + +```swift +let trio = [ + "harry", + "ronald", + "hermione" +] +let houseCup = [ + "gryffinder": 460, + "hufflepuff": 370, + "ravenclaw": 410, + "slytherin": 450 +] +``` + +```swift +let trio = [ + "harry", "ronald", "hermione" +] +let houseCup = [ + "gryffinder": 460, "hufflepuff": 370, + "ravenclaw": 410, "slytherin": 450 +] +``` + +```swift + _ = [ + 1, + 2, + 3, + 4, + 5, 6, + 7, 8, 9 + ] +``` + +## Triggering Examples + +```swift +let trio = [↓"harry", + "ronald", + "hermione" +] +``` + +```swift +let houseCup = [↓"gryffinder": 460, "hufflepuff": 370, + "ravenclaw": 410, "slytherin": 450 +] +``` + +```swift +let trio = [ + "harry", + "ronald", + "hermione"↓] +``` + +```swift +let houseCup = [ + "gryffinder": 460, "hufflepuff": 370, + "ravenclaw": 410, "slytherin": 450↓] +``` + +```swift +class Hogwarts { + let houseCup = [ + "gryffinder": 460, "hufflepuff": 370, + "ravenclaw": 410, "slytherin": 450↓] +} +``` + +```swift + _ = [ + 1, + 2, + 3, + 4, + 5, 6, + 7, 8, 9↓] +``` + +```swift + _ = [↓1, 2, 3, + 4, 5, 6, + 7, 8, 9 + ] +``` \ No newline at end of file diff --git a/docs/description/multiline_parameters.md b/docs/description/multiline_parameters.md new file mode 100644 index 0000000..2312b87 --- /dev/null +++ b/docs/description/multiline_parameters.md @@ -0,0 +1,474 @@ +# Multiline Parameters + +Functions and methods parameters should be either on the same line, or one per line. + +* **Identifier:** multiline_parameters +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func foo() { } +``` + +```swift +func foo(param1: Int) { } +``` + +```swift +func foo(param1: Int, param2: Bool) { } +``` + +```swift +func foo(param1: Int, param2: Bool, param3: [String]) { } +``` + +```swift +func foo(param1: Int, + param2: Bool, + param3: [String]) { } +``` + +```swift +func foo(_ param1: Int, param2: Int, param3: Int) -> (Int) -> Int { + return { x in x + param1 + param2 + param3 } +} +``` + +```swift +static func foo() { } +``` + +```swift +static func foo(param1: Int) { } +``` + +```swift +static func foo(param1: Int, param2: Bool) { } +``` + +```swift +static func foo(param1: Int, param2: Bool, param3: [String]) { } +``` + +```swift +static func foo(param1: Int, + param2: Bool, + param3: [String]) { } +``` + +```swift +protocol Foo { + func foo() { } +} +``` + +```swift +protocol Foo { + func foo(param1: Int) { } +} +``` + +```swift +protocol Foo { + func foo(param1: Int, param2: Bool) { } +} +``` + +```swift +protocol Foo { + func foo(param1: Int, param2: Bool, param3: [String]) { } +} +``` + +```swift +protocol Foo { + func foo(param1: Int, + param2: Bool, + param3: [String]) { } +} +``` + +```swift +protocol Foo { + static func foo(param1: Int, param2: Bool, param3: [String]) { } +} +``` + +```swift +protocol Foo { + static func foo(param1: Int, + param2: Bool, + param3: [String]) { } +} +``` + +```swift +protocol Foo { + class func foo(param1: Int, param2: Bool, param3: [String]) { } +} +``` + +```swift +protocol Foo { + class func foo(param1: Int, + param2: Bool, + param3: [String]) { } +} +``` + +```swift +enum Foo { + func foo() { } +} +``` + +```swift +enum Foo { + func foo(param1: Int) { } +} +``` + +```swift +enum Foo { + func foo(param1: Int, param2: Bool) { } +} +``` + +```swift +enum Foo { + func foo(param1: Int, param2: Bool, param3: [String]) { } +} +``` + +```swift +enum Foo { + func foo(param1: Int, + param2: Bool, + param3: [String]) { } +} +``` + +```swift +enum Foo { + static func foo(param1: Int, param2: Bool, param3: [String]) { } +} +``` + +```swift +enum Foo { + static func foo(param1: Int, + param2: Bool, + param3: [String]) { } +} +``` + +```swift +struct Foo { + func foo() { } +} +``` + +```swift +struct Foo { + func foo(param1: Int) { } +} +``` + +```swift +struct Foo { + func foo(param1: Int, param2: Bool) { } +} +``` + +```swift +struct Foo { + func foo(param1: Int, param2: Bool, param3: [String]) { } +} +``` + +```swift +struct Foo { + func foo(param1: Int, + param2: Bool, + param3: [String]) { } +} +``` + +```swift +struct Foo { + static func foo(param1: Int, param2: Bool, param3: [String]) { } +} +``` + +```swift +struct Foo { + static func foo(param1: Int, + param2: Bool, + param3: [String]) { } +} +``` + +```swift +class Foo { + func foo() { } +} +``` + +```swift +class Foo { + func foo(param1: Int) { } +} +``` + +```swift +class Foo { + func foo(param1: Int, param2: Bool) { } +} +``` + +```swift +class Foo { + func foo(param1: Int, param2: Bool, param3: [String]) { } + } +``` + +```swift +class Foo { + func foo(param1: Int, + param2: Bool, + param3: [String]) { } +} +``` + +```swift +class Foo { + class func foo(param1: Int, param2: Bool, param3: [String]) { } +} +``` + +```swift +class Foo { + class func foo(param1: Int, + param2: Bool, + param3: [String]) { } +} +``` + +```swift +class Foo { + class func foo(param1: Int, + param2: Bool, + param3: @escaping (Int, Int) -> Void = { _, _ in }) { } +} +``` + +```swift +class Foo { + class func foo(param1: Int, + param2: Bool, + param3: @escaping (Int) -> Void = { _ in }) { } +} +``` + +```swift +class Foo { + class func foo(param1: Int, + param2: Bool, + param3: @escaping ((Int) -> Void)? = nil) { } +} +``` + +```swift +class Foo { + class func foo(param1: Int, + param2: Bool, + param3: @escaping ((Int) -> Void)? = { _ in }) { } +} +``` + +```swift +class Foo { + class func foo(param1: Int, + param2: @escaping ((Int) -> Void)? = { _ in }, + param3: Bool) { } +} +``` + +```swift +class Foo { + class func foo(param1: Int, + param2: @escaping ((Int) -> Void)? = { _ in }, + param3: @escaping (Int, Int) -> Void = { _, _ in }) { } +} +``` + +```swift +class Foo { + class func foo(param1: Int, + param2: Bool, + param3: @escaping (Int) -> Void = { (x: Int) in }) { } +} +``` + +```swift +class Foo { + class func foo(param1: Int, + param2: Bool, + param3: @escaping (Int, (Int) -> Void) -> Void = { (x: Int, f: (Int) -> Void) in }) { } +} +``` + +## Triggering Examples + +```swift +func ↓foo(_ param1: Int, + param2: Int, param3: Int) -> (Int) -> Int { + return { x in x + param1 + param2 + param3 } +} +``` + +```swift +protocol Foo { + func ↓foo(param1: Int, + param2: Bool, param3: [String]) { } +} +``` + +```swift +protocol Foo { + func ↓foo(param1: Int, param2: Bool, + param3: [String]) { } +} +``` + +```swift +protocol Foo { + static func ↓foo(param1: Int, + param2: Bool, param3: [String]) { } +} +``` + +```swift +protocol Foo { + static func ↓foo(param1: Int, param2: Bool, + param3: [String]) { } +} +``` + +```swift +protocol Foo { + class func ↓foo(param1: Int, + param2: Bool, param3: [String]) { } +} +``` + +```swift +protocol Foo { + class func ↓foo(param1: Int, param2: Bool, + param3: [String]) { } +} +``` + +```swift +enum Foo { + func ↓foo(param1: Int, + param2: Bool, param3: [String]) { } +} +``` + +```swift +enum Foo { + func ↓foo(param1: Int, param2: Bool, + param3: [String]) { } +} +``` + +```swift +enum Foo { + static func ↓foo(param1: Int, + param2: Bool, param3: [String]) { } +} +``` + +```swift +enum Foo { + static func ↓foo(param1: Int, param2: Bool, + param3: [String]) { } +} +``` + +```swift +struct Foo { + func ↓foo(param1: Int, + param2: Bool, param3: [String]) { } +} +``` + +```swift +struct Foo { + func ↓foo(param1: Int, param2: Bool, + param3: [String]) { } +} +``` + +```swift +struct Foo { + static func ↓foo(param1: Int, + param2: Bool, param3: [String]) { } +} +``` + +```swift +struct Foo { + static func ↓foo(param1: Int, param2: Bool, + param3: [String]) { } +} +``` + +```swift +class Foo { + func ↓foo(param1: Int, + param2: Bool, param3: [String]) { } +} +``` + +```swift +class Foo { + func ↓foo(param1: Int, param2: Bool, + param3: [String]) { } +} +``` + +```swift +class Foo { + class func ↓foo(param1: Int, + param2: Bool, param3: [String]) { } +} +``` + +```swift +class Foo { + class func ↓foo(param1: Int, param2: Bool, + param3: [String]) { } +} +``` + +```swift +class Foo { + class func ↓foo(param1: Int, + param2: Bool, param3: @escaping (Int, Int) -> Void = { _, _ in }) { } +} +``` + +```swift +class Foo { + class func ↓foo(param1: Int, + param2: Bool, param3: @escaping (Int) -> Void = { (x: Int) in }) { } +} +``` \ No newline at end of file diff --git a/docs/description/multiline_parameters_brackets.md b/docs/description/multiline_parameters_brackets.md new file mode 100644 index 0000000..eedf87a --- /dev/null +++ b/docs/description/multiline_parameters_brackets.md @@ -0,0 +1,97 @@ +# Multiline Parameters Brackets + +Multiline parameters should have their surrounding brackets in a new line. + +* **Identifier:** multiline_parameters_brackets +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func foo(param1: String, param2: String, param3: String) +``` + +```swift +func foo( + param1: String, param2: String, param3: String +) +``` + +```swift +func foo( + param1: String, + param2: String, + param3: String +) +``` + +```swift +class SomeType { + func foo(param1: String, param2: String, param3: String) +} +``` + +```swift +class SomeType { + func foo( + param1: String, param2: String, param3: String + ) +} +``` + +```swift +class SomeType { + func foo( + param1: String, + param2: String, + param3: String + ) +} +``` + +```swift +func foo(param1: T, param2: String, param3: String) -> T { /* some code */ } +``` + +## Triggering Examples + +```swift +func foo(↓param1: String, param2: String, + param3: String +) +``` + +```swift +func foo( + param1: String, + param2: String, + param3: String↓) +``` + +```swift +class SomeType { + func foo(↓param1: String, param2: String, + param3: String + ) +} +``` + +```swift +class SomeType { + func foo( + param1: String, + param2: String, + param3: String↓) +} +``` + +```swift +func foo(↓param1: T, param2: String, + param3: String +) -> T +``` \ No newline at end of file diff --git a/docs/description/multiple_closures_with_trailing_closure.md b/docs/description/multiple_closures_with_trailing_closure.md new file mode 100644 index 0000000..f43f031 --- /dev/null +++ b/docs/description/multiple_closures_with_trailing_closure.md @@ -0,0 +1,55 @@ +# Multiple Closures with Trailing Closure + +Trailing closure syntax should not be used when passing more than one closure argument. + +* **Identifier:** multiple_closures_with_trailing_closure +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +foo.map { $0 + 1 } + +``` + +```swift +foo.reduce(0) { $0 + $1 } + +``` + +```swift +if let foo = bar.map({ $0 + 1 }) { + +} + +``` + +```swift +foo.something(param1: { $0 }, param2: { $0 + 1 }) + +``` + +```swift +UIView.animate(withDuration: 1.0) { + someView.alpha = 0.0 +} +``` + +## Triggering Examples + +```swift +foo.something(param1: { $0 }) ↓{ $0 + 1 } +``` + +```swift +UIView.animate(withDuration: 1.0, animations: { + someView.alpha = 0.0 +}) ↓{ _ in + someView.removeFromSuperview() +} +``` \ No newline at end of file diff --git a/docs/description/nesting.md b/docs/description/nesting.md new file mode 100644 index 0000000..3ada1cc --- /dev/null +++ b/docs/description/nesting.md @@ -0,0 +1,111 @@ +# Nesting + +Types should be nested at most 1 level deep, and statements should be nested at most 5 levels deep. + +* **Identifier:** nesting +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** metrics +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** (type_level) w: 1, (statement_level) w: 5 + +## Non Triggering Examples + +```swift +class Class0 { class Class1 {} } + +``` + +```swift +func func0() { + func func1() { + func func2() { + func func3() { + func func4() { + func func5() { + } + } + } + } + } +} +``` + +```swift +struct Class0 { struct Class1 {} } + +``` + +```swift +func func0() { + func func1() { + func func2() { + func func3() { + func func4() { + func func5() { + } + } + } + } + } +} +``` + +```swift +enum Class0 { enum Class1 {} } + +``` + +```swift +func func0() { + func func1() { + func func2() { + func func3() { + func func4() { + func func5() { + } + } + } + } + } +} +``` + +```swift +enum Enum0 { enum Enum1 { case Case } } +``` + +## Triggering Examples + +```swift +class A { class B { ↓class C {} } } + +``` + +```swift +struct A { struct B { ↓struct C {} } } + +``` + +```swift +enum A { enum B { ↓enum C {} } } + +``` + +```swift +func func0() { + func func1() { + func func2() { + func func3() { + func func4() { + func func5() { + ↓func func6() { + } + } + } + } + } + } +} +``` \ No newline at end of file diff --git a/docs/description/nimble_operator.md b/docs/description/nimble_operator.md new file mode 100644 index 0000000..b8dfe98 --- /dev/null +++ b/docs/description/nimble_operator.md @@ -0,0 +1,135 @@ +# Nimble Operator + +Prefer Nimble operator overloads over free matcher functions. + +* **Identifier:** nimble_operator +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +expect(seagull.squawk) != "Hi!" + +``` + +```swift +expect("Hi!") == "Hi!" + +``` + +```swift +expect(10) > 2 + +``` + +```swift +expect(10) >= 10 + +``` + +```swift +expect(10) < 11 + +``` + +```swift +expect(10) <= 10 + +``` + +```swift +expect(x) === x +``` + +```swift +expect(10) == 10 +``` + +```swift +expect(success) == true +``` + +```swift +expect(object.asyncFunction()).toEventually(equal(1)) + +``` + +```swift +expect(actual).to(haveCount(expected)) + +``` + +```swift +foo.method { + expect(value).to(equal(expectedValue), description: "Failed") + return Bar(value: ()) +} +``` + +## Triggering Examples + +```swift +↓expect(seagull.squawk).toNot(equal("Hi")) + +``` + +```swift +↓expect(12).toNot(equal(10)) + +``` + +```swift +↓expect(10).to(equal(10)) + +``` + +```swift +↓expect(10, line: 1).to(equal(10)) + +``` + +```swift +↓expect(10).to(beGreaterThan(8)) + +``` + +```swift +↓expect(10).to(beGreaterThanOrEqualTo(10)) + +``` + +```swift +↓expect(10).to(beLessThan(11)) + +``` + +```swift +↓expect(10).to(beLessThanOrEqualTo(10)) + +``` + +```swift +↓expect(x).to(beIdenticalTo(x)) + +``` + +```swift +↓expect(success).to(beTrue()) + +``` + +```swift +↓expect(success).to(beFalse()) + +``` + +```swift +expect(10) > 2 + ↓expect(10).to(beGreaterThan(2)) + +``` \ No newline at end of file diff --git a/docs/description/no_extension_access_modifier.md b/docs/description/no_extension_access_modifier.md new file mode 100644 index 0000000..86bf5bf --- /dev/null +++ b/docs/description/no_extension_access_modifier.md @@ -0,0 +1,46 @@ +# No Extension Access Modifier + +Prefer not to use extension access modifiers + +* **Identifier:** no_extension_access_modifier +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** error + +## Non Triggering Examples + +```swift +extension String {} +``` + +```swift + + + extension String {} +``` + +## Triggering Examples + +```swift +↓private extension String {} +``` + +```swift +↓public + extension String {} +``` + +```swift +↓open extension String {} +``` + +```swift +↓internal extension String {} +``` + +```swift +↓fileprivate extension String {} +``` \ No newline at end of file diff --git a/docs/description/no_fallthrough_only.md b/docs/description/no_fallthrough_only.md new file mode 100644 index 0000000..b4329c7 --- /dev/null +++ b/docs/description/no_fallthrough_only.md @@ -0,0 +1,183 @@ +# No Fallthrough Only + +Fallthroughs can only be used if the `case` contains at least one other statement. + +* **Identifier:** no_fallthrough_only +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +switch myvar { +case 1: + var a = 1 + fallthrough +case 2: + var a = 2 +} +``` + +```swift +switch myvar { +case "a": + var one = 1 + var two = 2 + fallthrough +case "b": /* comment */ + var three = 3 +} +``` + +```swift +switch myvar { +case 1: + let one = 1 +case 2: + // comment + var two = 2 +} +``` + +```swift +switch myvar { +case MyFunc(x: [1, 2, YourFunc(a: 23)], y: 2): + var three = 3 + fallthrough +default: + var three = 4 +} +``` + +```swift +switch myvar { +case .alpha: + var one = 1 +case .beta: + var three = 3 + fallthrough +default: + var four = 4 +} +``` + +```swift +let aPoint = (1, -1) +switch aPoint { +case let (x, y) where x == y: + let A = "A" +case let (x, y) where x == -y: + let B = "B" + fallthrough +default: + let C = "C" +} +``` + +```swift +switch myvar { +case MyFun(with: { $1 }): + let one = 1 + fallthrough +case "abc": + let two = 2 +} +``` + +```swift +switch enumInstance { +case .caseA: + print("it's a") +case .caseB: + fallthrough +@unknown default: + print("it's not a") +} +``` + +## Triggering Examples + +```swift +switch myvar { +case 1: + ↓fallthrough +case 2: + var a = 1 +} +``` + +```swift +switch myvar { +case 1: + var a = 2 +case 2: + ↓fallthrough +case 3: + var a = 3 +} +``` + +```swift +switch myvar { +case 1: // comment + ↓fallthrough +} +``` + +```swift +switch myvar { +case 1: /* multi + line + comment */ + ↓fallthrough +case 2: + var a = 2 +} +``` + +```swift +switch myvar { +case MyFunc(x: [1, 2, YourFunc(a: 23)], y: 2): + ↓fallthrough +default: + var three = 4 +} +``` + +```swift +switch myvar { +case .alpha: + var one = 1 +case .beta: + ↓fallthrough +case .gamma: + var three = 3 +default: + var four = 4 +} +``` + +```swift +let aPoint = (1, -1) +switch aPoint { +case let (x, y) where x == y: + let A = "A" +case let (x, y) where x == -y: + ↓fallthrough +default: + let B = "B" +} +``` + +```swift +switch myvar { +case MyFun(with: { $1 }): + ↓fallthrough +case "abc": + let two = 2 +} +``` \ No newline at end of file diff --git a/docs/description/no_grouping_extension.md b/docs/description/no_grouping_extension.md new file mode 100644 index 0000000..afb22c0 --- /dev/null +++ b/docs/description/no_grouping_extension.md @@ -0,0 +1,57 @@ +# No Grouping Extension + +Extensions shouldn't be used to group code within the same source file. + +* **Identifier:** no_grouping_extension +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +protocol Food {} +extension Food {} + +``` + +```swift +class Apples {} +extension Oranges {} + +``` + +```swift +class Box {} +extension Box where T: Vegetable {} + +``` + +## Triggering Examples + +```swift +enum Fruit {} +↓extension Fruit {} + +``` + +```swift +↓extension Tea: Error {} +struct Tea {} + +``` + +```swift +class Ham { class Spam {}} +↓extension Ham.Spam {} + +``` + +```swift +extension External { struct Gotcha {}} +↓extension External.Gotcha {} + +``` \ No newline at end of file diff --git a/docs/description/no_space_in_method_call.md b/docs/description/no_space_in_method_call.md new file mode 100644 index 0000000..cef56d4 --- /dev/null +++ b/docs/description/no_space_in_method_call.md @@ -0,0 +1,67 @@ +# No Space in Method Call + +Don't add a space between the method name and the parentheses. + +* **Identifier:** no_space_in_method_call +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.2.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +foo() +``` + +```swift +object.foo() +``` + +```swift +object.foo(1) +``` + +```swift +object.foo(value: 1) +``` + +```swift +object.foo { print($0 } +``` + +```swift +list.sorted { $0.0 < $1.0 }.map { $0.value } +``` + +```swift +self.init(rgb: (Int) (colorInt)) +``` + +## Triggering Examples + +```swift +foo↓ () +``` + +```swift +object.foo↓ () +``` + +```swift +object.foo↓ (1) +``` + +```swift +object.foo↓ (value: 1) +``` + +```swift +object.foo↓ () {} +``` + +```swift +object.foo↓ () +``` \ No newline at end of file diff --git a/docs/description/notification_center_detachment.md b/docs/description/notification_center_detachment.md new file mode 100644 index 0000000..446bb84 --- /dev/null +++ b/docs/description/notification_center_detachment.md @@ -0,0 +1,39 @@ +# Notification Center Detachment + +An object should only remove itself as an observer in `deinit`. + +* **Identifier:** notification_center_detachment +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class Foo { + deinit { + NotificationCenter.default.removeObserver(self) + } +} +``` + +```swift +class Foo { + func bar() { + NotificationCenter.default.removeObserver(otherObject) + } +} +``` + +## Triggering Examples + +```swift +class Foo { + func bar() { + ↓NotificationCenter.default.removeObserver(self) + } +} +``` \ No newline at end of file diff --git a/docs/description/nslocalizedstring_key.md b/docs/description/nslocalizedstring_key.md new file mode 100644 index 0000000..e8b64e0 --- /dev/null +++ b/docs/description/nslocalizedstring_key.md @@ -0,0 +1,31 @@ +# NSLocalizedString Key + +Static strings should be used as key in NSLocalizedString in order to genstrings work. + +* **Identifier:** nslocalizedstring_key +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +NSLocalizedString("key", comment: nil) +``` + +```swift +NSLocalizedString("key" + "2", comment: nil) +``` + +## Triggering Examples + +```swift +NSLocalizedString(↓method(), comment: nil) +``` + +```swift +NSLocalizedString(↓"key_\(param)", comment: nil) +``` \ No newline at end of file diff --git a/docs/description/nslocalizedstring_require_bundle.md b/docs/description/nslocalizedstring_require_bundle.md new file mode 100644 index 0000000..2fabf63 --- /dev/null +++ b/docs/description/nslocalizedstring_require_bundle.md @@ -0,0 +1,48 @@ +# NSLocalizedString Require Bundle + +Calls to NSLocalizedString should specify the bundle which contains the strings file. + +* **Identifier:** nslocalizedstring_require_bundle +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +NSLocalizedString("someKey", bundle: .main, comment: "test") +``` + +```swift +NSLocalizedString("someKey", tableName: "a", + bundle: Bundle(for: A.self), + comment: "test") +``` + +```swift +NSLocalizedString("someKey", tableName: "xyz", + bundle: someBundle, value: "test" + comment: "test") +``` + +```swift +arbitraryFunctionCall("something") +``` + +## Triggering Examples + +```swift +↓NSLocalizedString("someKey", comment: "test") +``` + +```swift +↓NSLocalizedString("someKey", tableName: "a", comment: "test") +``` + +```swift +↓NSLocalizedString("someKey", tableName: "xyz", + value: "test", comment: "test") +``` \ No newline at end of file diff --git a/docs/description/nsobject_prefer_isequal.md b/docs/description/nsobject_prefer_isequal.md new file mode 100644 index 0000000..2a106aa --- /dev/null +++ b/docs/description/nsobject_prefer_isequal.md @@ -0,0 +1,111 @@ +# NSObject Prefer isEqual + +NSObject subclasses should implement isEqual instead of ==. + +* **Identifier:** nsobject_prefer_isequal +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class AClass: NSObject { +} +``` + +```swift +@objc class AClass: SomeNSObjectSubclass { +} +``` + +```swift +class AClass: Equatable { + static func ==(lhs: AClass, rhs: AClass) -> Bool { + return true + } +``` + +```swift +class AClass: NSObject { + override func isEqual(_ object: Any?) -> Bool { + return true + } +} +``` + +```swift +@objc class AClass: SomeNSObjectSubclass { + override func isEqual(_ object: Any?) -> Bool { + return false + } +} +``` + +```swift +class AClass: NSObject { + static func ==(lhs: AClass, rhs: BClass) -> Bool { + return true + } +} +``` + +```swift +struct AStruct: Equatable { + static func ==(lhs: AStruct, rhs: AStruct) -> Bool { + return false + } +} +``` + +```swift +enum AnEnum: Equatable { + static func ==(lhs: AnEnum, rhs: AnEnum) -> Bool { + return true + } +} +``` + +## Triggering Examples + +```swift +class AClass: NSObject { + ↓static func ==(lhs: AClass, rhs: AClass) -> Bool { + return false + } +} +``` + +```swift +@objc class AClass: SomeOtherNSObjectSubclass { + ↓static func ==(lhs: AClass, rhs: AClass) -> Bool { + return true + } +} +``` + +```swift +class AClass: NSObject, Equatable { + ↓static func ==(lhs: AClass, rhs: AClass) -> Bool { + return false + } +} +``` + +```swift +class AClass: NSObject { + override func isEqual(_ object: Any?) -> Bool { + guard let other = object as? AClass else { + return false + } + return true + } + + ↓static func ==(lhs: AClass, rhs: AClass) -> Bool { + return false + } +} +``` \ No newline at end of file diff --git a/docs/description/number_separator.md b/docs/description/number_separator.md new file mode 100644 index 0000000..80ebc5c --- /dev/null +++ b/docs/description/number_separator.md @@ -0,0 +1,315 @@ +# Number Separator + +Underscores should be used as thousand separator in large decimal numbers. + +* **Identifier:** number_separator +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, minimum_length: 0 + +## Non Triggering Examples + +```swift +let foo = -100 +``` + +```swift +let foo = -1_000 +``` + +```swift +let foo = -1_000_000 +``` + +```swift +let foo = -1.000_1 +``` + +```swift +let foo = -1_000_000.000_000_1 +``` + +```swift +let binary = -0b10000 +``` + +```swift +let binary = -0b1000_0001 +``` + +```swift +let hex = -0xA +``` + +```swift +let hex = -0xAA_BB +``` + +```swift +let octal = -0o21 +``` + +```swift +let octal = -0o21_1 +``` + +```swift +let exp = -1_000_000.000_000e2 +``` + +```swift +let foo: Double = -(200) +``` + +```swift +let foo: Double = -(200 / 447.214) +``` + +```swift +let foo = +100 +``` + +```swift +let foo = +1_000 +``` + +```swift +let foo = +1_000_000 +``` + +```swift +let foo = +1.000_1 +``` + +```swift +let foo = +1_000_000.000_000_1 +``` + +```swift +let binary = +0b10000 +``` + +```swift +let binary = +0b1000_0001 +``` + +```swift +let hex = +0xA +``` + +```swift +let hex = +0xAA_BB +``` + +```swift +let octal = +0o21 +``` + +```swift +let octal = +0o21_1 +``` + +```swift +let exp = +1_000_000.000_000e2 +``` + +```swift +let foo: Double = +(200) +``` + +```swift +let foo: Double = +(200 / 447.214) +``` + +```swift +let foo = 100 +``` + +```swift +let foo = 1_000 +``` + +```swift +let foo = 1_000_000 +``` + +```swift +let foo = 1.000_1 +``` + +```swift +let foo = 1_000_000.000_000_1 +``` + +```swift +let binary = 0b10000 +``` + +```swift +let binary = 0b1000_0001 +``` + +```swift +let hex = 0xA +``` + +```swift +let hex = 0xAA_BB +``` + +```swift +let octal = 0o21 +``` + +```swift +let octal = 0o21_1 +``` + +```swift +let exp = 1_000_000.000_000e2 +``` + +```swift +let foo: Double = (200) +``` + +```swift +let foo: Double = (200 / 447.214) +``` + +## Triggering Examples + +```swift +let foo = ↓-10_0 +``` + +```swift +let foo = ↓-1000 +``` + +```swift +let foo = ↓-1000e2 +``` + +```swift +let foo = ↓-1000E2 +``` + +```swift +let foo = ↓-1__000 +``` + +```swift +let foo = ↓-1.0001 +``` + +```swift +let foo = ↓-1_000_000.000000_1 +``` + +```swift +let foo = ↓-1000000.000000_1 +``` + +```swift +let foo = +↓10_0 +``` + +```swift +let foo = +↓1000 +``` + +```swift +let foo = +↓1000e2 +``` + +```swift +let foo = +↓1000E2 +``` + +```swift +let foo = +↓1__000 +``` + +```swift +let foo = +↓1.0001 +``` + +```swift +let foo = +↓1_000_000.000000_1 +``` + +```swift +let foo = +↓1000000.000000_1 +``` + +```swift +let foo = ↓10_0 +``` + +```swift +let foo = ↓1000 +``` + +```swift +let foo = ↓1000e2 +``` + +```swift +let foo = ↓1000E2 +``` + +```swift +let foo = ↓1__000 +``` + +```swift +let foo = ↓1.0001 +``` + +```swift +let foo = ↓1_000_000.000000_1 +``` + +```swift +let foo = ↓1000000.000000_1 +``` + +```swift +let foo: Double = ↓-(100000) +``` + +```swift +let foo: Double = ↓-(10.000000_1) +``` + +```swift +let foo: Double = ↓-(123456 / ↓447.214214) +``` + +```swift +let foo: Double = +(↓100000) +``` + +```swift +let foo: Double = +(↓10.000000_1) +``` + +```swift +let foo: Double = +(↓123456 / ↓447.214214) +``` + +```swift +let foo: Double = (↓100000) +``` + +```swift +let foo: Double = (↓10.000000_1) +``` + +```swift +let foo: Double = (↓123456 / ↓447.214214) +``` \ No newline at end of file diff --git a/docs/description/object_literal.md b/docs/description/object_literal.md new file mode 100644 index 0000000..88a248b --- /dev/null +++ b/docs/description/object_literal.md @@ -0,0 +1,111 @@ +# Object Literal + +Prefer object literals over image and color inits. + +* **Identifier:** object_literal +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, image_literal: true, color_literal: true + +## Non Triggering Examples + +```swift +let image = #imageLiteral(resourceName: "image.jpg") +``` + +```swift +let color = #colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1) +``` + +```swift +let image = UIImage(named: aVariable) +``` + +```swift +let image = UIImage(named: "interpolated \(variable)") +``` + +```swift +let color = UIColor(red: value, green: value, blue: value, alpha: 1) +``` + +```swift +let image = NSImage(named: aVariable) +``` + +```swift +let image = NSImage(named: "interpolated \(variable)") +``` + +```swift +let color = NSColor(red: value, green: value, blue: value, alpha: 1) +``` + +## Triggering Examples + +```swift +let image = ↓UIImage(named: "foo") +``` + +```swift +let color = ↓UIColor(red: 0.3, green: 0.3, blue: 0.3, alpha: 1) +``` + +```swift +let color = ↓UIColor(red: 100 / 255.0, green: 50 / 255.0, blue: 0, alpha: 1) +``` + +```swift +let color = ↓UIColor(white: 0.5, alpha: 1) +``` + +```swift +let image = ↓NSImage(named: "foo") +``` + +```swift +let color = ↓NSColor(red: 0.3, green: 0.3, blue: 0.3, alpha: 1) +``` + +```swift +let color = ↓NSColor(red: 100 / 255.0, green: 50 / 255.0, blue: 0, alpha: 1) +``` + +```swift +let color = ↓NSColor(white: 0.5, alpha: 1) +``` + +```swift +let image = ↓UIImage.init(named: "foo") +``` + +```swift +let color = ↓UIColor.init(red: 0.3, green: 0.3, blue: 0.3, alpha: 1) +``` + +```swift +let color = ↓UIColor.init(red: 100 / 255.0, green: 50 / 255.0, blue: 0, alpha: 1) +``` + +```swift +let color = ↓UIColor.init(white: 0.5, alpha: 1) +``` + +```swift +let image = ↓NSImage.init(named: "foo") +``` + +```swift +let color = ↓NSColor.init(red: 0.3, green: 0.3, blue: 0.3, alpha: 1) +``` + +```swift +let color = ↓NSColor.init(red: 100 / 255.0, green: 50 / 255.0, blue: 0, alpha: 1) +``` + +```swift +let color = ↓NSColor.init(white: 0.5, alpha: 1) +``` \ No newline at end of file diff --git a/docs/description/opening_brace.md b/docs/description/opening_brace.md new file mode 100644 index 0000000..4ca1b08 --- /dev/null +++ b/docs/description/opening_brace.md @@ -0,0 +1,196 @@ +# Opening Brace Spacing + +Opening braces should be preceded by a single space and on the same line as the declaration. + +* **Identifier:** opening_brace +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func abc() { +} +``` + +```swift +[].map() { $0 } +``` + +```swift +[].map({ }) +``` + +```swift +if let a = b { } +``` + +```swift +while a == b { } +``` + +```swift +guard let a = b else { } +``` + +```swift +if + let a = b, + let c = d + where a == c +{ } +``` + +```swift +while + let a = b, + let c = d + where a == c +{ } +``` + +```swift +guard + let a = b, + let c = d + where a == c else +{ } +``` + +```swift +struct Rule {} + +``` + +```swift +struct Parent { + struct Child { + let foo: Int + } +} + +``` + +```swift +func f(rect: CGRect) { + { + let centre = CGPoint(x: rect.midX, y: rect.midY) + print(centre) + }() +} +``` + +## Triggering Examples + +```swift +func abc()↓{ +} +``` + +```swift +func abc() + ↓{ } +``` + +```swift +[].map()↓{ $0 } +``` + +```swift +[].map( ↓{ } ) +``` + +```swift +if let a = b↓{ } +``` + +```swift +while a == b↓{ } +``` + +```swift +guard let a = b else↓{ } +``` + +```swift +if + let a = b, + let c = d + where a == c↓{ } +``` + +```swift +while + let a = b, + let c = d + where a == c↓{ } +``` + +```swift +guard + let a = b, + let c = d + where a == c else↓{ } +``` + +```swift +struct Rule↓{} + +``` + +```swift +struct Rule +↓{ +} + +``` + +```swift +struct Rule + + ↓{ +} + +``` + +```swift +struct Parent { + struct Child + ↓{ + let foo: Int + } +} + +``` + +```swift +// Get the current thread's TLS pointer. On first call for a given thread, +// creates and initializes a new one. +internal static func getPointer() + -> UnsafeMutablePointer<_ThreadLocalStorage> +{ // <- here + return _swift_stdlib_threadLocalStorageGet().assumingMemoryBound( + to: _ThreadLocalStorage.self) +} +``` + +```swift +func run_Array_method1x(_ N: Int) { + let existentialArray = array! + for _ in 0 ..< N * 100 { + for elt in existentialArray { + if !elt.doIt() { + fatalError("expected true") + } + } + } +} + +func run_Array_method2x(_ N: Int) { + +} +``` \ No newline at end of file diff --git a/docs/description/operator_usage_whitespace.md b/docs/description/operator_usage_whitespace.md new file mode 100644 index 0000000..00120ed --- /dev/null +++ b/docs/description/operator_usage_whitespace.md @@ -0,0 +1,189 @@ +# Operator Usage Whitespace + +Operators should be surrounded by a single whitespace when they are being used. + +* **Identifier:** operator_usage_whitespace +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let foo = 1 + 2 + +``` + +```swift +let foo = 1 > 2 + +``` + +```swift +let foo = !false + +``` + +```swift +let foo: Int? + +``` + +```swift +let foo: Array + +``` + +```swift +let model = CustomView, NSAttributedString>() + +``` + +```swift +let foo: [String] + +``` + +```swift +let foo = 1 + + 2 + +``` + +```swift +let range = 1...3 + +``` + +```swift +let range = 1 ... 3 + +``` + +```swift +let range = 1..<3 + +``` + +```swift +#if swift(>=3.0) + foo() +#endif + +``` + +```swift +array.removeAtIndex(-200) + +``` + +```swift +let name = "image-1" + +``` + +```swift +button.setImage(#imageLiteral(resourceName: "image-1"), for: .normal) + +``` + +```swift +let doubleValue = -9e-11 + +``` + +```swift +let foo = GenericType<(UIViewController) -> Void>() + +``` + +```swift +let foo = Foo, Baz>() + +``` + +```swift +let foo = SignalProducer, Error>([ self.signal, next ]).flatten(.concat) + +``` + +## Triggering Examples + +```swift +let foo = 1↓+2 + +``` + +```swift +let foo = 1↓ + 2 + +``` + +```swift +let foo = 1↓ + 2 + +``` + +```swift +let foo = 1↓ + 2 + +``` + +```swift +let foo↓=1↓+2 + +``` + +```swift +let foo↓=1 + 2 + +``` + +```swift +let foo↓=bar + +``` + +```swift +let range = 1↓ ..< 3 + +``` + +```swift +let foo = bar↓ ?? 0 + +``` + +```swift +let foo = bar↓??0 + +``` + +```swift +let foo = bar↓ != 0 + +``` + +```swift +let foo = bar↓ !== bar2 + +``` + +```swift +let v8 = Int8(1)↓ << 6 + +``` + +```swift +let v8 = 1↓ << (6) + +``` + +```swift +let v8 = 1↓ << (6) + let foo = 1 > 2 + +``` \ No newline at end of file diff --git a/docs/description/operator_whitespace.md b/docs/description/operator_whitespace.md new file mode 100644 index 0000000..70c1cd2 --- /dev/null +++ b/docs/description/operator_whitespace.md @@ -0,0 +1,60 @@ +# Operator Function Whitespace + +Operators should be surrounded by a single whitespace when defining them. + +* **Identifier:** operator_whitespace +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func <| (lhs: Int, rhs: Int) -> Int {} + +``` + +```swift +func <|< (lhs: A, rhs: A) -> A {} + +``` + +```swift +func abc(lhs: Int, rhs: Int) -> Int {} + +``` + +## Triggering Examples + +```swift +↓func <|(lhs: Int, rhs: Int) -> Int {} + +``` + +```swift +↓func <|<(lhs: A, rhs: A) -> A {} + +``` + +```swift +↓func <| (lhs: Int, rhs: Int) -> Int {} + +``` + +```swift +↓func <|< (lhs: A, rhs: A) -> A {} + +``` + +```swift +↓func <| (lhs: Int, rhs: Int) -> Int {} + +``` + +```swift +↓func <|< (lhs: A, rhs: A) -> A {} + +``` \ No newline at end of file diff --git a/docs/description/optional_enum_case_matching.md b/docs/description/optional_enum_case_matching.md new file mode 100644 index 0000000..87658af --- /dev/null +++ b/docs/description/optional_enum_case_matching.md @@ -0,0 +1,83 @@ +# Optional Enum Case Match + +Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. + +* **Identifier:** optional_enum_case_matching +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +switch foo { + case .bar: break + case .baz: break + default: break +} +``` + +```swift +switch foo { + case (.bar, .baz): break + case (.bar, _): break + case (_, .baz): break + default: break +} +``` + +```swift +switch (x, y) { +case (.c, _?): + break +case (.c, nil): + break +case (_, _): + break +} +``` + +## Triggering Examples + +```swift +switch foo { + case .bar↓?: break + case .baz: break + default: break +} +``` + +```swift +switch foo { + case Foo.bar↓?: break + case .baz: break + default: break +} +``` + +```swift +switch foo { + case .bar↓?, .baz↓?: break + default: break +} +``` + +```swift +switch foo { + case .bar↓? where x > 1: break + case .baz: break + default: break +} +``` + +```swift +switch foo { + case (.bar↓?, .baz↓?): break + case (.bar↓?, _): break + case (_, .bar↓?): break + default: break +} +``` \ No newline at end of file diff --git a/docs/description/orphaned_doc_comment.md b/docs/description/orphaned_doc_comment.md new file mode 100644 index 0000000..674d1e9 --- /dev/null +++ b/docs/description/orphaned_doc_comment.md @@ -0,0 +1,51 @@ +# Orphaned Doc Comment + +A doc comment should be attached to a declaration. + +* **Identifier:** orphaned_doc_comment +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +/// My great property +var myGreatProperty: String! +``` + +```swift +////////////////////////////////////// +// +// Copyright header. +// +////////////////////////////////////// +``` + +```swift +/// Look here for more info: https://github.com. +var myGreatProperty: String! +``` + +```swift +/// Look here for more info: +/// https://github.com. +var myGreatProperty: String! +``` + +## Triggering Examples + +```swift +↓/// My great property +// Not a doc string +var myGreatProperty: String! +``` + +```swift +↓/// Look here for more info: https://github.com. +// Not a doc string +var myGreatProperty: String! +``` \ No newline at end of file diff --git a/docs/description/overridden_super_call.md b/docs/description/overridden_super_call.md new file mode 100644 index 0000000..09b9781 --- /dev/null +++ b/docs/description/overridden_super_call.md @@ -0,0 +1,83 @@ +# Overridden methods call super + +Some overridden methods should always call super + +* **Identifier:** overridden_super_call +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, excluded: [[]], included: [["*"]] + +## Non Triggering Examples + +```swift +class VC: UIViewController { + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + } +} +``` + +```swift +class VC: UIViewController { + override func viewWillAppear(_ animated: Bool) { + self.method1() + super.viewWillAppear(animated) + self.method2() + } +} +``` + +```swift +class VC: UIViewController { + override func loadView() { + } +} +``` + +```swift +class Some { + func viewWillAppear(_ animated: Bool) { + } +} +``` + +```swift +class VC: UIViewController { + override func viewDidLoad() { + defer { + super.viewDidLoad() + } + } +} +``` + +## Triggering Examples + +```swift +class VC: UIViewController { + override func viewWillAppear(_ animated: Bool) {↓ + //Not calling to super + self.method() + } +} +``` + +```swift +class VC: UIViewController { + override func viewWillAppear(_ animated: Bool) {↓ + super.viewWillAppear(animated) + //Other code + super.viewWillAppear(animated) + } +} +``` + +```swift +class VC: UIViewController { + override func didReceiveMemoryWarning() {↓ + } +} +``` \ No newline at end of file diff --git a/docs/description/override_in_extension.md b/docs/description/override_in_extension.md new file mode 100644 index 0000000..472e3d8 --- /dev/null +++ b/docs/description/override_in_extension.md @@ -0,0 +1,66 @@ +# Override in Extension + +Extensions shouldn't override declarations. + +* **Identifier:** override_in_extension +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +extension Person { + var age: Int { return 42 } +} + +``` + +```swift +extension Person { + func celebrateBirthday() {} +} + +``` + +```swift +class Employee: Person { + override func celebrateBirthday() {} +} + +``` + +```swift +class Foo: NSObject {} +extension Foo { + override var description: String { return "" } +} +``` + +```swift +struct Foo { + class Bar: NSObject {} +} +extension Foo.Bar { + override var description: String { return "" } +} +``` + +## Triggering Examples + +```swift +extension Person { + override ↓var age: Int { return 42 } +} + +``` + +```swift +extension Person { + override ↓func celebrateBirthday() {} +} + +``` \ No newline at end of file diff --git a/docs/description/pattern_matching_keywords.md b/docs/description/pattern_matching_keywords.md new file mode 100644 index 0000000..2656a5e --- /dev/null +++ b/docs/description/pattern_matching_keywords.md @@ -0,0 +1,117 @@ +# Pattern Matching Keywords + +Combine multiple pattern matching bindings by moving keywords out of tuples. + +* **Identifier:** pattern_matching_keywords +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +switch foo { + default: break +} +``` + +```swift +switch foo { + case 1: break +} +``` + +```swift +switch foo { + case bar: break +} +``` + +```swift +switch foo { + case let (x, y): break +} +``` + +```swift +switch foo { + case .foo(let x): break +} +``` + +```swift +switch foo { + case let .foo(x, y): break +} +``` + +```swift +switch foo { + case .foo(let x), .bar(let x): break +} +``` + +```swift +switch foo { + case .foo(let x, var y): break +} +``` + +```swift +switch foo { + case var (x, y): break +} +``` + +```swift +switch foo { + case .foo(var x): break +} +``` + +```swift +switch foo { + case var .foo(x, y): break +} +``` + +## Triggering Examples + +```swift +switch foo { + case (↓let x, ↓let y): break +} +``` + +```swift +switch foo { + case .foo(↓let x, ↓let y): break +} +``` + +```swift +switch foo { + case (.yamlParsing(↓let x), .yamlParsing(↓let y)): break +} +``` + +```swift +switch foo { + case (↓var x, ↓var y): break +} +``` + +```swift +switch foo { + case .foo(↓var x, ↓var y): break +} +``` + +```swift +switch foo { + case (.yamlParsing(↓var x), .yamlParsing(↓var y)): break +} +``` \ No newline at end of file diff --git a/docs/description/prefer_self_type_over_type_of_self.md b/docs/description/prefer_self_type_over_type_of_self.md new file mode 100644 index 0000000..9bfa94d --- /dev/null +++ b/docs/description/prefer_self_type_over_type_of_self.md @@ -0,0 +1,71 @@ +# Prefer Self Type Over Type of Self + +Prefer `Self` over `type(of: self)` when accessing properties or calling methods. + +* **Identifier:** prefer_self_type_over_type_of_self +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class Foo { + func bar() { + Self.baz() + } +} +``` + +```swift +class Foo { + func bar() { + print(Self.baz) + } +} +``` + +```swift +class A { + func foo(param: B) { + type(of: param).bar() + } +} +``` + +```swift +class A { + func foo() { + print(type(of: self)) + } +} +``` + +## Triggering Examples + +```swift +class Foo { + func bar() { + ↓type(of: self).baz() + } +} +``` + +```swift +class Foo { + func bar() { + print(↓type(of: self).baz) + } +} +``` + +```swift +class Foo { + func bar() { + print(↓Swift.type(of: self).baz) + } +} +``` \ No newline at end of file diff --git a/docs/description/prefixed_toplevel_constant.md b/docs/description/prefixed_toplevel_constant.md new file mode 100644 index 0000000..07dc0f9 --- /dev/null +++ b/docs/description/prefixed_toplevel_constant.md @@ -0,0 +1,113 @@ +# Prefixed Top-Level Constant + +Top-level constants should be prefixed by `k`. + +* **Identifier:** prefixed_toplevel_constant +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, only_private: false + +## Non Triggering Examples + +```swift +private let kFoo = 20.0 +``` + +```swift +public let kFoo = false +``` + +```swift +internal let kFoo = "Foo" +``` + +```swift +let kFoo = true +``` + +```swift +struct Foo { + let bar = 20.0 +} +``` + +```swift +private var foo = 20.0 +``` + +```swift +public var foo = false +``` + +```swift +internal var foo = "Foo" +``` + +```swift +var foo = true +``` + +```swift +var foo = true, bar = true +``` + +```swift +var foo = true, let kFoo = true +``` + +```swift +let + kFoo = true +``` + +```swift +var foo: Int { + return a + b +} +``` + +```swift +let kFoo = { + return a + b +}() +``` + +## Triggering Examples + +```swift +private let ↓Foo = 20.0 +``` + +```swift +public let ↓Foo = false +``` + +```swift +internal let ↓Foo = "Foo" +``` + +```swift +let ↓Foo = true +``` + +```swift +let ↓foo = 2, ↓bar = true +``` + +```swift +var foo = true, let ↓Foo = true +``` + +```swift +let + ↓foo = true +``` + +```swift +let ↓foo = { + return a + b +}() +``` \ No newline at end of file diff --git a/docs/description/private_action.md b/docs/description/private_action.md new file mode 100644 index 0000000..5526406 --- /dev/null +++ b/docs/description/private_action.md @@ -0,0 +1,134 @@ +# Private Actions + +IBActions should be private. + +* **Identifier:** private_action +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class Foo { + @IBAction private func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +struct Foo { + @IBAction private func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +class Foo { + @IBAction fileprivate func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +struct Foo { + @IBAction fileprivate func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +private extension Foo { + @IBAction func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +fileprivate extension Foo { + @IBAction func barButtonTapped(_ sender: UIButton) {} +} + +``` + +## Triggering Examples + +```swift +class Foo { + @IBAction ↓func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +struct Foo { + @IBAction ↓func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +class Foo { + @IBAction public ↓func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +struct Foo { + @IBAction public ↓func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +class Foo { + @IBAction internal ↓func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +struct Foo { + @IBAction internal ↓func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +extension Foo { + @IBAction ↓func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +extension Foo { + @IBAction public ↓func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +extension Foo { + @IBAction internal ↓func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +public extension Foo { + @IBAction ↓func barButtonTapped(_ sender: UIButton) {} +} + +``` + +```swift +internal extension Foo { + @IBAction ↓func barButtonTapped(_ sender: UIButton) {} +} + +``` \ No newline at end of file diff --git a/docs/description/private_outlet.md b/docs/description/private_outlet.md new file mode 100644 index 0000000..617373a --- /dev/null +++ b/docs/description/private_outlet.md @@ -0,0 +1,64 @@ +# Private Outlets + +IBOutlets should be private to avoid leaking UIKit to higher layers. + +* **Identifier:** private_outlet +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, allow_private_set: false + +## Non Triggering Examples + +```swift +class Foo { + @IBOutlet private var label: UILabel? +} + +``` + +```swift +class Foo { + @IBOutlet private var label: UILabel! +} + +``` + +```swift +class Foo { + var notAnOutlet: UILabel +} + +``` + +```swift +class Foo { + @IBOutlet weak private var label: UILabel? +} + +``` + +```swift +class Foo { + @IBOutlet private weak var label: UILabel? +} + +``` + +## Triggering Examples + +```swift +class Foo { + @IBOutlet ↓var label: UILabel? +} + +``` + +```swift +class Foo { + @IBOutlet ↓var label: UILabel! +} + +``` \ No newline at end of file diff --git a/docs/description/private_over_fileprivate.md b/docs/description/private_over_fileprivate.md new file mode 100644 index 0000000..7f51cfc --- /dev/null +++ b/docs/description/private_over_fileprivate.md @@ -0,0 +1,73 @@ +# Private over fileprivate + +Prefer `private` over `fileprivate` declarations. + +* **Identifier:** private_over_fileprivate +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, validate_extensions: false + +## Non Triggering Examples + +```swift +extension String {} +``` + +```swift +private extension String {} +``` + +```swift +public + enum MyEnum {} +``` + +```swift +open extension + String {} +``` + +```swift +internal extension String {} +``` + +```swift +extension String { + fileprivate func Something(){} +} +``` + +```swift +class MyClass { + fileprivate let myInt = 4 +} +``` + +```swift +class MyClass { + fileprivate(set) var myInt = 4 +} +``` + +```swift +struct Outter { + struct Inter { + fileprivate struct Inner {} + } +} +``` + +## Triggering Examples + +```swift +↓fileprivate enum MyEnum {} +``` + +```swift +↓fileprivate class MyClass { + fileprivate(set) var myInt = 4 +} +``` \ No newline at end of file diff --git a/docs/description/private_unit_test.md b/docs/description/private_unit_test.md new file mode 100644 index 0000000..b37b5aa --- /dev/null +++ b/docs/description/private_unit_test.md @@ -0,0 +1,105 @@ +# Private Unit Test + +Unit tests marked private are silently skipped. + +* **Identifier:** private_unit_test +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning: XCTestCase + +## Non Triggering Examples + +```swift +"class FooTest: XCTestCase { + func test1() {} + internal func test2() {} + public func test3() {} +} +``` + +```swift +internal class FooTest: XCTestCase { + func test1() {} + internal func test2() {} + public func test3() {} +} +``` + +```swift +public class FooTest: XCTestCase { + func test1() {} + internal func test2() {} + public func test3() {} +} +``` + +```swift +@objc private class FooTest: XCTestCase { + @objc private func test1() {} + internal func test2() {} + public func test3() {} +} +``` + +```swift +private class Foo: NSObject { + func test1() {} + internal func test2() {} + public func test3() {} +} +``` + +```swift +private class Foo { + func test1() {} + internal func test2() {} + public func test3() {} +} +``` + +```swift +public class FooTest: XCTestCase { + func test1(param: Int) {} +} +``` + +## Triggering Examples + +```swift +private ↓class FooTest: XCTestCase { + func test1() {} + internal func test2() {} + public func test3() {} + private func test4() {} +} +``` + +```swift +class FooTest: XCTestCase { + func test1() {} + internal func test2() {} + public func test3() {} + private ↓func test4() {} +} +``` + +```swift +internal class FooTest: XCTestCase { + func test1() {} + internal func test2() {} + public func test3() {} + private ↓func test4() {} +} +``` + +```swift +public class FooTest: XCTestCase { + func test1() {} + internal func test2() {} + public func test3() {} + private ↓func test4() {} +} +``` \ No newline at end of file diff --git a/docs/description/prohibited_interface_builder.md b/docs/description/prohibited_interface_builder.md new file mode 100644 index 0000000..6ba23f5 --- /dev/null +++ b/docs/description/prohibited_interface_builder.md @@ -0,0 +1,39 @@ +# Prohibited Interface Builder + +Creating views using Interface Builder should be avoided. + +* **Identifier:** prohibited_interface_builder +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class ViewController: UIViewController { + var label: UILabel! +} +``` + +```swift +class ViewController: UIViewController { + @objc func buttonTapped(_ sender: UIButton) {} +} +``` + +## Triggering Examples + +```swift +class ViewController: UIViewController { + @IBOutlet ↓var label: UILabel! +} +``` + +```swift +class ViewController: UIViewController { + @IBAction ↓func buttonTapped(_ sender: UIButton) {} +} +``` \ No newline at end of file diff --git a/docs/description/prohibited_super_call.md b/docs/description/prohibited_super_call.md new file mode 100644 index 0000000..f23d814 --- /dev/null +++ b/docs/description/prohibited_super_call.md @@ -0,0 +1,78 @@ +# Prohibited calls to super + +Some methods should not call super + +* **Identifier:** prohibited_super_call +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, excluded: [[]], included: [["*"]] + +## Non Triggering Examples + +```swift +class VC: UIViewController { + override func loadView() { + } +} +``` + +```swift +class NSView { + func updateLayer() { + self.method1() + } +} +``` + +```swift +public class FileProviderExtension: NSFileProviderExtension { + override func providePlaceholder(at url: URL, completionHandler: @escaping (Error?) -> Void) { + guard let identifier = persistentIdentifierForItem(at: url) else { + completionHandler(NSFileProviderError(.noSuchItem)) + return + } + } +} +``` + +## Triggering Examples + +```swift +class VC: UIViewController { + override func loadView() {↓ + super.loadView() + } +} +``` + +```swift +class VC: NSFileProviderExtension { + override func providePlaceholder(at url: URL, completionHandler: @escaping (Error?) -> Void) {↓ + self.method1() + super.providePlaceholder(at:url, completionHandler: completionHandler) + } +} +``` + +```swift +class VC: NSView { + override func updateLayer() {↓ + self.method1() + super.updateLayer() + self.method2() + } +} +``` + +```swift +class VC: NSView { + override func updateLayer() {↓ + defer { + super.updateLayer() + } + } +} +``` \ No newline at end of file diff --git a/docs/description/protocol_property_accessors_order.md b/docs/description/protocol_property_accessors_order.md new file mode 100644 index 0000000..560940c --- /dev/null +++ b/docs/description/protocol_property_accessors_order.md @@ -0,0 +1,39 @@ +# Protocol Property Accessors Order + +When declaring properties in protocols, the order of accessors should be `get set`. + +* **Identifier:** protocol_property_accessors_order +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +protocol Foo { + var bar: String { get set } + } +``` + +```swift +protocol Foo { + var bar: String { get } + } +``` + +```swift +protocol Foo { + var bar: String { set } + } +``` + +## Triggering Examples + +```swift +protocol Foo { + var bar: String { ↓set get } + } +``` \ No newline at end of file diff --git a/docs/description/quick_discouraged_call.md b/docs/description/quick_discouraged_call.md new file mode 100644 index 0000000..dd87de8 --- /dev/null +++ b/docs/description/quick_discouraged_call.md @@ -0,0 +1,313 @@ +# Quick Discouraged Call + +Discouraged call inside 'describe' and/or 'context' block. + +* **Identifier:** quick_discouraged_call +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + beforeEach { + let foo = Foo() + foo.toto() + } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + beforeEach { + let foo = Foo() + foo.toto() + } + afterEach { + let foo = Foo() + foo.toto() + } + describe("bar") { + } + context("bar") { + } + it("bar") { + let foo = Foo() + foo.toto() + } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + itBehavesLike("bar") + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + it("does something") { + let foo = Foo() + foo.toto() + } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + context("foo") { + afterEach { toto.append(foo) } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + xcontext("foo") { + afterEach { toto.append(foo) } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + xdescribe("foo") { + afterEach { toto.append(foo) } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + xit("does something") { + let foo = Foo() + foo.toto() + } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + fcontext("foo") { + afterEach { toto.append(foo) } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + fdescribe("foo") { + afterEach { toto.append(foo) } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + fit("does something") { + let foo = Foo() + foo.toto() + } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + fitBehavesLike("foo") + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + xitBehavesLike("foo") + } +} +``` + +## Triggering Examples + +```swift +class TotoTests { + override func spec() { + describe("foo") { + let foo = Foo() + } + } +} +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + let foo = ↓Foo() + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + let foo = ↓Foo() + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + context("foo") { + let foo = ↓Foo() + } + context("bar") { + let foo = ↓Foo() + ↓foo.bar() + it("does something") { + let foo = Foo() + foo.toto() + } + } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + context("foo") { + context("foo") { + beforeEach { + let foo = Foo() + foo.toto() + } + it("bar") { + } + context("foo") { + let foo = ↓Foo() + } + } + } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + context("foo") { + let foo = ↓Foo() + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + sharedExamples("foo") { + let foo = ↓Foo() + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + ↓foo() + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + context("foo") { + ↓foo() + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + sharedExamples("foo") { + ↓foo() + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + xdescribe("foo") { + let foo = ↓Foo() + } + fdescribe("foo") { + let foo = ↓Foo() + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + xcontext("foo") { + let foo = ↓Foo() + } + fcontext("foo") { + let foo = ↓Foo() + } + } +} +``` \ No newline at end of file diff --git a/docs/description/quick_discouraged_focused_test.md b/docs/description/quick_discouraged_focused_test.md new file mode 100644 index 0000000..2a0bc93 --- /dev/null +++ b/docs/description/quick_discouraged_focused_test.md @@ -0,0 +1,94 @@ +# Quick Discouraged Focused Test + +Discouraged focused test. Other tests won't run while this one is focused. + +* **Identifier:** quick_discouraged_focused_test +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + describe("bar") { } + context("bar") { + it("bar") { } + } + it("bar") { } + itBehavesLike("bar") + } + } +} +``` + +## Triggering Examples + +```swift +class TotoTests: QuickSpec { + override func spec() { + ↓fdescribe("foo") { } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + ↓fcontext("foo") { } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + ↓fit("foo") { } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + ↓fit("bar") { } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + context("foo") { + ↓fit("bar") { } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + context("bar") { + ↓fit("toto") { } + } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + ↓fitBehavesLike("foo") + } +} +``` \ No newline at end of file diff --git a/docs/description/quick_discouraged_pending_test.md b/docs/description/quick_discouraged_pending_test.md new file mode 100644 index 0000000..c7788be --- /dev/null +++ b/docs/description/quick_discouraged_pending_test.md @@ -0,0 +1,102 @@ +# Quick Discouraged Pending Test + +Discouraged pending test. This test won't run while it's marked as pending. + +* **Identifier:** quick_discouraged_pending_test +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + describe("bar") { } + context("bar") { + it("bar") { } + } + it("bar") { } + itBehavesLike("bar") + } + } +} +``` + +## Triggering Examples + +```swift +class TotoTests: QuickSpec { + override func spec() { + ↓xdescribe("foo") { } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + ↓xcontext("foo") { } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + ↓xit("foo") { } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + ↓xit("bar") { } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + context("foo") { + ↓xit("bar") { } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + context("bar") { + ↓xit("toto") { } + } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + ↓pending("foo") + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + ↓xitBehavesLike("foo") + } +} +``` \ No newline at end of file diff --git a/docs/description/raw_value_for_camel_cased_codable_enum.md b/docs/description/raw_value_for_camel_cased_codable_enum.md new file mode 100644 index 0000000..b891ee2 --- /dev/null +++ b/docs/description/raw_value_for_camel_cased_codable_enum.md @@ -0,0 +1,91 @@ +# Raw Value For Camel Cased Codable Enum + +Camel cased cases of Codable String enums should have raw value. + +* **Identifier:** raw_value_for_camel_cased_codable_enum +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +enum Numbers: Codable { + case int(Int) + case short(Int16) +} +``` + +```swift +enum Numbers: Int, Codable { + case one = 1 + case two = 2 +} +``` + +```swift +enum Numbers: Double, Codable { + case one = 1.1 + case two = 2.2 +} +``` + +```swift +enum Numbers: String, Codable { + case one = "one" + case two = "two" +} +``` + +```swift +enum Status: String { + case ok + case notAcceptable + case maybeAcceptable = "maybe_acceptable" +} +``` + +```swift +enum Status: Int, Codable { + case ok + case notAcceptable + case maybeAcceptable = -1 +} +``` + +## Triggering Examples + +```swift +enum Status: String, Codable { + case ok + case ↓notAcceptable + case maybeAcceptable = "maybe_acceptable" +} +``` + +```swift +enum Status: String, Decodable { + case ok + case ↓notAcceptable + case maybeAcceptable = "maybe_acceptable" +} +``` + +```swift +enum Status: String, Encodable { + case ok + case ↓notAcceptable + case maybeAcceptable = "maybe_acceptable" +} +``` + +```swift +enum Status: String, Codable { + case ok + case ↓notAcceptable + case maybeAcceptable = "maybe_acceptable" +} +``` \ No newline at end of file diff --git a/docs/description/reduce_boolean.md b/docs/description/reduce_boolean.md new file mode 100644 index 0000000..298c3a1 --- /dev/null +++ b/docs/description/reduce_boolean.md @@ -0,0 +1,55 @@ +# Reduce Boolean + +Prefer using `.allSatisfy()` or `.contains()` over `reduce(true)` or `reduce(false)` + +* **Identifier:** reduce_boolean +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.2.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +nums.reduce(0) { $0.0 + $0.1 } +``` + +```swift +nums.reduce(0.0) { $0.0 + $0.1 } +``` + +## Triggering Examples + +```swift +let allNines = nums.↓reduce(true) { $0.0 && $0.1 == 9 } +``` + +```swift +let anyNines = nums.↓reduce(false) { $0.0 || $0.1 == 9 } +``` + +```swift +let allValid = validators.↓reduce(true) { $0 && $1(input) } +``` + +```swift +let anyValid = validators.↓reduce(false) { $0 || $1(input) } +``` + +```swift +let allNines = nums.↓reduce(true, { $0.0 && $0.1 == 9 }) +``` + +```swift +let anyNines = nums.↓reduce(false, { $0.0 || $0.1 == 9 }) +``` + +```swift +let allValid = validators.↓reduce(true, { $0 && $1(input) }) +``` + +```swift +let anyValid = validators.↓reduce(false, { $0 || $1(input) }) +``` \ No newline at end of file diff --git a/docs/description/reduce_into.md b/docs/description/reduce_into.md new file mode 100644 index 0000000..10cfac8 --- /dev/null +++ b/docs/description/reduce_into.md @@ -0,0 +1,106 @@ +# Reduce Into + +Prefer `reduce(into:_:)` over `reduce(_:_:)` for copy-on-write types + +* **Identifier:** reduce_into +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let foo = values.reduce(into: "abc") { $0 += "\($1)" } +``` + +```swift +values.reduce(into: Array()) { result, value in + result.append(value) +} +``` + +```swift +let rows = violations.enumerated().reduce(into: "") { rows, indexAndViolation in + rows.append(generateSingleRow(for: indexAndViolation.1, at: indexAndViolation.0 + 1)) +} +``` + +```swift +zip(group, group.dropFirst()).reduce(into: []) { result, pair in + result.append(pair.0 + pair.1) +} +``` + +```swift +let foo = values.reduce(into: [String: Int]()) { result, value in + result["\(value)"] = value +} +``` + +```swift +let foo = values.reduce(into: Dictionary.init()) { result, value in + result["\(value)"] = value +} +``` + +```swift +let foo = values.reduce(into: [Int](repeating: 0, count: 10)) { result, value in + result.append(value) +} +``` + +```swift +let foo = values.reduce(MyClass()) { result, value in + result.handleValue(value) + return result +} +``` + +## Triggering Examples + +```swift +let bar = values.↓reduce("abc") { $0 + "\($1)" } +``` + +```swift +values.↓reduce(Array()) { result, value in + result += [value] +} +``` + +```swift +let rows = violations.enumerated().↓reduce("") { rows, indexAndViolation in + return rows + generateSingleRow(for: indexAndViolation.1, at: indexAndViolation.0 + 1) +} +``` + +```swift +zip(group, group.dropFirst()).↓reduce([]) { result, pair in + result + [pair.0 + pair.1] +} +``` + +```swift +let foo = values.↓reduce([String: Int]()) { result, value in + var result = result + result["\(value)"] = value + return result +} +``` + +```swift +let bar = values.↓reduce(Dictionary.init()) { result, value in + var result = result + result["\(value)"] = value + return result +} +``` + +```swift +let bar = values.↓reduce([Int](repeating: 0, count: 10)) { result, value in + return result + [value] +} +``` \ No newline at end of file diff --git a/docs/description/redundant_discardable_let.md b/docs/description/redundant_discardable_let.md new file mode 100644 index 0000000..2b0212c --- /dev/null +++ b/docs/description/redundant_discardable_let.md @@ -0,0 +1,49 @@ +# Redundant Discardable Let + +Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function. + +* **Identifier:** redundant_discardable_let +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +_ = foo() + +``` + +```swift +if let _ = foo() { } + +``` + +```swift +guard let _ = foo() else { return } + +``` + +```swift +let _: ExplicitType = foo() +``` + +```swift +while let _ = SplashStyle(rawValue: maxValue) { maxValue += 1 } + +``` + +## Triggering Examples + +```swift +↓let _ = foo() + +``` + +```swift +if _ = foo() { ↓let _ = bar() } + +``` \ No newline at end of file diff --git a/docs/description/redundant_nil_coalescing.md b/docs/description/redundant_nil_coalescing.md new file mode 100644 index 0000000..9b18ec4 --- /dev/null +++ b/docs/description/redundant_nil_coalescing.md @@ -0,0 +1,30 @@ +# Redundant Nil Coalescing + +nil coalescing operator is only evaluated if the lhs is nil, coalescing operator with nil as rhs is redundant + +* **Identifier:** redundant_nil_coalescing +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +var myVar: Int?; myVar ?? 0 + +``` + +## Triggering Examples + +```swift +var myVar: Int? = nil; myVar↓ ?? nil + +``` + +```swift +var myVar: Int? = nil; myVar↓??nil + +``` \ No newline at end of file diff --git a/docs/description/redundant_objc_attribute.md b/docs/description/redundant_objc_attribute.md new file mode 100644 index 0000000..29d173b --- /dev/null +++ b/docs/description/redundant_objc_attribute.md @@ -0,0 +1,213 @@ +# Redundant @objc Attribute + +Objective-C attribute (@objc) is redundant in declaration. + +* **Identifier:** redundant_objc_attribute +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +@objc private var foo: String? {} +``` + +```swift +@IBInspectable private var foo: String? {} +``` + +```swift +@objc private func foo(_ sender: Any) {} +``` + +```swift +@IBAction private func foo(_ sender: Any) {} +``` + +```swift +@GKInspectable private var foo: String! {} +``` + +```swift +private @GKInspectable var foo: String! {} +``` + +```swift +@NSManaged var foo: String! +``` + +```swift +@objc @NSCopying var foo: String! +``` + +```swift +@objcMembers +class Foo { + var bar: Any? + @objc + class Bar { + @objc + var foo: Any? + } +} +``` + +```swift +@objc +extension Foo { + var bar: Int { + return 0 + } +} +``` + +```swift +extension Foo { + @objc + var bar: Int { return 0 } +} +``` + +```swift +@objc @IBDesignable +extension Foo { + var bar: Int { return 0 } +} +``` + +```swift +@IBDesignable +extension Foo { + @objc + var bar: Int { return 0 } + var fooBar: Int { return 1 } +} +``` + +```swift +@objcMembers +class Foo: NSObject { + @objc + private var bar: Int { + return 0 + } +} +``` + +```swift +@objcMembers +class Foo { + class Bar: NSObject { + @objc var foo: Any + } +} +``` + +```swift +@objcMembers +class Foo { + @objc class Bar {} +} +``` + +## Triggering Examples + +```swift +↓@objc @IBInspectable private var foo: String? {} +``` + +```swift +@IBInspectable ↓@objc private var foo: String? {} +``` + +```swift +↓@objc @IBAction private func foo(_ sender: Any) {} +``` + +```swift +@IBAction ↓@objc private func foo(_ sender: Any) {} +``` + +```swift +↓@objc @GKInspectable private var foo: String! {} +``` + +```swift +@GKInspectable ↓@objc private var foo: String! {} +``` + +```swift +↓@objc @NSManaged private var foo: String! +``` + +```swift +@NSManaged ↓@objc private var foo: String! +``` + +```swift +↓@objc @IBDesignable class Foo {} +``` + +```swift +@objcMembers +class Foo { + ↓@objc var bar: Any? +} +``` + +```swift +@objcMembers +class Foo { + ↓@objc var bar: Any? + ↓@objc var foo: Any? + @objc + class Bar { + @objc + var foo: Any? + } +} +``` + +```swift +@objc +extension Foo { + ↓@objc + var bar: Int { + return 0 + } +} +``` + +```swift +@objc @IBDesignable +extension Foo { + ↓@objc + var bar: Int { + return 0 + } +} +``` + +```swift +@objcMembers +class Foo { + @objcMembers + class Bar: NSObject { + ↓@objc var foo: Any + } +} +``` + +```swift +@objc +extension Foo { + ↓@objc + private var bar: Int { + return 0 + } +} +``` \ No newline at end of file diff --git a/docs/description/redundant_optional_initialization.md b/docs/description/redundant_optional_initialization.md new file mode 100644 index 0000000..1eac9bd --- /dev/null +++ b/docs/description/redundant_optional_initialization.md @@ -0,0 +1,106 @@ +# Redundant Optional Initialization + +Initializing an optional variable with nil is redundant. + +* **Identifier:** redundant_optional_initialization +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +var myVar: Int? + +``` + +```swift +let myVar: Int? = nil + +``` + +```swift +var myVar: Int? = 0 + +``` + +```swift +func foo(bar: Int? = 0) { } + +``` + +```swift +var myVar: Optional + +``` + +```swift +let myVar: Optional = nil + +``` + +```swift +var myVar: Optional = 0 + +``` + +```swift +var foo: Int? { + if bar != nil { } + return 0 +} +``` + +```swift +var foo: Int? = { + if bar != nil { } + return 0 +}() +``` + +```swift +lazy var test: Int? = nil +``` + +```swift +func funcName() { + var myVar: String? +} +``` + +```swift +func funcName() { + let myVar: String? = nil +} +``` + +## Triggering Examples + +```swift +var myVar: Int?↓ = nil + +``` + +```swift +var myVar: Optional↓ = nil + +``` + +```swift +var myVar: Int?↓=nil + +``` + +```swift +var myVar: Optional↓=nil +) +``` + +```swift +func funcName() { + var myVar: String?↓ = nil +} +``` \ No newline at end of file diff --git a/docs/description/redundant_set_access_control.md b/docs/description/redundant_set_access_control.md new file mode 100644 index 0000000..1109174 --- /dev/null +++ b/docs/description/redundant_set_access_control.md @@ -0,0 +1,71 @@ +# Redundant Set Access Control Rule + +Property setter access level shouldn't be explicit if it's the same as the variable access level. + +* **Identifier:** redundant_set_access_control +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +private(set) public var foo: Int +``` + +```swift +public let foo: Int +``` + +```swift +public var foo: Int +``` + +```swift +var foo: Int +``` + +```swift +private final class A { + private(set) var value: Int +} +``` + +## Triggering Examples + +```swift +↓private(set) private var foo: Int +``` + +```swift +↓fileprivate(set) fileprivate var foo: Int +``` + +```swift +↓internal(set) internal var foo: Int +``` + +```swift +↓public(set) public var foo: Int +``` + +```swift +open class Foo { + ↓open(set) open var bar: Int +} +``` + +```swift +class A { + ↓internal(set) var value: Int +} +``` + +```swift +fileprivate class A { + ↓fileprivate(set) var value: Int +} +``` \ No newline at end of file diff --git a/docs/description/redundant_string_enum_value.md b/docs/description/redundant_string_enum_value.md new file mode 100644 index 0000000..6a080c2 --- /dev/null +++ b/docs/description/redundant_string_enum_value.md @@ -0,0 +1,68 @@ +# Redundant String Enum Value + +String enum values can be omitted when they are equal to the enumcase name. + +* **Identifier:** redundant_string_enum_value +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +enum Numbers: String { + case one + case two +} +``` + +```swift +enum Numbers: Int { + case one = 1 + case two = 2 +} +``` + +```swift +enum Numbers: String { + case one = "ONE" + case two = "TWO" +} +``` + +```swift +enum Numbers: String { + case one = "ONE" + case two = "two" +} +``` + +```swift +enum Numbers: String { + case one, two +} +``` + +## Triggering Examples + +```swift +enum Numbers: String { + case one = ↓"one" + case two = ↓"two" +} +``` + +```swift +enum Numbers: String { + case one = ↓"one", two = ↓"two" +} +``` + +```swift +enum Numbers: String { + case one, two = ↓"two" +} +``` \ No newline at end of file diff --git a/docs/description/redundant_type_annotation.md b/docs/description/redundant_type_annotation.md new file mode 100644 index 0000000..a498fcd --- /dev/null +++ b/docs/description/redundant_type_annotation.md @@ -0,0 +1,59 @@ +# Redundant Type Annotation + +Variables should not have redundant type annotation + +* **Identifier:** redundant_type_annotation +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +var url = URL() +``` + +```swift +var url: CustomStringConvertible = URL() +``` + +```swift +@IBInspectable var color: UIColor = UIColor.white +``` + +## Triggering Examples + +```swift +var url↓:URL=URL() +``` + +```swift +var url↓:URL = URL(string: "") +``` + +```swift +var url↓: URL = URL() +``` + +```swift +let url↓: URL = URL() +``` + +```swift +lazy var url↓: URL = URL() +``` + +```swift +let alphanumerics↓: CharacterSet = CharacterSet.alphanumerics +``` + +```swift +class ViewController: UIViewController { + func someMethod() { + let myVar↓: Int = Int(5) + } +} +``` \ No newline at end of file diff --git a/docs/description/redundant_void_return.md b/docs/description/redundant_void_return.md new file mode 100644 index 0000000..e2eb652 --- /dev/null +++ b/docs/description/redundant_void_return.md @@ -0,0 +1,104 @@ +# Redundant Void Return + +Returning Void in a function declaration is redundant. + +* **Identifier:** redundant_void_return +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func foo() {} + +``` + +```swift +func foo() -> Int {} + +``` + +```swift +func foo() -> Int -> Void {} + +``` + +```swift +func foo() -> VoidResponse + +``` + +```swift +let foo: (Int) -> Void + +``` + +```swift +func foo() -> Int -> () {} + +``` + +```swift +let foo: (Int) -> () + +``` + +```swift +func foo() -> ()? + +``` + +```swift +func foo() -> ()! + +``` + +```swift +func foo() -> Void? + +``` + +```swift +func foo() -> Void! + +``` + +```swift +struct A { + subscript(key: String) { + print(key) + } +} +``` + +## Triggering Examples + +```swift +func foo()↓ -> Void {} + +``` + +```swift +protocol Foo { + func foo()↓ -> Void +} +``` + +```swift +func foo()↓ -> () {} + +``` + +```swift +func foo()↓ -> ( ) {} +``` + +```swift +protocol Foo { + func foo()↓ -> () +} +``` \ No newline at end of file diff --git a/docs/description/required_deinit.md b/docs/description/required_deinit.md new file mode 100644 index 0000000..7b7bc67 --- /dev/null +++ b/docs/description/required_deinit.md @@ -0,0 +1,82 @@ +# Required Deinit + +Classes should have an explicit deinit method. + +* **Identifier:** required_deinit +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class Apple { + deinit { } +} +``` + +```swift +enum Banana { } +``` + +```swift +protocol Cherry { } +``` + +```swift +struct Damson { } +``` + +```swift +class Outer { + deinit { print("Deinit Outer") } + class Inner { + deinit { print("Deinit Inner") } + } +} +``` + +## Triggering Examples + +```swift +↓class Apple { } +``` + +```swift +↓class Banana: NSObject, Equatable { } +``` + +```swift +↓class Cherry { + // deinit { } +} +``` + +```swift +↓class Damson { + func deinitialize() { } +} +``` + +```swift +class Outer { + func hello() -> String { return "outer" } + deinit { } + ↓class Inner { + func hello() -> String { return "inner" } + } +} +``` + +```swift +↓class Outer { + func hello() -> String { return "outer" } + class Inner { + func hello() -> String { return "inner" } + deinit { } + } +} +``` \ No newline at end of file diff --git a/docs/description/required_enum_case.md b/docs/description/required_enum_case.md new file mode 100644 index 0000000..5bed980 --- /dev/null +++ b/docs/description/required_enum_case.md @@ -0,0 +1,75 @@ +# Required Enum Case + +Enums conforming to a specified protocol must implement a specific case(s). + +* **Identifier:** required_enum_case +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** No protocols configured. In config add 'required_enum_case' to 'opt_in_rules' and config using : + +'required_enum_case: + {Protocol Name}: + {Case Name}:{warning|error} + {Case Name}:{warning|error} + + +## Non Triggering Examples + +```swift +enum MyNetworkResponse: String, NetworkResponsable { + case success, error, notConnected +} +``` + +```swift +enum MyNetworkResponse: String, NetworkResponsable { + case success, error, notConnected(error: Error) +} +``` + +```swift +enum MyNetworkResponse: String, NetworkResponsable { + case success + case error + case notConnected +} +``` + +```swift +enum MyNetworkResponse: String, NetworkResponsable { + case success + case error + case notConnected(error: Error) +} +``` + +## Triggering Examples + +```swift +enum MyNetworkResponse: String, NetworkResponsable { + case success, error +} +``` + +```swift +enum MyNetworkResponse: String, NetworkResponsable { + case success, error +} +``` + +```swift +enum MyNetworkResponse: String, NetworkResponsable { + case success + case error +} +``` + +```swift +enum MyNetworkResponse: String, NetworkResponsable { + case success + case error +} +``` \ No newline at end of file diff --git a/docs/description/return_arrow_whitespace.md b/docs/description/return_arrow_whitespace.md new file mode 100644 index 0000000..a862e5e --- /dev/null +++ b/docs/description/return_arrow_whitespace.md @@ -0,0 +1,87 @@ +# Returning Whitespace + +Return arrow and return type should be separated by a single space or on a separate line. + +* **Identifier:** return_arrow_whitespace +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func abc() -> Int {} + +``` + +```swift +func abc() -> [Int] {} + +``` + +```swift +func abc() -> (Int, Int) {} + +``` + +```swift +var abc = {(param: Int) -> Void in } + +``` + +```swift +func abc() -> + Int {} + +``` + +```swift +func abc() + -> Int {} + +``` + +## Triggering Examples + +```swift +func abc()↓->Int {} + +``` + +```swift +func abc()↓->[Int] {} + +``` + +```swift +func abc()↓->(Int, Int) {} + +``` + +```swift +func abc()↓-> Int {} + +``` + +```swift +func abc()↓ ->Int {} + +``` + +```swift +func abc()↓ -> Int {} + +``` + +```swift +var abc = {(param: Int)↓ ->Bool in } + +``` + +```swift +var abc = {(param: Int)↓->Bool in } + +``` \ No newline at end of file diff --git a/docs/description/shorthand_operator.md b/docs/description/shorthand_operator.md new file mode 100644 index 0000000..a1bfd1b --- /dev/null +++ b/docs/description/shorthand_operator.md @@ -0,0 +1,264 @@ +# Shorthand Operator + +Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning. + +* **Identifier:** shorthand_operator +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** error + +## Non Triggering Examples + +```swift +foo -= 1 +``` + +```swift +foo -= variable +``` + +```swift +foo -= bar.method() +``` + +```swift +self.foo = foo - 1 +``` + +```swift +foo = self.foo - 1 +``` + +```swift +page = ceilf(currentOffset - pageWidth) +``` + +```swift +foo = aMethod(foo - bar) +``` + +```swift +foo = aMethod(bar - foo) +``` + +```swift +foo /= 1 +``` + +```swift +foo /= variable +``` + +```swift +foo /= bar.method() +``` + +```swift +self.foo = foo / 1 +``` + +```swift +foo = self.foo / 1 +``` + +```swift +page = ceilf(currentOffset / pageWidth) +``` + +```swift +foo = aMethod(foo / bar) +``` + +```swift +foo = aMethod(bar / foo) +``` + +```swift +foo += 1 +``` + +```swift +foo += variable +``` + +```swift +foo += bar.method() +``` + +```swift +self.foo = foo + 1 +``` + +```swift +foo = self.foo + 1 +``` + +```swift +page = ceilf(currentOffset + pageWidth) +``` + +```swift +foo = aMethod(foo + bar) +``` + +```swift +foo = aMethod(bar + foo) +``` + +```swift +foo *= 1 +``` + +```swift +foo *= variable +``` + +```swift +foo *= bar.method() +``` + +```swift +self.foo = foo * 1 +``` + +```swift +foo = self.foo * 1 +``` + +```swift +page = ceilf(currentOffset * pageWidth) +``` + +```swift +foo = aMethod(foo * bar) +``` + +```swift +foo = aMethod(bar * foo) +``` + +```swift +var helloWorld = "world!" + helloWorld = "Hello, " + helloWorld +``` + +```swift +angle = someCheck ? angle : -angle +``` + +```swift +seconds = seconds * 60 + value +``` + +## Triggering Examples + +```swift +↓foo = foo - 1 + +``` + +```swift +↓foo = foo - aVariable + +``` + +```swift +↓foo = foo - bar.method() + +``` + +```swift +↓foo.aProperty = foo.aProperty - 1 + +``` + +```swift +↓self.aProperty = self.aProperty - 1 + +``` + +```swift +↓foo = foo / 1 + +``` + +```swift +↓foo = foo / aVariable + +``` + +```swift +↓foo = foo / bar.method() + +``` + +```swift +↓foo.aProperty = foo.aProperty / 1 + +``` + +```swift +↓self.aProperty = self.aProperty / 1 + +``` + +```swift +↓foo = foo + 1 + +``` + +```swift +↓foo = foo + aVariable + +``` + +```swift +↓foo = foo + bar.method() + +``` + +```swift +↓foo.aProperty = foo.aProperty + 1 + +``` + +```swift +↓self.aProperty = self.aProperty + 1 + +``` + +```swift +↓foo = foo * 1 + +``` + +```swift +↓foo = foo * aVariable + +``` + +```swift +↓foo = foo * bar.method() + +``` + +```swift +↓foo.aProperty = foo.aProperty * 1 + +``` + +```swift +↓self.aProperty = self.aProperty * 1 + +``` + +```swift +n = n + i / outputLength +``` + +```swift +n = n - i / outputLength +``` \ No newline at end of file diff --git a/docs/description/single_test_class.md b/docs/description/single_test_class.md new file mode 100644 index 0000000..139f87f --- /dev/null +++ b/docs/description/single_test_class.md @@ -0,0 +1,63 @@ +# Single Test Class + +Test files should contain a single QuickSpec or XCTestCase class. + +* **Identifier:** single_test_class +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class FooTests { } + +``` + +```swift +class FooTests: QuickSpec { } + +``` + +```swift +class FooTests: XCTestCase { } + +``` + +## Triggering Examples + +```swift +↓class FooTests: QuickSpec { } +↓class BarTests: QuickSpec { } +``` + +```swift +↓class FooTests: QuickSpec { } +↓class BarTests: QuickSpec { } +↓class TotoTests: QuickSpec { } +``` + +```swift +↓class FooTests: XCTestCase { } +↓class BarTests: XCTestCase { } +``` + +```swift +↓class FooTests: XCTestCase { } +↓class BarTests: XCTestCase { } +↓class TotoTests: XCTestCase { } +``` + +```swift +↓class FooTests: QuickSpec { } +↓class BarTests: XCTestCase { } +``` + +```swift +↓class FooTests: QuickSpec { } +↓class BarTests: XCTestCase { } +class TotoTests { } +``` \ No newline at end of file diff --git a/docs/description/sorted_first_last.md b/docs/description/sorted_first_last.md new file mode 100644 index 0000000..635b74f --- /dev/null +++ b/docs/description/sorted_first_last.md @@ -0,0 +1,137 @@ +# Min or Max over Sorted First or Last + +Prefer using `min()` or `max()` over `sorted().first` or `sorted().last` + +* **Identifier:** sorted_first_last +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** performance +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let min = myList.min() + +``` + +```swift +let min = myList.min(by: { $0 < $1 }) + +``` + +```swift +let min = myList.min(by: >) + +``` + +```swift +let max = myList.max() + +``` + +```swift +let max = myList.max(by: { $0 < $1 }) + +``` + +```swift +let message = messages.sorted(byKeyPath: #keyPath(Message.timestamp)).last +``` + +```swift +let message = messages.sorted(byKeyPath: "timestamp", ascending: false).first +``` + +```swift +myList.sorted().firstIndex(of: key) +``` + +```swift +myList.sorted().lastIndex(of: key) +``` + +```swift +myList.sorted().firstIndex(where: someFunction) +``` + +```swift +myList.sorted().lastIndex(where: someFunction) +``` + +```swift +myList.sorted().firstIndex { $0 == key } +``` + +```swift +myList.sorted().lastIndex { $0 == key } +``` + +## Triggering Examples + +```swift +↓myList.sorted().first + +``` + +```swift +↓myList.sorted(by: { $0.description < $1.description }).first + +``` + +```swift +↓myList.sorted(by: >).first + +``` + +```swift +↓myList.map { $0 + 1 }.sorted().first + +``` + +```swift +↓myList.sorted(by: someFunction).first + +``` + +```swift +↓myList.map { $0 + 1 }.sorted { $0.description < $1.description }.first + +``` + +```swift +↓myList.sorted().last + +``` + +```swift +↓myList.sorted().last?.something() + +``` + +```swift +↓myList.sorted(by: { $0.description < $1.description }).last + +``` + +```swift +↓myList.map { $0 + 1 }.sorted().last + +``` + +```swift +↓myList.sorted(by: someFunction).last + +``` + +```swift +↓myList.map { $0 + 1 }.sorted { $0.description < $1.description }.last + +``` + +```swift +↓myList.map { $0 + 1 }.sorted { $0.first < $1.first }.last + +``` \ No newline at end of file diff --git a/docs/description/sorted_imports.md b/docs/description/sorted_imports.md new file mode 100644 index 0000000..c2829cf --- /dev/null +++ b/docs/description/sorted_imports.md @@ -0,0 +1,101 @@ +# Sorted Imports + +Imports should be sorted. + +* **Identifier:** sorted_imports +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +import AAA +import BBB +import CCC +import DDD +``` + +```swift +import Alamofire +import API +``` + +```swift +import labc +import Ldef +``` + +```swift +import BBB +// comment +import AAA +import CCC +``` + +```swift +@testable import AAA +import CCC +``` + +```swift +import AAA +@testable import CCC +``` + +```swift +import EEE.A +import FFF.B +#if os(Linux) +import DDD.A +import EEE.B +#else +import CCC +import DDD.B +#endif +import AAA +import BBB +``` + +## Triggering Examples + +```swift +import AAA +import ZZZ +import ↓BBB +import CCC +``` + +```swift +import DDD +// comment +import CCC +import ↓AAA +``` + +```swift +@testable import CCC +import ↓AAA +``` + +```swift +import CCC +@testable import ↓AAA +``` + +```swift +import FFF.B +import ↓EEE.A +#if os(Linux) +import DDD.A +import EEE.B +#else +import DDD.B +import ↓CCC +#endif +import AAA +import BBB +``` \ No newline at end of file diff --git a/docs/description/statement_position.md b/docs/description/statement_position.md new file mode 100644 index 0000000..aa958c4 --- /dev/null +++ b/docs/description/statement_position.md @@ -0,0 +1,63 @@ +# Statement Position + +Else and catch should be on the same line, one space after the previous declaration. + +* **Identifier:** statement_position +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** (statement_mode) default, (severity) warning + +## Non Triggering Examples + +```swift +} else if { +``` + +```swift +} else { +``` + +```swift +} catch { +``` + +```swift +"}else{" +``` + +```swift +struct A { let catchphrase: Int } +let a = A( + catchphrase: 0 +) +``` + +```swift +struct A { let `catch`: Int } +let a = A( + `catch`: 0 +) +``` + +## Triggering Examples + +```swift +↓}else if { +``` + +```swift +↓} else { +``` + +```swift +↓} +catch { +``` + +```swift +↓} + catch { +``` \ No newline at end of file diff --git a/docs/description/static_operator.md b/docs/description/static_operator.md new file mode 100644 index 0000000..f67e9d6 --- /dev/null +++ b/docs/description/static_operator.md @@ -0,0 +1,85 @@ +# Static Operator + +Operators should be declared as static functions, not free functions. + +* **Identifier:** static_operator +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class A: Equatable { + static func == (lhs: A, rhs: A) -> Bool { + return false + } +``` + +```swift +class A: Equatable { + static func == (lhs: A, rhs: A) -> Bool { + return false + } +``` + +```swift +public extension Array where Element == Rule { + static func == (lhs: Array, rhs: Array) -> Bool { + if lhs.count != rhs.count { return false } + return !zip(lhs, rhs).contains { !$0.0.isEqualTo($0.1) } + } +} +``` + +```swift +private extension Optional where Wrapped: Comparable { + static func < (lhs: Optional, rhs: Optional) -> Bool { + switch (lhs, rhs) { + case let (lhs?, rhs?): + return lhs < rhs + case (nil, _?): + return true + default: + return false + } + } +} +``` + +## Triggering Examples + +```swift +↓func == (lhs: A, rhs: A) -> Bool { + return false +} +``` + +```swift +↓func == (lhs: A, rhs: A) -> Bool { + return false +} +``` + +```swift +↓func == (lhs: [Rule], rhs: [Rule]) -> Bool { + if lhs.count != rhs.count { return false } + return !zip(lhs, rhs).contains { !$0.0.isEqualTo($0.1) } +} +``` + +```swift +private ↓func < (lhs: T?, rhs: T?) -> Bool { + switch (lhs, rhs) { + case let (lhs?, rhs?): + return lhs < rhs + case (nil, _?): + return true + default: + return false + } +} +``` \ No newline at end of file diff --git a/docs/description/strict_fileprivate.md b/docs/description/strict_fileprivate.md new file mode 100644 index 0000000..9138208 --- /dev/null +++ b/docs/description/strict_fileprivate.md @@ -0,0 +1,77 @@ +# Strict fileprivate + +`fileprivate` should be avoided. + +* **Identifier:** strict_fileprivate +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +extension String {} +``` + +```swift +private extension String {} +``` + +```swift +public +extension String {} +``` + +```swift +open extension + String {} +``` + +```swift +internal extension String {} +``` + +## Triggering Examples + +```swift +↓fileprivate extension String {} +``` + +```swift +↓fileprivate + extension String {} +``` + +```swift +↓fileprivate extension + String {} +``` + +```swift +extension String { + ↓fileprivate func Something(){} +} +``` + +```swift +class MyClass { + ↓fileprivate let myInt = 4 +} +``` + +```swift +class MyClass { + ↓fileprivate(set) var myInt = 4 +} +``` + +```swift +struct Outter { + struct Inter { + ↓fileprivate struct Inner {} + } +} +``` \ No newline at end of file diff --git a/docs/description/strong_iboutlet.md b/docs/description/strong_iboutlet.md new file mode 100644 index 0000000..ccfad1a --- /dev/null +++ b/docs/description/strong_iboutlet.md @@ -0,0 +1,45 @@ +# Strong IBOutlet + +@IBOutlets shouldn't be declared as weak. + +* **Identifier:** strong_iboutlet +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class ViewController: UIViewController { + @IBOutlet var label: UILabel? +} +``` + +```swift +class ViewController: UIViewController { + weak var label: UILabel? +} +``` + +## Triggering Examples + +```swift +class ViewController: UIViewController { + @IBOutlet weak ↓var label: UILabel? +} +``` + +```swift +class ViewController: UIViewController { + @IBOutlet unowned ↓var label: UILabel! +} +``` + +```swift +class ViewController: UIViewController { + @IBOutlet weak ↓var textField: UITextField? +} +``` \ No newline at end of file diff --git a/docs/description/superfluous_disable_command.md b/docs/description/superfluous_disable_command.md new file mode 100644 index 0000000..c6bfb3b --- /dev/null +++ b/docs/description/superfluous_disable_command.md @@ -0,0 +1,11 @@ +# Superfluous Disable Command + +SwiftLint 'disable' commands are superfluous when the disabled rule would not have triggered a violation in the disabled region. Use " - " if you wish to document a command. + +* **Identifier:** superfluous_disable_command +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning \ No newline at end of file diff --git a/docs/description/switch_case_alignment.md b/docs/description/switch_case_alignment.md new file mode 100644 index 0000000..fe8bac0 --- /dev/null +++ b/docs/description/switch_case_alignment.md @@ -0,0 +1,107 @@ +# Switch and Case Statement Alignment + +Case statements should vertically align with their enclosing switch statement, or indented if configured otherwise. + +* **Identifier:** switch_case_alignment +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, indented_cases: false + +## Non Triggering Examples + +```swift +switch someBool { +case true: // case 1 + print('red') +case false: + /* + case 2 + */ + if case let .someEnum(val) = someFunc() { + print('blue') + } +} +enum SomeEnum { + case innocent +} +``` + +```swift +if aBool { + switch someBool { + case true: + print('red') + case false: + print('blue') + } +} +``` + +```swift +switch someInt { +// comments ignored +case 0: + // zero case + print('Zero') +case 1: + print('One') +default: + print('Some other number') +} +``` + +## Triggering Examples + +```swift +switch someBool { + ↓case true: + print("red") + ↓case false: + print("blue") +} +``` + +```swift +if aBool { + switch someBool { + ↓case true: + print('red') + ↓case false: + print('blue') + } +} +``` + +```swift +switch someInt { + ↓case 0: + print('Zero') + ↓case 1: + print('One') + ↓default: + print('Some other number') +} +``` + +```swift +switch someBool { +case true: + print('red') + ↓case false: + print('blue') +} +``` + +```swift +if aBool { + switch someBool { + ↓case true: + print('red') + case false: + print('blue') + } +} +``` \ No newline at end of file diff --git a/docs/description/switch_case_on_newline.md b/docs/description/switch_case_on_newline.md new file mode 100644 index 0000000..8865551 --- /dev/null +++ b/docs/description/switch_case_on_newline.md @@ -0,0 +1,178 @@ +# Switch Case on Newline + +Cases inside a switch should always be on a newline + +* **Identifier:** switch_case_on_newline +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +/*case 1: */return true +``` + +```swift +//case 1: + return true +``` + +```swift +let x = [caseKey: value] +``` + +```swift +let x = [key: .default] +``` + +```swift +if case let .someEnum(value) = aFunction([key: 2]) { } +``` + +```swift +guard case let .someEnum(value) = aFunction([key: 2]) { } +``` + +```swift +for case let .someEnum(value) = aFunction([key: 2]) { } +``` + +```swift +enum Environment { + case development +} +``` + +```swift +enum Environment { + case development(url: URL) +} +``` + +```swift +enum Environment { + case development(url: URL) // staging +} +``` + +```swift +switch foo { + case 1: + return true +} +``` + +```swift +switch foo { + default: + return true +} +``` + +```swift +switch foo { + case let value: + return true +} +``` + +```swift +switch foo { + case .myCase: // error from network + return true +} +``` + +```swift +switch foo { + case let .myCase(value) where value > 10: + return false +} +``` + +```swift +switch foo { + case let .myCase(value) + where value > 10: + return false +} +``` + +```swift +switch foo { + case let .myCase(code: lhsErrorCode, description: _) + where lhsErrorCode > 10: +return false +} +``` + +```swift +switch foo { + case #selector(aFunction(_:)): + return false + +} +``` + +## Triggering Examples + +```swift +switch foo { + ↓case 1: return true +} +``` + +```swift +switch foo { + ↓case let value: return true +} +``` + +```swift +switch foo { + ↓default: return true +} +``` + +```swift +switch foo { + ↓case "a string": return false +} +``` + +```swift +switch foo { + ↓case .myCase: return false // error from network +} +``` + +```swift +switch foo { + ↓case let .myCase(value) where value > 10: return false +} +``` + +```swift +switch foo { + ↓case #selector(aFunction(_:)): return false + +} +``` + +```swift +switch foo { + ↓case let .myCase(value) + where value > 10: return false +} +``` + +```swift +switch foo { + ↓case .first, + .second: return false +} +``` \ No newline at end of file diff --git a/docs/description/syntactic_sugar.md b/docs/description/syntactic_sugar.md new file mode 100644 index 0000000..d824c7f --- /dev/null +++ b/docs/description/syntactic_sugar.md @@ -0,0 +1,107 @@ +# Syntactic Sugar + +Shorthand syntactic sugar should be used, i.e. [Int] instead of Array. + +* **Identifier:** syntactic_sugar +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let x: [Int] +``` + +```swift +let x: [Int: String] +``` + +```swift +let x: Int? +``` + +```swift +func x(a: [Int], b: Int) -> [Int: Any] +``` + +```swift +let x: Int! +``` + +```swift +extension Array { + func x() { } +} +``` + +```swift +extension Dictionary { + func x() { } +} +``` + +```swift +let x: CustomArray +``` + +```swift +var currentIndex: Array.Index? +``` + +```swift +func x(a: [Int], b: Int) -> Array.Index +``` + +```swift +unsafeBitCast(nonOptionalT, to: Optional.self) +``` + +```swift +type is Optional.Type +``` + +```swift +let x: Foo.Optional +``` + +## Triggering Examples + +```swift +let x: ↓Array +``` + +```swift +let x: ↓Dictionary +``` + +```swift +let x: ↓Optional +``` + +```swift +let x: ↓ImplicitlyUnwrappedOptional +``` + +```swift +func x(a: ↓Array, b: Int) -> [Int: Any] +``` + +```swift +func x(a: [Int], b: Int) -> ↓Dictionary +``` + +```swift +func x(a: ↓Array, b: Int) -> ↓Dictionary +``` + +```swift +let x = ↓Array.array(of: object) +``` + +```swift +let x: ↓Swift.Optional +``` \ No newline at end of file diff --git a/docs/description/todo.md b/docs/description/todo.md new file mode 100644 index 0000000..b42c3ad --- /dev/null +++ b/docs/description/todo.md @@ -0,0 +1,65 @@ +# Todo + +TODOs and FIXMEs should be resolved. + +* **Identifier:** todo +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +// notaTODO: + +``` + +```swift +// notaFIXME: + +``` + +## Triggering Examples + +```swift +// ↓TODO: + +``` + +```swift +// ↓FIXME: + +``` + +```swift +// ↓TODO(note) + +``` + +```swift +// ↓FIXME(note) + +``` + +```swift +/* ↓FIXME: */ + +``` + +```swift +/* ↓TODO: */ + +``` + +```swift +/** ↓FIXME: */ + +``` + +```swift +/** ↓TODO: */ + +``` \ No newline at end of file diff --git a/docs/description/toggle_bool.md b/docs/description/toggle_bool.md new file mode 100644 index 0000000..48ea7ef --- /dev/null +++ b/docs/description/toggle_bool.md @@ -0,0 +1,53 @@ +# Toggle Bool + +Prefer `someBool.toggle()` over `someBool = !someBool`. + +* **Identifier:** toggle_bool +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.2.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +isHidden.toggle() + +``` + +```swift +view.clipsToBounds.toggle() + +``` + +```swift +func foo() { abc.toggle() } +``` + +```swift +view.clipsToBounds = !clipsToBounds + +``` + +```swift +disconnected = !connected + +``` + +## Triggering Examples + +```swift +↓isHidden = !isHidden + +``` + +```swift +↓view.clipsToBounds = !view.clipsToBounds + +``` + +```swift +func foo() { ↓abc = !abc } +``` \ No newline at end of file diff --git a/docs/description/trailing_closure.md b/docs/description/trailing_closure.md new file mode 100644 index 0000000..822fd2e --- /dev/null +++ b/docs/description/trailing_closure.md @@ -0,0 +1,77 @@ +# Trailing Closure + +Trailing closure syntax should be used whenever possible. + +* **Identifier:** trailing_closure +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, only_single_muted_parameter: false + +## Non Triggering Examples + +```swift +foo.map { $0 + 1 } + +``` + +```swift +foo.bar() + +``` + +```swift +foo.reduce(0) { $0 + 1 } + +``` + +```swift +if let foo = bar.map({ $0 + 1 }) { } + +``` + +```swift +foo.something(param1: { $0 }, param2: { $0 + 1 }) + +``` + +```swift +offsets.sorted { $0.offset < $1.offset } + +``` + +```swift +foo.something({ return 1 }()) +``` + +```swift +foo.something({ return $0 }(1)) +``` + +```swift +foo.something(0, { return 1 }()) +``` + +## Triggering Examples + +```swift +↓foo.map({ $0 + 1 }) + +``` + +```swift +↓foo.reduce(0, combine: { $0 + 1 }) + +``` + +```swift +↓offsets.sorted(by: { $0.offset < $1.offset }) + +``` + +```swift +↓foo.something(0, { $0 + 1 }) + +``` \ No newline at end of file diff --git a/docs/description/trailing_comma.md b/docs/description/trailing_comma.md new file mode 100644 index 0000000..11ffd6c --- /dev/null +++ b/docs/description/trailing_comma.md @@ -0,0 +1,111 @@ +# Trailing Comma + +Trailing commas in arrays and dictionaries should be avoided/enforced. + +* **Identifier:** trailing_comma +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, mandatory_comma: false + +## Non Triggering Examples + +```swift +let foo = [1, 2, 3] + +``` + +```swift +let foo = [] + +``` + +```swift +let foo = [:] + +``` + +```swift +let foo = [1: 2, 2: 3] + +``` + +```swift +let foo = [Void]() + +``` + +```swift +let example = [ 1, + 2 + // 3, +] +``` + +```swift +foo([1: "\(error)"]) + +``` + +## Triggering Examples + +```swift +let foo = [1, 2, 3↓,] + +``` + +```swift +let foo = [1, 2, 3↓, ] + +``` + +```swift +let foo = [1, 2, 3 ↓,] + +``` + +```swift +let foo = [1: 2, 2: 3↓, ] + +``` + +```swift +struct Bar { + let foo = [1: 2, 2: 3↓, ] +} + +``` + +```swift +let foo = [1, 2, 3↓,] + [4, 5, 6↓,] + +``` + +```swift +let example = [ 1, +2↓, + // 3, +] +``` + +```swift +let foo = ["אבג", "αβγ", "🇺🇸"↓,] + +``` + +```swift +class C { + #if true + func f() { + let foo = [1, 2, 3↓,] + } + #endif +} +``` + +```swift +foo([1: "\(error)"↓,]) + +``` \ No newline at end of file diff --git a/docs/description/trailing_newline.md b/docs/description/trailing_newline.md new file mode 100644 index 0000000..4847ce7 --- /dev/null +++ b/docs/description/trailing_newline.md @@ -0,0 +1,30 @@ +# Trailing Newline + +Files should have a single trailing newline. + +* **Identifier:** trailing_newline +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let a = 0 + +``` + +## Triggering Examples + +```swift +let a = 0 +``` + +```swift +let a = 0 + + +``` \ No newline at end of file diff --git a/docs/description/trailing_semicolon.md b/docs/description/trailing_semicolon.md new file mode 100644 index 0000000..15e18d2 --- /dev/null +++ b/docs/description/trailing_semicolon.md @@ -0,0 +1,46 @@ +# Trailing Semicolon + +Lines should not have trailing semicolons. + +* **Identifier:** trailing_semicolon +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let a = 0 + +``` + +## Triggering Examples + +```swift +let a = 0↓; + +``` + +```swift +let a = 0↓; +let b = 1 + +``` + +```swift +let a = 0↓;; + +``` + +```swift +let a = 0↓; ;; + +``` + +```swift +let a = 0↓; ; ; + +``` \ No newline at end of file diff --git a/docs/description/trailing_whitespace.md b/docs/description/trailing_whitespace.md new file mode 100644 index 0000000..4771282 --- /dev/null +++ b/docs/description/trailing_whitespace.md @@ -0,0 +1,50 @@ +# Trailing Whitespace + +Lines should not have trailing whitespace. + +* **Identifier:** trailing_whitespace +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, ignores_empty_lines: false, ignores_comments: true + +## Non Triggering Examples + +```swift +let name: String + +``` + +```swift +// + +``` + +```swift +// + +``` + +```swift +let name: String // + +``` + +```swift +let name: String // + +``` + +## Triggering Examples + +```swift +let name: String + +``` + +```swift +/* */ let name: String + +``` \ No newline at end of file diff --git a/docs/description/type_body_length.md b/docs/description/type_body_length.md new file mode 100644 index 0000000..eaba6b7 --- /dev/null +++ b/docs/description/type_body_length.md @@ -0,0 +1,3120 @@ +# Type Body Length + +Type bodies should not span too many lines. + +* **Identifier:** type_body_length +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** metrics +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning: 200, error: 350 + +## Non Triggering Examples + +```swift +class Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +} + +``` + +```swift +class Abc { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +``` + +```swift +class Abc { +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +} + +``` + +```swift +class Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 + +/* this is +a multiline comment +*/ +} + +``` + +```swift +struct Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +} + +``` + +```swift +struct Abc { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +``` + +```swift +struct Abc { +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +} + +``` + +```swift +struct Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 + +/* this is +a multiline comment +*/ +} + +``` + +```swift +enum Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +} + +``` + +```swift +enum Abc { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +``` + +```swift +enum Abc { +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +} + +``` + +```swift +enum Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 + +/* this is +a multiline comment +*/ +} + +``` + +## Triggering Examples + +```swift +↓class Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +} + +``` + +```swift +↓struct Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +} + +``` + +```swift +↓enum Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +} + +``` \ No newline at end of file diff --git a/docs/description/type_contents_order.md b/docs/description/type_contents_order.md new file mode 100644 index 0000000..93dfc54 --- /dev/null +++ b/docs/description/type_contents_order.md @@ -0,0 +1,249 @@ +# Type Contents Order + +Specifies the order of subtypes, properties, methods & more within a type. + +* **Identifier:** type_contents_order +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, order: [[SwiftLintFramework.TypeContent.case], [SwiftLintFramework.TypeContent.typeAlias, SwiftLintFramework.TypeContent.associatedType], [SwiftLintFramework.TypeContent.subtype], [SwiftLintFramework.TypeContent.typeProperty], [SwiftLintFramework.TypeContent.instanceProperty], [SwiftLintFramework.TypeContent.ibInspectable], [SwiftLintFramework.TypeContent.ibOutlet], [SwiftLintFramework.TypeContent.initializer], [SwiftLintFramework.TypeContent.typeMethod], [SwiftLintFramework.TypeContent.viewLifeCycleMethod], [SwiftLintFramework.TypeContent.ibAction], [SwiftLintFramework.TypeContent.otherMethod], [SwiftLintFramework.TypeContent.subscript], [SwiftLintFramework.TypeContent.deinitializer]] + +## Non Triggering Examples + +```swift +class TestViewController: UIViewController { + // Type Aliases + typealias CompletionHandler = ((TestEnum) -> Void) + + // Subtypes + class TestClass { + // 10 lines + } + + struct TestStruct { + // 3 lines + } + + enum TestEnum { + // 5 lines + } + + // Type Properties + static let cellIdentifier: String = "AmazingCell" + + // Instance Properties + var shouldLayoutView1: Bool! + weak var delegate: TestViewControllerDelegate? + private var hasLayoutedView1: Bool = false + private var hasLayoutedView2: Bool = false + + private var hasAnyLayoutedView: Bool { + return hasLayoutedView1 || hasLayoutedView2 + } + + // IBOutlets + @IBOutlet private var view1: UIView! + @IBOutlet private var view2: UIView! + + // Initializers + override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // Type Methods + static func makeViewController() -> TestViewController { + // some code + } + + // View Life-Cycle Methods + override func viewDidLoad() { + super.viewDidLoad() + + view1.setNeedsLayout() + view1.layoutIfNeeded() + hasLayoutedView1 = true + } + + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + + view2.setNeedsLayout() + view2.layoutIfNeeded() + hasLayoutedView2 = true + } + + // IBActions + @IBAction func goNextButtonPressed() { + goToNextVc() + delegate?.didPressTrackedButton() + } + + // Other Methods + func goToNextVc() { /* TODO */ } + + func goToInfoVc() { /* TODO */ } + + func goToRandomVc() { + let viewCtrl = getRandomVc() + present(viewCtrl, animated: true) + } + + private func getRandomVc() -> UIViewController { return UIViewController() } + + // Subscripts + subscript(_ someIndexThatIsNotEvenUsed: Int) -> String { + get { + return "This is just a test" + } + + set { + log.warning("Just a test", newValue) + } + } + + deinit { + log.debug("deinit") + }, +} +``` + +## Triggering Examples + +```swift +class TestViewController: UIViewController { + // Subtypes + ↓class TestClass { + // 10 lines + } + + // Type Aliases + typealias CompletionHandler = ((TestEnum) -> Void) +} +``` + +```swift +class TestViewController: UIViewController { + // Stored Type Properties + ↓static let cellIdentifier: String = "AmazingCell" + + // Subtypes + class TestClass { + // 10 lines + } +} +``` + +```swift +class TestViewController: UIViewController { + // Stored Instance Properties + ↓var shouldLayoutView1: Bool! + + // Stored Type Properties + static let cellIdentifier: String = "AmazingCell" +} +``` + +```swift +class TestViewController: UIViewController { + // IBOutlets + @IBOutlet private ↓var view1: UIView! + + // Computed Instance Properties + private var hasAnyLayoutedView: Bool { + return hasLayoutedView1 || hasLayoutedView2 + } +} +``` + +```swift +class TestViewController: UIViewController { + + // deinitializer + ↓deinit { + log.debug("deinit") + } + + // Initializers + override ↓init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + + // IBOutlets + @IBOutlet private var view1: UIView! + @IBOutlet private var view2: UIView! +} +``` + +```swift +class TestViewController: UIViewController { + // View Life-Cycle Methods + override ↓func viewDidLoad() { + super.viewDidLoad() + + view1.setNeedsLayout() + view1.layoutIfNeeded() + hasLayoutedView1 = true + } + + // Type Methods + static func makeViewController() -> TestViewController { + // some code + } +} +``` + +```swift +class TestViewController: UIViewController { + // IBActions + @IBAction ↓func goNextButtonPressed() { + goToNextVc() + delegate?.didPressTrackedButton() + } + + // View Life-Cycle Methods + override func viewDidLoad() { + super.viewDidLoad() + + view1.setNeedsLayout() + view1.layoutIfNeeded() + hasLayoutedView1 = true + } +} +``` + +```swift +class TestViewController: UIViewController { + // Other Methods + ↓func goToNextVc() { /* TODO */ } + + // IBActions + @IBAction func goNextButtonPressed() { + goToNextVc() + delegate?.didPressTrackedButton() + } +} +``` + +```swift +class TestViewController: UIViewController { + // Subscripts + ↓subscript(_ someIndexThatIsNotEvenUsed: Int) -> String { + get { + return "This is just a test" + } + + set { + log.warning("Just a test", newValue) + } + } + + // MARK: Other Methods + func goToNextVc() { /* TODO */ } +} +``` \ No newline at end of file diff --git a/docs/description/type_name.md b/docs/description/type_name.md new file mode 100644 index 0000000..84d6649 --- /dev/null +++ b/docs/description/type_name.md @@ -0,0 +1,231 @@ +# Type Name + +Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 40 characters in length. + +* **Identifier:** type_name +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** (min_length) w/e: 3/0, (max_length) w/e: 40/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true + +## Non Triggering Examples + +```swift +class MyType {} +``` + +```swift +private class _MyType {} +``` + +```swift +class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} +``` + +```swift +class MyView_Previews: PreviewProvider +``` + +```swift +private class _MyView_Previews: PreviewProvider +``` + +```swift +struct MyType {} +``` + +```swift +private struct _MyType {} +``` + +```swift +struct AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} +``` + +```swift +struct MyView_Previews: PreviewProvider +``` + +```swift +private struct _MyView_Previews: PreviewProvider +``` + +```swift +enum MyType {} +``` + +```swift +private enum _MyType {} +``` + +```swift +enum AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} +``` + +```swift +enum MyView_Previews: PreviewProvider +``` + +```swift +private enum _MyView_Previews: PreviewProvider +``` + +```swift +typealias Foo = Void +``` + +```swift +private typealias Foo = Void +``` + +```swift +protocol Foo { + associatedtype Bar +} +``` + +```swift +protocol Foo { + associatedtype Bar: Equatable +} +``` + +```swift +enum MyType { +case value +} +``` + +## Triggering Examples + +```swift +class ↓myType {} +``` + +```swift +class ↓_MyType {} +``` + +```swift +private class ↓MyType_ {} +``` + +```swift +class ↓My {} +``` + +```swift +class ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} +``` + +```swift +class ↓MyView_Previews +``` + +```swift +private class ↓_MyView_Previews +``` + +```swift +class ↓MyView_Previews_Previews: PreviewProvider +``` + +```swift +struct ↓myType {} +``` + +```swift +struct ↓_MyType {} +``` + +```swift +private struct ↓MyType_ {} +``` + +```swift +struct ↓My {} +``` + +```swift +struct ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} +``` + +```swift +struct ↓MyView_Previews +``` + +```swift +private struct ↓_MyView_Previews +``` + +```swift +struct ↓MyView_Previews_Previews: PreviewProvider +``` + +```swift +enum ↓myType {} +``` + +```swift +enum ↓_MyType {} +``` + +```swift +private enum ↓MyType_ {} +``` + +```swift +enum ↓My {} +``` + +```swift +enum ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} +``` + +```swift +enum ↓MyView_Previews +``` + +```swift +private enum ↓_MyView_Previews +``` + +```swift +enum ↓MyView_Previews_Previews: PreviewProvider +``` + +```swift +typealias ↓X = Void +``` + +```swift +private typealias ↓Foo_Bar = Void +``` + +```swift +private typealias ↓foo = Void +``` + +```swift +typealias ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA = Void +``` + +```swift +protocol Foo { + associatedtype ↓X +} +``` + +```swift +protocol Foo { + associatedtype ↓Foo_Bar: Equatable +} +``` + +```swift +protocol Foo { + associatedtype ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +} +``` \ No newline at end of file diff --git a/docs/description/unavailable_function.md b/docs/description/unavailable_function.md new file mode 100644 index 0000000..10a423b --- /dev/null +++ b/docs/description/unavailable_function.md @@ -0,0 +1,54 @@ +# Unavailable Function + +Unimplemented functions should be marked as unavailable. + +* **Identifier:** unavailable_function +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class ViewController: UIViewController { + @available(*, unavailable) + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} +``` + +```swift +func jsonValue(_ jsonString: String) -> NSObject { + let data = jsonString.data(using: .utf8)! + let result = try! JSONSerialization.jsonObject(with: data, options: []) + if let dict = (result as? [String: Any])?.bridge() { + return dict + } else if let array = (result as? [Any])?.bridge() { + return array + } + fatalError() +} +``` + +## Triggering Examples + +```swift +class ViewController: UIViewController { + public required ↓init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} +``` + +```swift +class ViewController: UIViewController { + public required ↓init?(coder aDecoder: NSCoder) { + let reason = "init(coder:) has not been implemented" + fatalError(reason) + } +} +``` \ No newline at end of file diff --git a/docs/description/unneeded_break_in_switch.md b/docs/description/unneeded_break_in_switch.md new file mode 100644 index 0000000..21f4e4e --- /dev/null +++ b/docs/description/unneeded_break_in_switch.md @@ -0,0 +1,82 @@ +# Unneeded Break in Switch + +Avoid using unneeded break statements. + +* **Identifier:** unneeded_break_in_switch +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +switch foo { +case .bar: + break +} +``` + +```swift +switch foo { +default: + break +} +``` + +```swift +switch foo { +case .bar: + for i in [0, 1, 2] { break } +} +``` + +```swift +switch foo { +case .bar: + if true { break } +} +``` + +```swift +switch foo { +case .bar: + something() +} +``` + +## Triggering Examples + +```swift +switch foo { +case .bar: + something() + ↓break +} +``` + +```swift +switch foo { +case .bar: + something() + ↓break // comment +} +``` + +```swift +switch foo { +default: + something() + ↓break +} +``` + +```swift +switch foo { +case .foo, .foo2 where condition: + something() + ↓break +} +``` \ No newline at end of file diff --git a/docs/description/unneeded_parentheses_in_closure_argument.md b/docs/description/unneeded_parentheses_in_closure_argument.md new file mode 100644 index 0000000..1e357fc --- /dev/null +++ b/docs/description/unneeded_parentheses_in_closure_argument.md @@ -0,0 +1,84 @@ +# Unneeded Parentheses in Closure Argument + +Parentheses are not needed when declaring closure arguments. + +* **Identifier:** unneeded_parentheses_in_closure_argument +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let foo = { (bar: Int) in } + +``` + +```swift +let foo = { bar, _ in } + +``` + +```swift +let foo = { bar in } + +``` + +```swift +let foo = { bar -> Bool in return true } + +``` + +## Triggering Examples + +```swift +call(arg: { ↓(bar) in }) + +``` + +```swift +call(arg: { ↓(bar, _) in }) + +``` + +```swift +let foo = { ↓(bar) -> Bool in return true } + +``` + +```swift +foo.map { ($0, $0) }.forEach { ↓(x, y) in } +``` + +```swift +foo.bar { [weak self] ↓(x, y) in } +``` + +```swift +[].first { ↓(temp) in + [].first { ↓(temp) in + [].first { ↓(temp) in + _ = temp + return false + } + return false + } + return false +} +``` + +```swift +[].first { temp in + [].first { ↓(temp) in + [].first { ↓(temp) in + _ = temp + return false + } + return false + } + return false +} +``` \ No newline at end of file diff --git a/docs/description/unowned_variable_capture.md b/docs/description/unowned_variable_capture.md new file mode 100644 index 0000000..4b446ce --- /dev/null +++ b/docs/description/unowned_variable_capture.md @@ -0,0 +1,51 @@ +# Unowned Variable Capture + +Prefer capturing references as weak to avoid potential crashes. + +* **Identifier:** unowned_variable_capture +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +foo { [weak self] in _ } +``` + +```swift +foo { [weak self] param in _ } +``` + +```swift +foo { [weak bar] in _ } +``` + +```swift +foo { [weak bar] param in _ } +``` + +```swift +foo { bar in _ } +``` + +```swift +foo { $0 } +``` + +## Triggering Examples + +```swift +foo { [↓unowned self] in _ } +``` + +```swift +foo { [↓unowned bar] in _ } +``` + +```swift +foo { [bar, ↓unowned self] in _ } +``` \ No newline at end of file diff --git a/docs/description/untyped_error_in_catch.md b/docs/description/untyped_error_in_catch.md new file mode 100644 index 0000000..669fd66 --- /dev/null +++ b/docs/description/untyped_error_in_catch.md @@ -0,0 +1,84 @@ +# Untyped Error in Catch + +Catch statements should not declare error variables without type casting. + +* **Identifier:** untyped_error_in_catch +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +do { + try foo() +} catch {} +``` + +```swift +do { + try foo() +} catch Error.invalidOperation { +} catch {} +``` + +```swift +do { + try foo() +} catch let error as MyError { +} catch {} +``` + +```swift +do { + try foo() +} catch var error as MyError { +} catch {} +``` + +## Triggering Examples + +```swift +do { + try foo() +} ↓catch var error {} +``` + +```swift +do { + try foo() +} ↓catch let error {} +``` + +```swift +do { + try foo() +} ↓catch let someError {} +``` + +```swift +do { + try foo() +} ↓catch var someError {} +``` + +```swift +do { + try foo() +} ↓catch let e {} +``` + +```swift +do { + try foo() +} ↓catch(let error) {} +``` + +```swift +do { + try foo() +} ↓catch (let error) {} +``` \ No newline at end of file diff --git a/docs/description/unused_capture_list.md b/docs/description/unused_capture_list.md new file mode 100644 index 0000000..4edeca0 --- /dev/null +++ b/docs/description/unused_capture_list.md @@ -0,0 +1,87 @@ +# Unused Capture List + +Unused reference in a capture list should be removed. + +* **Identifier:** unused_capture_list +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.2.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +[1, 2].map { [weak self] num in + self?.handle(num) +} +``` + +```swift +let failure: Failure = { [weak self, unowned delegate = self.delegate!] foo in + delegate.handle(foo, self) +} +``` + +```swift +numbers.forEach({ + [weak handler] in + handler?.handle($0) +}) +``` + +```swift +withEnvironment(apiService: MockService(fetchProjectResponse: project)) { + [Device.phone4_7inch, Device.phone5_8inch, Device.pad].forEach { device in + device.handle() + } +} +``` + +```swift +{ [foo] _ in foo.bar() }() +``` + +```swift +sizes.max().flatMap { [(offset: offset, size: $0)] } ?? [] +``` + +## Triggering Examples + +```swift +[1, 2].map { [↓weak self] num in + print(num) +} +``` + +```swift +let failure: Failure = { [weak self, ↓unowned delegate = self.delegate!] foo in + self?.handle(foo) +} +``` + +```swift +let failure: Failure = { [↓weak self, ↓unowned delegate = self.delegate!] foo in + print(foo) +} +``` + +```swift +numbers.forEach({ + [weak handler] in + print($0) +}) +``` + +```swift +withEnvironment(apiService: MockService(fetchProjectResponse: project)) { [↓foo] in + [Device.phone4_7inch, Device.phone5_8inch, Device.pad].forEach { device in + device.handle() + } +} +``` + +```swift +{ [↓foo] in _ }() +``` \ No newline at end of file diff --git a/docs/description/unused_closure_parameter.md b/docs/description/unused_closure_parameter.md new file mode 100644 index 0000000..ac25104 --- /dev/null +++ b/docs/description/unused_closure_parameter.md @@ -0,0 +1,172 @@ +# Unused Closure Parameter + +Unused parameter in a closure should be replaced with _. + +* **Identifier:** unused_closure_parameter +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +[1, 2].map { $0 + 1 } + +``` + +```swift +[1, 2].map({ $0 + 1 }) + +``` + +```swift +[1, 2].map { number in + number + 1 +} + +``` + +```swift +[1, 2].map { _ in + 3 +} + +``` + +```swift +[1, 2].something { number, idx in + return number * idx +} + +``` + +```swift +let isEmpty = [1, 2].isEmpty() + +``` + +```swift +violations.sorted(by: { lhs, rhs in + return lhs.location > rhs.location +}) + +``` + +```swift +rlmConfiguration.migrationBlock.map { rlmMigration in +return { migration, schemaVersion in +rlmMigration(migration.rlmMigration, schemaVersion) +} +} +``` + +```swift +genericsFunc { (a: Type, b) in +a + b +} + +``` + +```swift +var label: UILabel = { (lbl: UILabel) -> UILabel in + lbl.backgroundColor = .red + return lbl +}(UILabel()) + +``` + +```swift +hoge(arg: num) { num in + return num +} + +``` + +```swift +({ (manager: FileManager) in + print(manager) +})(FileManager.default) +``` + +```swift +withPostSideEffect { input in + if true { print("\(input)") } +} +``` + +```swift +viewModel?.profileImage.didSet(weak: self) { (self, profileImage) in + self.profileImageView.image = profileImage +} +``` + +## Triggering Examples + +```swift +[1, 2].map { ↓number in + return 3 +} + +``` + +```swift +[1, 2].map { ↓number in + return numberWithSuffix +} + +``` + +```swift +[1, 2].map { ↓number in + return 3 // number +} + +``` + +```swift +[1, 2].map { ↓number in + return 3 "number" +} + +``` + +```swift +[1, 2].something { number, ↓idx in + return number +} + +``` + +```swift +genericsFunc { (↓number: TypeA, idx: TypeB) in return idx +} + +``` + +```swift +hoge(arg: num) { ↓num in +} + +``` + +```swift +fooFunc { ↓아 in + } +``` + +```swift +func foo () { + bar { ↓number in + return 3 +} + +``` + +```swift +viewModel?.profileImage.didSet(weak: self) { (↓self, profileImage) in + profileImageView.image = profileImage +} +``` \ No newline at end of file diff --git a/docs/description/unused_control_flow_label.md b/docs/description/unused_control_flow_label.md new file mode 100644 index 0000000..79c68cf --- /dev/null +++ b/docs/description/unused_control_flow_label.md @@ -0,0 +1,84 @@ +# Unused Control Flow Label + +Unused control flow label should be removed. + +* **Identifier:** unused_control_flow_label +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +loop: while true { break loop } +``` + +```swift +loop: while true { continue loop } +``` + +```swift +loop: + while true { break loop } +``` + +```swift +while true { break } +``` + +```swift +loop: for x in array { break loop } +``` + +```swift +label: switch number { +case 1: print("1") +case 2: print("2") +default: break label +} +``` + +```swift +loop: repeat { + if x == 10 { + break loop + } +} while true +``` + +## Triggering Examples + +```swift +↓loop: while true { break } +``` + +```swift +↓loop: while true { break loop1 } +``` + +```swift +↓loop: while true { break outerLoop } +``` + +```swift +↓loop: for x in array { break } +``` + +```swift +↓label: switch number { +case 1: print("1") +case 2: print("2") +default: break +} +``` + +```swift +↓loop: repeat { + if x == 10 { + break + } +} while true +``` \ No newline at end of file diff --git a/docs/description/unused_declaration.md b/docs/description/unused_declaration.md new file mode 100644 index 0000000..cf56ad8 --- /dev/null +++ b/docs/description/unused_declaration.md @@ -0,0 +1,85 @@ +# Unused Declaration + +Declarations should be referenced at least once within all files linted. + +* **Identifier:** unused_declaration +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** Yes +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** severity: error, include_public_and_open: false + +## Non Triggering Examples + +```swift +let kConstant = 0 +_ = kConstant +``` + +```swift +enum Change { + case insert(T) + case delete(T) +} + +extension Sequence { + func deletes() -> [T] where Element == Change { + return compactMap { operation in + if case .delete(let value) = operation { + return value + } else { + return nil + } + } + } +} + +let changes = [Change.insert(0), .delete(0)] +changes.deletes() +``` + +```swift +struct Item {} +struct ResponseModel: Codable { + let items: [Item] + + enum CodingKeys: String, CodingKey { + case items = "ResponseItems" + } +} + +_ = ResponseModel(items: [Item()]).items +``` + +```swift +class ResponseModel { + @objc func foo() { + } +} +_ = ResponseModel() +``` + +## Triggering Examples + +```swift +let ↓kConstant = 0 +``` + +```swift +struct Item {} +struct ↓ResponseModel: Codable { + let ↓items: [Item] + + enum ↓CodingKeys: String { + case items = "ResponseItems" + } +} +``` + +```swift +class ↓ResponseModel { + func ↓foo() { + } +} +``` \ No newline at end of file diff --git a/docs/description/unused_enumerated.md b/docs/description/unused_enumerated.md new file mode 100644 index 0000000..3afb742 --- /dev/null +++ b/docs/description/unused_enumerated.md @@ -0,0 +1,80 @@ +# Unused Enumerated + +When the index or the item is not used, `.enumerated()` can be removed. + +* **Identifier:** unused_enumerated +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +for (idx, foo) in bar.enumerated() { } + +``` + +```swift +for (_, foo) in bar.enumerated().something() { } + +``` + +```swift +for (_, foo) in bar.something() { } + +``` + +```swift +for foo in bar.enumerated() { } + +``` + +```swift +for foo in bar { } + +``` + +```swift +for (idx, _) in bar.enumerated().something() { } + +``` + +```swift +for (idx, _) in bar.something() { } + +``` + +```swift +for idx in bar.indices { } + +``` + +```swift +for (section, (event, _)) in data.enumerated() {} + +``` + +## Triggering Examples + +```swift +for (↓_, foo) in bar.enumerated() { } + +``` + +```swift +for (↓_, foo) in abc.bar.enumerated() { } + +``` + +```swift +for (↓_, foo) in abc.something().enumerated() { } + +``` + +```swift +for (idx, ↓_) in bar.enumerated() { } + +``` \ No newline at end of file diff --git a/docs/description/unused_import.md b/docs/description/unused_import.md new file mode 100644 index 0000000..534c6c7 --- /dev/null +++ b/docs/description/unused_import.md @@ -0,0 +1,83 @@ +# Unused Import + +All imported modules should be required to make the file compile. + +* **Identifier:** unused_import +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** lint +* **Analyzer rule:** Yes +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** severity: warning, require_explicit_imports: false, allowed_transitive_imports: [] + +## Non Triggering Examples + +```swift +import Dispatch // This is used +dispatchMain() +``` + +```swift +@testable import Dispatch +dispatchMain() +``` + +```swift +import Foundation +@objc +class A {} +``` + +```swift +import UnknownModule +func foo(error: Swift.Error) {} +``` + +```swift +import Foundation +import ObjectiveC +let 👨‍👩‍👧‍👦 = #selector(NSArray.contains(_:)) +👨‍👩‍👧‍👦 == 👨‍👩‍👧‍👦 +``` + +## Triggering Examples + +```swift +↓import Dispatch +struct A { + static func dispatchMain() {} +} +A.dispatchMain() +``` + +```swift +↓import Foundation // This is unused +struct A { + static func dispatchMain() {} +} +A.dispatchMain() +↓import Dispatch + +``` + +```swift +↓import Foundation +dispatchMain() +``` + +```swift +↓import Foundation +// @objc +class A {} +``` + +```swift +↓import Foundation +import UnknownModule +func foo(error: Swift.Error) {} +``` + +```swift +↓import Foundation +typealias Foo = CFData +``` \ No newline at end of file diff --git a/docs/description/unused_optional_binding.md b/docs/description/unused_optional_binding.md new file mode 100644 index 0000000..2d27f7e --- /dev/null +++ b/docs/description/unused_optional_binding.md @@ -0,0 +1,104 @@ +# Unused Optional Binding + +Prefer `!= nil` over `let _ =` + +* **Identifier:** unused_optional_binding +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, ignore_optional_try: false + +## Non Triggering Examples + +```swift +if let bar = Foo.optionalValue { +} + +``` + +```swift +if let (_, second) = getOptionalTuple() { +} + +``` + +```swift +if let (_, asd, _) = getOptionalTuple(), let bar = Foo.optionalValue { +} + +``` + +```swift +if foo() { let _ = bar() } + +``` + +```swift +if foo() { _ = bar() } + +``` + +```swift +if case .some(_) = self {} +``` + +```swift +if let point = state.find({ _ in true }) {} +``` + +## Triggering Examples + +```swift +if let ↓_ = Foo.optionalValue { +} + +``` + +```swift +if let a = Foo.optionalValue, let ↓_ = Foo.optionalValue2 { +} + +``` + +```swift +guard let a = Foo.optionalValue, let ↓_ = Foo.optionalValue2 { +} + +``` + +```swift +if let (first, second) = getOptionalTuple(), let ↓_ = Foo.optionalValue { +} + +``` + +```swift +if let (first, _) = getOptionalTuple(), let ↓_ = Foo.optionalValue { +} + +``` + +```swift +if let (_, second) = getOptionalTuple(), let ↓_ = Foo.optionalValue { +} + +``` + +```swift +if let ↓(_, _, _) = getOptionalTuple(), let bar = Foo.optionalValue { +} + +``` + +```swift +func foo() { +if let ↓_ = bar { +} + +``` + +```swift +if case .some(let ↓_) = self {} +``` \ No newline at end of file diff --git a/docs/description/unused_setter_value.md b/docs/description/unused_setter_value.md new file mode 100644 index 0000000..ed07a1a --- /dev/null +++ b/docs/description/unused_setter_value.md @@ -0,0 +1,104 @@ +# Unused Setter Value + +Setter value is not used. + +* **Identifier:** unused_setter_value +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +var aValue: String { + get { + return Persister.shared.aValue + } + set { + Persister.shared.aValue = newValue + } +} +``` + +```swift +var aValue: String { + set { + Persister.shared.aValue = newValue + } + get { + return Persister.shared.aValue + } +} +``` + +```swift +var aValue: String { + get { + return Persister.shared.aValue + } + set(value) { + Persister.shared.aValue = value + } +} +``` + +## Triggering Examples + +```swift +var aValue: String { + get { + return Persister.shared.aValue + } + ↓set { + Persister.shared.aValue = aValue + } +} +``` + +```swift +var aValue: String { + ↓set { + Persister.shared.aValue = aValue + } + get { + return Persister.shared.aValue + } +} +``` + +```swift +var aValue: String { + get { + return Persister.shared.aValue + } + ↓set { + Persister.shared.aValue = aValue + } +} +``` + +```swift +var aValue: String { + get { + let newValue = Persister.shared.aValue + return newValue + } + ↓set { + Persister.shared.aValue = aValue + } +} +``` + +```swift +var aValue: String { + get { + return Persister.shared.aValue + } + ↓set(value) { + Persister.shared.aValue = aValue + } +} +``` \ No newline at end of file diff --git a/docs/description/valid_ibinspectable.md b/docs/description/valid_ibinspectable.md new file mode 100644 index 0000000..964ae53 --- /dev/null +++ b/docs/description/valid_ibinspectable.md @@ -0,0 +1,125 @@ +# Valid IBInspectable + +@IBInspectable should be applied to variables only, have its type explicit and be of a supported type + +* **Identifier:** valid_ibinspectable +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class Foo { + @IBInspectable private var x: Int +} +``` + +```swift +class Foo { + @IBInspectable private var x: String? +} +``` + +```swift +class Foo { + @IBInspectable private var x: String! +} +``` + +```swift +class Foo { + @IBInspectable private var count: Int = 0 +} +``` + +```swift +class Foo { + private var notInspectable = 0 +} +``` + +```swift +class Foo { + private let notInspectable: Int +} +``` + +```swift +class Foo { + private let notInspectable: UInt8 +} +``` + +```swift +extension Foo { + @IBInspectable var color: UIColor { + set { + self.bar.textColor = newValue + } + + get { + return self.bar.textColor + } + } +} +``` + +## Triggering Examples + +```swift +class Foo { + @IBInspectable private ↓let count: Int +} +``` + +```swift +class Foo { + @IBInspectable private ↓var insets: UIEdgeInsets +} +``` + +```swift +class Foo { + @IBInspectable private ↓var count = 0 +} +``` + +```swift +class Foo { + @IBInspectable private ↓var count: Int? +} +``` + +```swift +class Foo { + @IBInspectable private ↓var count: Int! +} +``` + +```swift +class Foo { + @IBInspectable private ↓var x: ImplicitlyUnwrappedOptional +} +``` + +```swift +class Foo { + @IBInspectable private ↓var count: Optional +} +``` + +```swift +class Foo { + @IBInspectable private ↓var x: Optional +} +``` + +```swift +class Foo { + @IBInspectable private ↓var x: ImplicitlyUnwrappedOptional +} +``` \ No newline at end of file diff --git a/docs/description/vertical_parameter_alignment.md b/docs/description/vertical_parameter_alignment.md new file mode 100644 index 0000000..745c6e3 --- /dev/null +++ b/docs/description/vertical_parameter_alignment.md @@ -0,0 +1,96 @@ +# Vertical Parameter Alignment + +Function parameters should be aligned vertically if they're in multiple lines in a declaration. + +* **Identifier:** vertical_parameter_alignment +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind, + dictionary: SourceKittenDictionary) { } +``` + +```swift +func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind, + dictionary: SourceKittenDictionary) -> [StyleViolation] +``` + +```swift +func foo(bar: Int) +``` + +```swift +func foo(bar: Int) -> String +``` + +```swift +func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind, + dictionary: SourceKittenDictionary) + -> [StyleViolation] +``` + +```swift +func validateFunction( + _ file: SwiftLintFile, kind: SwiftDeclarationKind, + dictionary: SourceKittenDictionary) -> [StyleViolation] +``` + +```swift +func validateFunction( + _ file: SwiftLintFile, kind: SwiftDeclarationKind, + dictionary: SourceKittenDictionary +) -> [StyleViolation] +``` + +```swift +func regex(_ pattern: String, + options: NSRegularExpression.Options = [.anchorsMatchLines, + .dotMatchesLineSeparators]) -> NSRegularExpression +``` + +```swift +func foo(a: Void, + b: [String: String] = + [:]) { +} +``` + +```swift +func foo(data: (size: CGSize, + identifier: String)) {} +``` + +```swift +func foo(data: Data, + @ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {} +``` + +## Triggering Examples + +```swift +func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind, + ↓dictionary: SourceKittenDictionary) { } +``` + +```swift +func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind, + ↓dictionary: SourceKittenDictionary) { } +``` + +```swift +func validateFunction(_ file: SwiftLintFile, + ↓kind: SwiftDeclarationKind, + ↓dictionary: SourceKittenDictionary) { } +``` + +```swift +func foo(data: Data, + ↓@ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {} +``` \ No newline at end of file diff --git a/docs/description/vertical_parameter_alignment_on_call.md b/docs/description/vertical_parameter_alignment_on_call.md new file mode 100644 index 0000000..253064b --- /dev/null +++ b/docs/description/vertical_parameter_alignment_on_call.md @@ -0,0 +1,118 @@ +# Vertical Parameter Alignment On Call + +Function parameters should be aligned vertically if they're in multiple lines in a method call. + +* **Identifier:** vertical_parameter_alignment_on_call +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +foo(param1: 1, param2: bar + param3: false, param4: true) +``` + +```swift +foo(param1: 1, param2: bar) +``` + +```swift +foo(param1: 1, param2: bar + param3: false, + param4: true) +``` + +```swift +foo( + param1: 1 +) { _ in } +``` + +```swift +UIView.animate(withDuration: 0.4, animations: { + blurredImageView.alpha = 1 +}, completion: { _ in + self.hideLoading() +}) +``` + +```swift +UIView.animate(withDuration: 0.4, animations: { + blurredImageView.alpha = 1 +}, +completion: { _ in + self.hideLoading() +}) +``` + +```swift +foo(param1: 1, param2: { _ in }, + param3: false, param4: true) +``` + +```swift +foo({ _ in + bar() + }, + completion: { _ in + baz() + } +) +``` + +```swift +foo(param1: 1, param2: [ + 0, + 1 +], param3: 0) +``` + +```swift +myFunc(foo: 0, + bar: baz == 0) +``` + +## Triggering Examples + +```swift +foo(param1: 1, param2: bar + ↓param3: false, param4: true) +``` + +```swift +foo(param1: 1, param2: bar + ↓param3: false, param4: true) +``` + +```swift +foo(param1: 1, param2: bar + ↓param3: false, + ↓param4: true) +``` + +```swift +foo(param1: 1, + ↓param2: { _ in }) +``` + +```swift +foo(param1: 1, + param2: { _ in +}, param3: 2, + ↓param4: 0) +``` + +```swift +foo(param1: 1, param2: { _ in }, + ↓param3: false, param4: true) +``` + +```swift +myFunc(foo: 0, + ↓bar: baz == 0) +``` \ No newline at end of file diff --git a/docs/description/vertical_whitespace.md b/docs/description/vertical_whitespace.md new file mode 100644 index 0000000..f51b322 --- /dev/null +++ b/docs/description/vertical_whitespace.md @@ -0,0 +1,62 @@ +# Vertical Whitespace + +Limit vertical whitespace to a single empty line. + +* **Identifier:** vertical_whitespace +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, max_empty_lines: 1 + +## Non Triggering Examples + +```swift +let abc = 0 + +``` + +```swift +let abc = 0 + + +``` + +```swift +/* bcs + + + +*/ +``` + +```swift +// bca + + +``` + +## Triggering Examples + +```swift +let aaaa = 0 + + + +``` + +```swift +struct AAAA {} + + + + +``` + +```swift +class BBBB {} + + + +``` \ No newline at end of file diff --git a/docs/description/vertical_whitespace_between_cases.md b/docs/description/vertical_whitespace_between_cases.md new file mode 100644 index 0000000..eb9f5ef --- /dev/null +++ b/docs/description/vertical_whitespace_between_cases.md @@ -0,0 +1,122 @@ +# Vertical Whitespace Between Cases + +Include a single empty line between switch cases. + +* **Identifier:** vertical_whitespace_between_cases +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift + switch x { + case .valid: + print("multiple ...") + print("... lines") + + case .invalid: + print("multiple ...") + print("... lines") + } +``` + +```swift + switch x { + case .valid: + print("x is valid") + + case .invalid: + print("x is invalid") + } +``` + +```swift + switch x { + case 0..<5: + print("x is valid") + + default: + print("x is invalid") + } +``` + +```swift +switch x { + +case 0..<5: + print("x is low") + +case 5..<10: + print("x is high") + +default: + print("x is invalid") + +} +``` + +```swift +switch x { +case 0..<5: + print("x is low") + +case 5..<10: + print("x is high") + +default: + print("x is invalid") +} +``` + +```swift +switch x { +case 0..<5: print("x is low") +case 5..<10: print("x is high") +default: print("x is invalid") +} +``` + +```swift +switch x { +case 1: + print("one") + +default: + print("not one") +} +``` + +## Triggering Examples + +```swift + switch x { + case .valid: + print("multiple ...") + print("... lines") +↓ case .invalid: + print("multiple ...") + print("... lines") + } +``` + +```swift + switch x { + case .valid: + print("x is valid") +↓ case .invalid: + print("x is invalid") + } +``` + +```swift + switch x { + case 0..<5: + print("x is valid") +↓ default: + print("x is invalid") + } +``` \ No newline at end of file diff --git a/docs/description/vertical_whitespace_closing_braces.md b/docs/description/vertical_whitespace_closing_braces.md new file mode 100644 index 0000000..11cbeb3 --- /dev/null +++ b/docs/description/vertical_whitespace_closing_braces.md @@ -0,0 +1,127 @@ +# Vertical Whitespace before Closing Braces + +Don't include vertical whitespace (empty line) before closing braces. + +* **Identifier:** vertical_whitespace_closing_braces +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** N/A + +## Non Triggering Examples + +```swift + ) +} + } +} +``` + +```swift + print("x is 5") +} +``` + +```swift + print("x is 5") +} +``` + +```swift + print("x is 5") +} +``` + +```swift +/* + class X { + + let x = 5 + + } +*/ +``` + +```swift +[ +1, +2, +3 +] +``` + +```swift +[1, 2].map { $0 }.filter { +``` + +```swift +[1, 2].map { $0 }.filter { num in +``` + +```swift +class Name { + run(5) { x in print(x) } +} +``` + +```swift +foo( +x: 5, +y:6 +) +``` + +## Triggering Examples + +```swift + ) +} +↓ + } +} +``` + +```swift + print("x is 5") +↓ + +} +``` + +```swift + print("x is 5") +↓ +} +``` + +```swift + print("x is 5") +↓ +} +``` + +```swift +[ +1, +2, +3 +↓ +] +``` + +```swift +class Name { + run(5) { x in print(x) } +↓ +} +``` + +```swift +foo( +x: 5, +y:6 +↓ +) +``` \ No newline at end of file diff --git a/docs/description/vertical_whitespace_opening_braces.md b/docs/description/vertical_whitespace_opening_braces.md new file mode 100644 index 0000000..ae52009 --- /dev/null +++ b/docs/description/vertical_whitespace_opening_braces.md @@ -0,0 +1,197 @@ +# Vertical Whitespace after Opening Braces + +Don't include vertical whitespace (empty line) after opening braces. + +* **Identifier:** vertical_whitespace_opening_braces +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** N/A + +## Non Triggering Examples + +```swift +/* + class X { + + let x = 5 + + } +*/ +``` + +```swift +// [1, 2].map { $0 }.filter { num in +``` + +```swift +KingfisherManager.shared.retrieveImage(with: url, options: nil, progressBlock: nil) { image, _, _, _ in + guard let img = image else { return } +``` + +```swift +[ +1, +2, +3 +] +``` + +```swift +[1, 2].map { $0 }.filter { num in +``` + +```swift +[1, 2].map { $0 }.foo() +``` + +```swift +class Name { + run(5) { x in print(x) } +} +``` + +```swift +class X { + struct Y { + class Z { + +``` + +```swift +foo( +x: 5, +y:6 +) +``` + +```swift +if x == 5 { + print("x is 5") +``` + +```swift +if x == 5 { + print("x is 5") +``` + +```swift +if x == 5 { + print("x is 5") +``` + +```swift +if x == 5 { + print("x is 5") +``` + +```swift +struct MyStruct { + let x = 5 +``` + +```swift +struct MyStruct { + let x = 5 +``` + +```swift +struct MyStruct { + let x = 5 +``` + +```swift +}) { _ in + self.dismiss(animated: false, completion: { +``` + +## Triggering Examples + +```swift +KingfisherManager.shared.retrieveImage(with: url, options: nil, progressBlock: nil) { image, _, _, _ in +↓ + guard let img = image else { return } +``` + +```swift +[ +↓ +1, +2, +3 +] +``` + +```swift +class Name { +↓ + run(5) { x in print(x) } +} +``` + +```swift +class X { + struct Y { +↓ + class Z { + +``` + +```swift +foo( +↓ +x: 5, +y:6 +) +``` + +```swift +if x == 5 { +↓ + print("x is 5") +``` + +```swift +if x == 5 { +↓ + + print("x is 5") +``` + +```swift +if x == 5 { +↓ + print("x is 5") +``` + +```swift +if x == 5 { +↓ + print("x is 5") +``` + +```swift +struct MyStruct { +↓ + let x = 5 +``` + +```swift +struct MyStruct { +↓ + let x = 5 +``` + +```swift +struct MyStruct { +↓ + let x = 5 +``` + +```swift +}) { _ in +↓ + self.dismiss(animated: false, completion: { +``` \ No newline at end of file diff --git a/docs/description/void_return.md b/docs/description/void_return.md new file mode 100644 index 0000000..6a57efe --- /dev/null +++ b/docs/description/void_return.md @@ -0,0 +1,85 @@ +# Void Return + +Prefer `-> Void` over `-> ()`. + +* **Identifier:** void_return +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let abc: () -> Void = {} + +``` + +```swift +let abc: () -> (VoidVoid) = {} + +``` + +```swift +func foo(completion: () -> Void) + +``` + +```swift +let foo: (ConfigurationTests) -> () throws -> Void) + +``` + +```swift +let foo: (ConfigurationTests) -> () throws -> Void) + +``` + +```swift +let foo: (ConfigurationTests) ->() throws -> Void) + +``` + +```swift +let foo: (ConfigurationTests) -> () -> Void) + +``` + +## Triggering Examples + +```swift +let abc: () -> ↓() = {} + +``` + +```swift +let abc: () -> ↓(Void) = {} + +``` + +```swift +let abc: () -> ↓( Void ) = {} + +``` + +```swift +func foo(completion: () -> ↓()) + +``` + +```swift +func foo(completion: () -> ↓( )) + +``` + +```swift +func foo(completion: () -> ↓(Void)) + +``` + +```swift +let foo: (ConfigurationTests) -> () throws -> ↓()) + +``` \ No newline at end of file diff --git a/docs/description/weak_delegate.md b/docs/description/weak_delegate.md new file mode 100644 index 0000000..adf4898 --- /dev/null +++ b/docs/description/weak_delegate.md @@ -0,0 +1,95 @@ +# Weak Delegate + +Delegates should be weak to avoid reference cycles. + +* **Identifier:** weak_delegate +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class Foo { + weak var delegate: SomeProtocol? +} + +``` + +```swift +class Foo { + weak var someDelegate: SomeDelegateProtocol? +} + +``` + +```swift +class Foo { + weak var delegateScroll: ScrollDelegate? +} + +``` + +```swift +class Foo { + var scrollHandler: ScrollDelegate? +} + +``` + +```swift +func foo() { + var delegate: SomeDelegate +} + +``` + +```swift +class Foo { + var delegateNotified: Bool? +} + +``` + +```swift +protocol P { + var delegate: AnyObject? { get set } +} + +``` + +```swift +class Foo { + protocol P { + var delegate: AnyObject? { get set } +} +} + +``` + +```swift +class Foo { + var computedDelegate: ComputedDelegate { + return bar() +} +} +``` + +## Triggering Examples + +```swift +class Foo { + ↓var delegate: SomeProtocol? +} + +``` + +```swift +class Foo { + ↓var scrollDelegate: ScrollDelegate? +} + +``` \ No newline at end of file diff --git a/docs/description/xct_specific_matcher.md b/docs/description/xct_specific_matcher.md new file mode 100644 index 0000000..ad52c98 --- /dev/null +++ b/docs/description/xct_specific_matcher.md @@ -0,0 +1,303 @@ +# XCTest Specific Matcher + +Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual` + +* **Identifier:** xct_specific_matcher +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +XCTAssertFalse(foo) +``` + +```swift +XCTAssertTrue(foo) +``` + +```swift +XCTAssertNil(foo) +``` + +```swift +XCTAssertNotNil(foo) +``` + +```swift +XCTAssertEqual(foo, 2) +``` + +```swift +XCTAssertNotEqual(foo, "false") +``` + +```swift +XCTAssertEqual(foo, [1, 2, 3, true]) +``` + +```swift +XCTAssertEqual(foo, [1, 2, 3, false]) +``` + +```swift +XCTAssertEqual(foo, [1, 2, 3, nil]) +``` + +```swift +XCTAssertEqual(foo, [true, nil, true, nil]) +``` + +```swift +XCTAssertEqual([1, 2, 3, true], foo) +``` + +```swift +XCTAssertEqual([1, 2, 3, false], foo) +``` + +```swift +XCTAssertEqual([1, 2, 3, nil], foo) +``` + +```swift +XCTAssertEqual([true, nil, true, nil], foo) +``` + +```swift +XCTAssertEqual(2, foo) +``` + +```swift +XCTAssertNotEqual("false"), foo) +``` + +```swift +XCTAssertEqual(false, foo?.bar) +``` + +```swift +XCTAssertEqual(true, foo?.bar) +``` + +```swift +XCTAssertFalse( foo ) +``` + +```swift +XCTAssertTrue( foo ) +``` + +```swift +XCTAssertNil( foo ) +``` + +```swift +XCTAssertNotNil( foo ) +``` + +```swift +XCTAssertEqual( foo , 2 ) +``` + +```swift +XCTAssertNotEqual( foo, "false") +``` + +```swift +XCTAssertEqual(foo?.bar, false) +``` + +```swift +XCTAssertEqual(foo?.bar, true) +``` + +```swift +XCTAssertNil(foo?.bar) +``` + +```swift +XCTAssertNotNil(foo?.bar) +``` + +```swift +XCTAssertEqual(foo?.bar, 2) +``` + +```swift +XCTAssertNotEqual(foo?.bar, "false") +``` + +```swift +XCTAssertEqual(foo?.bar, toto()) +``` + +```swift +XCTAssertEqual(foo?.bar, .toto(.zoo)) +``` + +```swift +XCTAssertEqual(toto(), foo?.bar) +``` + +```swift +XCTAssertEqual(.toto(.zoo), foo?.bar) +``` + +## Triggering Examples + +```swift +↓XCTAssertEqual(foo, true) +``` + +```swift +↓XCTAssertEqual(foo, false) +``` + +```swift +↓XCTAssertEqual(foo, nil) +``` + +```swift +↓XCTAssertNotEqual(foo, true) +``` + +```swift +↓XCTAssertNotEqual(foo, false) +``` + +```swift +↓XCTAssertNotEqual(foo, nil) +``` + +```swift +↓XCTAssertEqual(true, foo) +``` + +```swift +↓XCTAssertEqual(false, foo) +``` + +```swift +↓XCTAssertEqual(nil, foo) +``` + +```swift +↓XCTAssertNotEqual(true, foo) +``` + +```swift +↓XCTAssertNotEqual(false, foo) +``` + +```swift +↓XCTAssertNotEqual(nil, foo) +``` + +```swift +↓XCTAssertEqual(foo, true, "toto") +``` + +```swift +↓XCTAssertEqual(foo, false, "toto") +``` + +```swift +↓XCTAssertEqual(foo, nil, "toto") +``` + +```swift +↓XCTAssertNotEqual(foo, true, "toto") +``` + +```swift +↓XCTAssertNotEqual(foo, false, "toto") +``` + +```swift +↓XCTAssertNotEqual(foo, nil, "toto") +``` + +```swift +↓XCTAssertEqual(true, foo, "toto") +``` + +```swift +↓XCTAssertEqual(false, foo, "toto") +``` + +```swift +↓XCTAssertEqual(nil, foo, "toto") +``` + +```swift +↓XCTAssertNotEqual(true, foo, "toto") +``` + +```swift +↓XCTAssertNotEqual(false, foo, "toto") +``` + +```swift +↓XCTAssertNotEqual(nil, foo, "toto") +``` + +```swift +↓XCTAssertEqual(foo,true) +``` + +```swift +↓XCTAssertEqual( foo , false ) +``` + +```swift +↓XCTAssertEqual( foo , nil ) +``` + +```swift +↓XCTAssertEqual(true, [1, 2, 3, true].hasNumbers()) +``` + +```swift +↓XCTAssertEqual([1, 2, 3, true].hasNumbers(), true) +``` + +```swift +↓XCTAssertEqual(foo?.bar, nil) +``` + +```swift +↓XCTAssertNotEqual(foo?.bar, nil) +``` + +```swift +↓XCTAssertEqual(nil, true) +``` + +```swift +↓XCTAssertEqual(nil, false) +``` + +```swift +↓XCTAssertEqual(true, nil) +``` + +```swift +↓XCTAssertEqual(false, nil) +``` + +```swift +↓XCTAssertEqual(nil, nil) +``` + +```swift +↓XCTAssertEqual(true, true) +``` + +```swift +↓XCTAssertEqual(false, false) +``` \ No newline at end of file diff --git a/docs/description/xctfail_message.md b/docs/description/xctfail_message.md new file mode 100644 index 0000000..85f408f --- /dev/null +++ b/docs/description/xctfail_message.md @@ -0,0 +1,39 @@ +# XCTFail Message + +An XCTFail call should include a description of the assertion. + +* **Identifier:** xctfail_message +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func testFoo() { + XCTFail("bar") +} +``` + +```swift +func testFoo() { + XCTFail(bar) +} +``` + +## Triggering Examples + +```swift +func testFoo() { + ↓XCTFail() +} +``` + +```swift +func testFoo() { + ↓XCTFail("") +} +``` \ No newline at end of file diff --git a/docs/description/yoda_condition.md b/docs/description/yoda_condition.md new file mode 100644 index 0000000..8e9b9cd --- /dev/null +++ b/docs/description/yoda_condition.md @@ -0,0 +1,87 @@ +# Yoda condition rule + +The variable should be placed on the left, the constant on the right of a comparison operator. + +* **Identifier:** yoda_condition +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +if foo == 42 {} + +``` + +```swift +if foo <= 42.42 {} + +``` + +```swift +guard foo >= 42 else { return } + +``` + +```swift +guard foo != "str str" else { return } +``` + +```swift +while foo < 10 { } + +``` + +```swift +while foo > 1 { } + +``` + +```swift +while foo + 1 == 2 +``` + +```swift +if optionalValue?.property ?? 0 == 2 +``` + +```swift +if foo == nil +``` + +## Triggering Examples + +```swift +↓if 42 == foo {} + +``` + +```swift +↓if 42.42 >= foo {} + +``` + +```swift +↓guard 42 <= foo else { return } + +``` + +```swift +↓guard "str str" != foo else { return } +``` + +```swift +↓while 10 > foo { } +``` + +```swift +↓while 1 < foo { } +``` + +```swift +↓if nil == foo +``` \ No newline at end of file diff --git a/docs/patterns.json b/docs/patterns.json old mode 100755 new mode 100644 index b9cbd63..4580111 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -1,12 +1,27 @@ { "name": "swiftlint", - "version": "0.36.0", + "version": "0.39.2", "patterns": [ + { + "patternId": "anyobject_protocol", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "array_init", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "attributes", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "block_based_kvo", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "class_delegate_protocol", "level": "Info", @@ -17,6 +32,11 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "closure_body_length", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "closure_end_indentation", "level": "Info", @@ -32,6 +52,11 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "collection_alignment", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "colon", "level": "Info", @@ -52,11 +77,36 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "contains_over_filter_count", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "contains_over_filter_is_empty", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "contains_over_first_not_nil", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "contains_over_range_nil_comparison", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "control_statement", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "convenience_type", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "custom_rules", "level": "Info", @@ -67,16 +117,56 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "deployment_target", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "discarded_notification_center_observer", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "discouraged_direct_init", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "discouraged_object_literal", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "discouraged_optional_boolean", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "discouraged_optional_collection", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "duplicate_enum_cases", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "duplicate_imports", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "dynamic_inline", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "empty_collection_literal", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "empty_count", "level": "Info", @@ -97,11 +187,46 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "empty_string", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "empty_xctest_method", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "enum_case_associated_values_count", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "expiring_todo", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "explicit_acl", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "explicit_enum_raw_value", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "explicit_init", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "explicit_self", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "explicit_top_level_acl", "level": "Info", @@ -117,6 +242,11 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "fallthrough", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "fatal_error_message", "level": "Info", @@ -132,11 +262,31 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "file_name", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "file_name_no_space", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "file_types_order", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "first_where", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "flatmap_over_map_reduce", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "for_where", "level": "Info", @@ -162,6 +312,11 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "function_default_parameter_at_end", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "function_parameter_count", "level": "Info", @@ -172,6 +327,11 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "identical_operands", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "identifier_name", "level": "Info", @@ -192,11 +352,36 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "indentation_width", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "inert_defer", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "is_disjoint", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "joined_default_parameter", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "large_tuple", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "last_where", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "leading_whitespace", "level": "Info", @@ -217,26 +402,96 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "legacy_hashing", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "legacy_multiple", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "legacy_nsgeometry_functions", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "legacy_random", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "let_var_whitespace", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "line_length", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "literal_expression_end_indentation", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "lower_acl_than_parent", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "mark", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "missing_docs", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "modifier_order", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "multiline_arguments", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "multiline_arguments_brackets", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "multiline_function_chains", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "multiline_literal_brackets", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "multiline_parameters", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "multiline_parameters_brackets", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "multiple_closures_with_trailing_closure", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "nesting", "level": "Info", @@ -252,11 +507,41 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "no_fallthrough_only", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "no_grouping_extension", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "no_space_in_method_call", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "notification_center_detachment", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "nslocalizedstring_key", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "nslocalizedstring_require_bundle", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "nsobject_prefer_isequal", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "number_separator", "level": "Info", @@ -282,21 +567,66 @@ "level": "Info", "category": "CodeStyle" }, + { + "patternId": "optional_enum_case_matching", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "orphaned_doc_comment", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "overridden_super_call", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "override_in_extension", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "pattern_matching_keywords", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "prefer_self_type_over_type_of_self", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "prefixed_toplevel_constant", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "private_action", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "private_outlet", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "private_over_fileprivate", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "private_unit_test", "level": "Info", "category": "CodeStyle" }, + { + "patternId": "prohibited_interface_builder", + "level": "Info", + "category": "CodeStyle" + }, { "patternId": "prohibited_super_call", "level": "Info", @@ -308,302 +638,312 @@ "category": "CodeStyle" }, { - "patternId": "redundant_discardable_let", + "patternId": "quick_discouraged_call", "level": "Info", "category": "CodeStyle" }, { - "patternId": "redundant_nil_coalescing", + "patternId": "quick_discouraged_focused_test", "level": "Info", "category": "CodeStyle" }, { - "patternId": "redundant_optional_initialization", + "patternId": "quick_discouraged_pending_test", "level": "Info", "category": "CodeStyle" }, { - "patternId": "redundant_string_enum_value", + "patternId": "raw_value_for_camel_cased_codable_enum", "level": "Info", "category": "CodeStyle" }, { - "patternId": "redundant_void_return", + "patternId": "reduce_boolean", "level": "Info", "category": "CodeStyle" }, { - "patternId": "return_arrow_whitespace", + "patternId": "reduce_into", "level": "Info", "category": "CodeStyle" }, { - "patternId": "shorthand_operator", + "patternId": "redundant_discardable_let", "level": "Info", "category": "CodeStyle" }, { - "patternId": "sorted_imports", + "patternId": "redundant_nil_coalescing", "level": "Info", "category": "CodeStyle" }, { - "patternId": "statement_position", + "patternId": "redundant_objc_attribute", "level": "Info", "category": "CodeStyle" }, { - "patternId": "switch_case_on_newline", + "patternId": "redundant_optional_initialization", "level": "Info", "category": "CodeStyle" }, { - "patternId": "syntactic_sugar", + "patternId": "redundant_set_access_control", "level": "Info", "category": "CodeStyle" }, { - "patternId": "todo", + "patternId": "redundant_string_enum_value", "level": "Info", "category": "CodeStyle" }, { - "patternId": "trailing_comma", + "patternId": "redundant_type_annotation", "level": "Info", "category": "CodeStyle" }, { - "patternId": "trailing_newline", + "patternId": "redundant_void_return", "level": "Info", "category": "CodeStyle" }, { - "patternId": "trailing_semicolon", + "patternId": "required_deinit", "level": "Info", "category": "CodeStyle" }, { - "patternId": "trailing_whitespace", + "patternId": "required_enum_case", "level": "Info", "category": "CodeStyle" }, { - "patternId": "type_body_length", + "patternId": "return_arrow_whitespace", "level": "Info", "category": "CodeStyle" }, { - "patternId": "type_name", + "patternId": "shorthand_operator", "level": "Info", "category": "CodeStyle" }, { - "patternId": "unused_closure_parameter", + "patternId": "single_test_class", "level": "Info", "category": "CodeStyle" }, { - "patternId": "unused_enumerated", + "patternId": "sorted_first_last", "level": "Info", "category": "CodeStyle" }, { - "patternId": "unused_optional_binding", + "patternId": "sorted_imports", "level": "Info", "category": "CodeStyle" }, { - "patternId": "valid_ibinspectable", + "patternId": "statement_position", "level": "Info", "category": "CodeStyle" }, { - "patternId": "vertical_parameter_alignment", + "patternId": "static_operator", "level": "Info", "category": "CodeStyle" }, { - "patternId": "vertical_parameter_alignment_on_call", + "patternId": "strict_fileprivate", "level": "Info", "category": "CodeStyle" }, { - "patternId": "vertical_whitespace", + "patternId": "strong_iboutlet", "level": "Info", "category": "CodeStyle" }, { - "patternId": "void_return", + "patternId": "superfluous_disable_command", "level": "Info", "category": "CodeStyle" }, { - "patternId": "weak_delegate", + "patternId": "switch_case_alignment", "level": "Info", "category": "CodeStyle" }, { - "patternId": "array_init", + "patternId": "switch_case_on_newline", "level": "Info", "category": "CodeStyle" }, { - "patternId": "block_based_kvo", + "patternId": "syntactic_sugar", "level": "Info", "category": "CodeStyle" }, { - "patternId": "contains_over_first_not_nil", + "patternId": "todo", "level": "Info", "category": "CodeStyle" }, { - "patternId": "discouraged_direct_init", + "patternId": "toggle_bool", "level": "Info", "category": "CodeStyle" }, { - "patternId": "discouraged_object_literal", + "patternId": "trailing_closure", "level": "Info", "category": "CodeStyle" }, { - "patternId": "discouraged_optional_boolean", + "patternId": "trailing_comma", "level": "Info", "category": "CodeStyle" }, { - "patternId": "explicit_acl", + "patternId": "trailing_newline", "level": "Info", "category": "CodeStyle" }, { - "patternId": "explicit_enum_raw_value", + "patternId": "trailing_semicolon", "level": "Info", "category": "CodeStyle" }, { - "patternId": "fallthrough", + "patternId": "trailing_whitespace", "level": "Info", "category": "CodeStyle" }, { - "patternId": "is_disjoint", + "patternId": "type_body_length", "level": "Info", "category": "CodeStyle" }, { - "patternId": "joined_default_parameter", + "patternId": "type_contents_order", "level": "Info", "category": "CodeStyle" }, { - "patternId": "let_var_whitespace", + "patternId": "type_name", "level": "Info", "category": "CodeStyle" }, { - "patternId": "literal_expression_end_indentation", + "patternId": "unavailable_function", "level": "Info", "category": "CodeStyle" }, { - "patternId": "multiline_arguments", + "patternId": "unneeded_break_in_switch", "level": "Info", "category": "CodeStyle" }, { - "patternId": "multiple_closures_with_trailing_closure", + "patternId": "unneeded_parentheses_in_closure_argument", "level": "Info", "category": "CodeStyle" }, { - "patternId": "no_grouping_extension", + "patternId": "unowned_variable_capture", "level": "Info", "category": "CodeStyle" }, { - "patternId": "override_in_extension", + "patternId": "untyped_error_in_catch", "level": "Info", "category": "CodeStyle" }, { - "patternId": "pattern_matching_keywords", + "patternId": "unused_capture_list", "level": "Info", "category": "CodeStyle" }, { - "patternId": "prefixed_toplevel_constant", + "patternId": "unused_closure_parameter", "level": "Info", "category": "CodeStyle" }, { - "patternId": "private_action", + "patternId": "unused_control_flow_label", "level": "Info", "category": "CodeStyle" }, { - "patternId": "private_over_fileprivate", + "patternId": "unused_declaration", "level": "Info", "category": "CodeStyle" }, { - "patternId": "quick_discouraged_call", + "patternId": "unused_enumerated", "level": "Info", "category": "CodeStyle" }, { - "patternId": "quick_discouraged_focused_test", + "patternId": "unused_import", "level": "Info", "category": "CodeStyle" }, { - "patternId": "quick_discouraged_pending_test", + "patternId": "unused_optional_binding", "level": "Info", "category": "CodeStyle" }, { - "patternId": "required_enum_case", + "patternId": "unused_setter_value", "level": "Info", "category": "CodeStyle" }, { - "patternId": "single_test_class", + "patternId": "valid_ibinspectable", "level": "Info", "category": "CodeStyle" }, { - "patternId": "sorted_first_last", + "patternId": "vertical_parameter_alignment", "level": "Info", "category": "CodeStyle" }, { - "patternId": "strict_fileprivate", + "patternId": "vertical_parameter_alignment_on_call", "level": "Info", "category": "CodeStyle" }, { - "patternId": "superfluous_disable_command", + "patternId": "vertical_whitespace", "level": "Info", "category": "CodeStyle" }, { - "patternId": "switch_case_alignment", + "patternId": "vertical_whitespace_between_cases", "level": "Info", "category": "CodeStyle" }, { - "patternId": "trailing_closure", + "patternId": "vertical_whitespace_closing_braces", "level": "Info", "category": "CodeStyle" }, { - "patternId": "unneeded_break_in_switch", + "patternId": "vertical_whitespace_opening_braces", "level": "Info", "category": "CodeStyle" }, { - "patternId": "unneeded_parentheses_in_closure_argument", + "patternId": "void_return", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "weak_delegate", + "level": "Info", + "category": "CodeStyle" + }, + { + "patternId": "xct_specific_matcher", "level": "Info", "category": "CodeStyle" }, From 1827202bccb455d02c24a40fc15c6a36ec269b3e Mon Sep 17 00:00:00 2001 From: Joao Machado Date: Tue, 4 Aug 2020 17:24:40 +0100 Subject: [PATCH 036/119] feature: Add/update GitHub actions to handle Jira tickets --- .github/workflows/comment_issue.yml | 48 ++++++++++++ .github/workflows/create_issue.yml | 86 +++++++++++++++++++++ .github/workflows/create_issue_on_label.yml | 79 +++++++++++++++++++ 3 files changed, 213 insertions(+) create mode 100644 .github/workflows/comment_issue.yml create mode 100644 .github/workflows/create_issue.yml create mode 100644 .github/workflows/create_issue_on_label.yml diff --git a/.github/workflows/comment_issue.yml b/.github/workflows/comment_issue.yml new file mode 100644 index 0000000..3ec8174 --- /dev/null +++ b/.github/workflows/comment_issue.yml @@ -0,0 +1,48 @@ +name: Comment issue on Jira + +on: + issue_comment: + types: [created] + +jobs: + jira: + env: + JIRA_CREATE_COMMENT_AUTO: ${{ secrets.JIRA_CREATE_COMMENT_AUTO }} + runs-on: ubuntu-latest + steps: + + - name: Jira Login + if: env.JIRA_CREATE_COMMENT_AUTO == 'true' + id: login + uses: atlassian/gajira-login@v2.0.0 + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + + - name: Extract Jira number + if: env.JIRA_CREATE_COMMENT_AUTO == 'true' + id: extract_jira_number + uses: actions/github-script@v2.0.0 + env: + JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }} + GITHUB_TITLE: ${{ github.event.issue.title }} + with: + script: | + const jiraTaskRegex = new RegExp(`\\\[(${process.env.JIRA_PROJECT}-[0-9]+?)\\\]`) + return process.env.GITHUB_TITLE.match(jiraTaskRegex)[1] + result-encoding: string + + - name: Jira Add comment on issue + if: env.JIRA_CREATE_COMMENT_AUTO == 'true' + id: add_comment_jira_issue + uses: atlassian/gajira-comment@v2.0.0 + with: + issue: ${{ steps.extract_jira_number.outputs.result }} + comment: | + GitHub Comment : ${{ github.event.comment.user.login }} + {quote}${{ github.event.comment.body }}{quote} + ---- + {panel} + _[Github permalink |${{ github.event.comment.html_url }}]_ + {panel} diff --git a/.github/workflows/create_issue.yml b/.github/workflows/create_issue.yml new file mode 100644 index 0000000..8e6d133 --- /dev/null +++ b/.github/workflows/create_issue.yml @@ -0,0 +1,86 @@ +name: Create issue on Jira + +on: + issues: + types: [opened] + +jobs: + jira: + env: + JIRA_CREATE_ISSUE_AUTO: ${{ secrets.JIRA_CREATE_ISSUE_AUTO }} + runs-on: ubuntu-latest + steps: + + - name: Jira Login + if: env.JIRA_CREATE_ISSUE_AUTO == 'true' + id: login + uses: atlassian/gajira-login@v2.0.0 + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + + - name: Jira Create issue + if: env.JIRA_CREATE_ISSUE_AUTO == 'true' + id: create_jira_issue + uses: atlassian/gajira-create@v2.0.0 + with: + project: ${{ secrets.JIRA_PROJECT }} + issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} + summary: "[GH#${{ github.event.issue.number }}] ${{ github.event.issue.title }}" + description: | + ${{ github.event.issue.body }} + ---- + {panel} + _[Github permalink |${{ github.event.issue.html_url }}]_ + {panel} + + - name: Update Jira issue + if: env.JIRA_CREATE_ISSUE_AUTO == 'true' && env.JIRA_UPDATE_ISSUE_BODY != '' + env: + JIRA_UPDATE_ISSUE_BODY: ${{ secrets.JIRA_UPDATE_ISSUE_BODY }} + run: > + curl + -u ${{ secrets.JIRA_USER_EMAIL }}:${{ secrets.JIRA_API_TOKEN }} + -X PUT + -H 'Content-Type: application/json' + -d '${{ env.JIRA_UPDATE_ISSUE_BODY }}' + ${{ secrets.JIRA_BASE_URL }}/rest/api/2/issue/${{ steps.create_jira_issue.outputs.issue }} + + - name: Update GitHub issue + if: env.JIRA_CREATE_ISSUE_AUTO == 'true' + uses: actions/github-script@v2.0.0 + env: + JIRA_ISSUE_NUMBER: ${{ steps.create_jira_issue.outputs.issue }} + GITHUB_ORIGINAL_TITLE: ${{ github.event.issue.title }} + JIRA_ISSUE_LABEL: ${{ secrets.JIRA_ISSUE_LABEL }} + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const newTitle = `[${process.env.JIRA_ISSUE_NUMBER}] ${process.env.GITHUB_ORIGINAL_TITLE}` + github.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + title: newTitle + }) + github.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: [process.env.JIRA_ISSUE_LABEL] + }) + + + - name: Add comment after sync + if: env.JIRA_CREATE_ISSUE_AUTO == 'true' + uses: actions/github-script@v2.0.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Internal ticket created : [${{ steps.create_jira_issue.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create_jira_issue.outputs.issue }})' + }) diff --git a/.github/workflows/create_issue_on_label.yml b/.github/workflows/create_issue_on_label.yml new file mode 100644 index 0000000..0539821 --- /dev/null +++ b/.github/workflows/create_issue_on_label.yml @@ -0,0 +1,79 @@ +name: Create issue on Jira when labeled with JIRA_ISSUE_LABEL + +on: + issues: + types: [labeled] + +jobs: + jira: + env: + JIRA_ISSUE_LABEL: ${{ secrets.JIRA_ISSUE_LABEL }} + runs-on: ubuntu-latest + steps: + + - name: Jira Login + if: github.event.label.name == env.JIRA_ISSUE_LABEL + id: login + uses: atlassian/gajira-login@v2.0.0 + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + + - name: Jira Create issue + if: github.event.label.name == env.JIRA_ISSUE_LABEL + id: create_jira_issue + uses: atlassian/gajira-create@v2.0.0 + with: + project: ${{ secrets.JIRA_PROJECT }} + issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} + summary: "[GH#${{ github.event.issue.number }}] ${{ github.event.issue.title }}" + description: | + ${{ github.event.issue.body }} + ---- + {panel} + _[Github permalink |${{ github.event.issue.html_url }}]_ + {panel} + + - name: Update Jira issue + if: github.event.label.name == env.JIRA_ISSUE_LABEL && env.JIRA_UPDATE_ISSUE_BODY != '' + env: + JIRA_UPDATE_ISSUE_BODY: ${{ secrets.JIRA_UPDATE_ISSUE_BODY }} + run: > + curl + -u ${{ secrets.JIRA_USER_EMAIL }}:${{ secrets.JIRA_API_TOKEN }} + -X PUT + -H 'Content-Type: application/json' + -d '${{ env.JIRA_UPDATE_ISSUE_BODY }}' + ${{ secrets.JIRA_BASE_URL }}/rest/api/2/issue/${{ steps.create_jira_issue.outputs.issue }} + + - name: Change Title + if: github.event.label.name == env.JIRA_ISSUE_LABEL + uses: actions/github-script@v2.0.0 + env: + JIRA_ISSUE_NUMBER: ${{ steps.create_jira_issue.outputs.issue }} + GITHUB_ORIGINAL_TITLE: ${{ github.event.issue.title }} + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const newTitle = `[${process.env.JIRA_ISSUE_NUMBER}] ${process.env.GITHUB_ORIGINAL_TITLE}` + github.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + title: newTitle + }) + + - name: Add comment after sync + if: github.event.label.name == env.JIRA_ISSUE_LABEL + uses: actions/github-script@v2.0.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Internal ticket created : [${{ steps.create_jira_issue.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create_jira_issue.outputs.issue }})' + }) + From 7e446d44f04cab728799111a61d6fca400bf7abe Mon Sep 17 00:00:00 2001 From: Joao Machado Date: Thu, 6 Aug 2020 16:40:46 +0100 Subject: [PATCH 037/119] meta: No longer runs failing worflows for comments on pull requests --- .github/workflows/comment_issue.yml | 55 +++++++++++++++++++-- .github/workflows/create_issue.yml | 6 ++- .github/workflows/create_issue_on_label.yml | 7 ++- 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/.github/workflows/comment_issue.yml b/.github/workflows/comment_issue.yml index 3ec8174..64b5ed0 100644 --- a/.github/workflows/comment_issue.yml +++ b/.github/workflows/comment_issue.yml @@ -11,20 +11,66 @@ jobs: runs-on: ubuntu-latest steps: - - name: Jira Login + - name: Start workflow if JIRA_CREATE_COMMENT_AUTO is enabled + if: env.JIRA_CREATE_COMMENT_AUTO == 'true' + run: echo "Starting workflow" + + - name: Check GitHub Issue type if: env.JIRA_CREATE_COMMENT_AUTO == 'true' + id: github_issue_type + uses: actions/github-script@v2.0.0 + with: + result-encoding: string + script: | + // An Issue can be a pull request, you can identify pull requests by the pull_request key + const pullRequest = ${{ toJson(github.event.issue.pull_request) }} + if(pullRequest) { + return "pull-request" + } else { + return "issue" + } + + - name: Check if GitHub Issue has JIRA_ISSUE_LABEL + if: env.JIRA_CREATE_COMMENT_AUTO == 'true' + id: github_issue_has_jira_issue_label + uses: actions/github-script@v2.0.0 + env: + JIRA_ISSUE_LABEL: ${{ secrets.JIRA_ISSUE_LABEL }} + with: + result-encoding: string + script: | + const labels = ${{ toJson(github.event.issue.labels) }} + if(labels.find(label => label.name == process.env.JIRA_ISSUE_LABEL)) { + return "true" + } else { + return "false" + } + + - name: Continue workflow only for Issues (not Pull Requests) tagged with JIRA_ISSUE_LABEL + if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' + env: + GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} + GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} + run: echo "GitHub Issue is tracked on Jira, eligilbe to be commented" + + - name: Jira Login + if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' id: login uses: atlassian/gajira-login@v2.0.0 env: + GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} + GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} - name: Extract Jira number - if: env.JIRA_CREATE_COMMENT_AUTO == 'true' + if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' id: extract_jira_number uses: actions/github-script@v2.0.0 env: + GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} + GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }} GITHUB_TITLE: ${{ github.event.issue.title }} with: @@ -34,9 +80,12 @@ jobs: result-encoding: string - name: Jira Add comment on issue - if: env.JIRA_CREATE_COMMENT_AUTO == 'true' + if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' id: add_comment_jira_issue uses: atlassian/gajira-comment@v2.0.0 + env: + GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} + GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} with: issue: ${{ steps.extract_jira_number.outputs.result }} comment: | diff --git a/.github/workflows/create_issue.yml b/.github/workflows/create_issue.yml index 8e6d133..e8f62f0 100644 --- a/.github/workflows/create_issue.yml +++ b/.github/workflows/create_issue.yml @@ -11,6 +11,10 @@ jobs: runs-on: ubuntu-latest steps: + - name: Start workflow if JIRA_CREATE_ISSUE_AUTO is enabled + if: env.JIRA_CREATE_ISSUE_AUTO == 'true' + run: echo "Starting workflow" + - name: Jira Login if: env.JIRA_CREATE_ISSUE_AUTO == 'true' id: login @@ -35,7 +39,7 @@ jobs: _[Github permalink |${{ github.event.issue.html_url }}]_ {panel} - - name: Update Jira issue + - name: Update Jira issue if JIRA_UPDATE_ISSUE_BODY is defined if: env.JIRA_CREATE_ISSUE_AUTO == 'true' && env.JIRA_UPDATE_ISSUE_BODY != '' env: JIRA_UPDATE_ISSUE_BODY: ${{ secrets.JIRA_UPDATE_ISSUE_BODY }} diff --git a/.github/workflows/create_issue_on_label.yml b/.github/workflows/create_issue_on_label.yml index 0539821..632a3aa 100644 --- a/.github/workflows/create_issue_on_label.yml +++ b/.github/workflows/create_issue_on_label.yml @@ -11,6 +11,10 @@ jobs: runs-on: ubuntu-latest steps: + - name: Start workflow if GitHub issue is tagged with JIRA_ISSUE_LABEL + if: github.event.label.name == env.JIRA_ISSUE_LABEL + run: echo "Starting workflow" + - name: Jira Login if: github.event.label.name == env.JIRA_ISSUE_LABEL id: login @@ -35,7 +39,7 @@ jobs: _[Github permalink |${{ github.event.issue.html_url }}]_ {panel} - - name: Update Jira issue + - name: Update Jira issue if JIRA_UPDATE_ISSUE_BODY is defined if: github.event.label.name == env.JIRA_ISSUE_LABEL && env.JIRA_UPDATE_ISSUE_BODY != '' env: JIRA_UPDATE_ISSUE_BODY: ${{ secrets.JIRA_UPDATE_ISSUE_BODY }} @@ -76,4 +80,3 @@ jobs: repo: context.repo.repo, body: 'Internal ticket created : [${{ steps.create_jira_issue.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create_jira_issue.outputs.issue }})' }) - From 5a868ca6d7dfd1d31789ceff8134aee213394b69 Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 13 Aug 2020 17:26:21 +0100 Subject: [PATCH 038/119] bump: Bump swiftlint to 0.40.0 version This should fix the problem related to incorrect JSON being outputted by tool Fix #19 Fix CY-2525 --- Dockerfile | 2 +- Dockerfile.dev | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ba649fd..7bee871 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM norionomura/swiftlint:0.39.2 as builder +FROM norionomura/swiftlint:0.40.0 as builder FROM swift:5.2.4-xenial-slim diff --git a/Dockerfile.dev b/Dockerfile.dev index 2c39d0b..f8a1f95 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM norionomura/swiftlint:0.39.2 as builder +FROM norionomura/swiftlint:0.40.0 as builder FROM swift:5.2.4-xenial-slim From c26706a7ed51917411837daaae986aa90d3f3d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20=20Melo?= Date: Tue, 15 Sep 2020 14:24:56 +0100 Subject: [PATCH 039/119] feature: Add enabled by default to patterns.json --- .circleci/config.yml | 2 +- .gitignore | 1 + build.sbt | 2 +- docs/patterns.json | 573 ++++++++++++++++++++++++++++--------------- 4 files changed, 385 insertions(+), 193 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f4803cd..87fea04 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 orbs: codacy: codacy/base@4.2.7 - codacy_plugins_test: codacy/plugins-test@0.13.0 + codacy_plugins_test: codacy/plugins-test@0.14.5 workflows: version: 2 diff --git a/.gitignore b/.gitignore index 84b56bd..c313053 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ target .DS_Store .metals .bloop +.vscode diff --git a/build.sbt b/build.sbt index 919db28..94d5d60 100755 --- a/build.sbt +++ b/build.sbt @@ -16,7 +16,7 @@ Compile / sourceGenerators += Def.task { Seq(file) }.taskValue -libraryDependencies += "com.codacy" %% "codacy-engine-scala-seed" % "4.0.3" +libraryDependencies += "com.codacy" %% "codacy-engine-scala-seed" % "5.0.0" enablePlugins(GraalVMNativeImagePlugin) diff --git a/docs/patterns.json b/docs/patterns.json index 4580111..dc3b604 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -5,957 +5,1148 @@ { "patternId": "anyobject_protocol", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "array_init", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "attributes", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "block_based_kvo", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "class_delegate_protocol", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "closing_brace", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "closure_body_length", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "closure_end_indentation", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "closure_parameter_position", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "closure_spacing", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "collection_alignment", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "colon", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "comma", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "compiler_protocol_init", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "conditional_returns_on_newline", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "contains_over_filter_count", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "contains_over_filter_is_empty", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "contains_over_first_not_nil", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "contains_over_range_nil_comparison", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "control_statement", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "convenience_type", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "custom_rules", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "cyclomatic_complexity", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "deployment_target", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "discarded_notification_center_observer", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "discouraged_direct_init", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "discouraged_object_literal", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "discouraged_optional_boolean", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "discouraged_optional_collection", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "duplicate_enum_cases", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "duplicate_imports", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "dynamic_inline", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "empty_collection_literal", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "empty_count", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "empty_enum_arguments", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "empty_parameters", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "empty_parentheses_with_trailing_closure", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "empty_string", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "empty_xctest_method", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "enum_case_associated_values_count", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "expiring_todo", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "explicit_acl", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "explicit_enum_raw_value", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "explicit_init", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "explicit_self", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "explicit_top_level_acl", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "explicit_type_interface", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "extension_access_modifier", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "fallthrough", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "fatal_error_message", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "file_header", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "file_length", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "file_name", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "file_name_no_space", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "file_types_order", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "first_where", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "flatmap_over_map_reduce", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "for_where", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "force_cast", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "force_try", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "force_unwrapping", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "function_body_length", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "function_default_parameter_at_end", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "function_parameter_count", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "generic_type_name", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "identical_operands", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "identifier_name", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "implicit_getter", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "implicit_return", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "implicitly_unwrapped_optional", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "indentation_width", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "inert_defer", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "is_disjoint", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "joined_default_parameter", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "large_tuple", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "last_where", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "leading_whitespace", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "legacy_cggeometry_functions", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "legacy_constant", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "legacy_constructor", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "legacy_hashing", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "legacy_multiple", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "legacy_nsgeometry_functions", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "legacy_random", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "let_var_whitespace", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "line_length", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "literal_expression_end_indentation", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "lower_acl_than_parent", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "mark", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "missing_docs", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "modifier_order", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "multiline_arguments", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "multiline_arguments_brackets", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "multiline_function_chains", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "multiline_literal_brackets", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "multiline_parameters", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "multiline_parameters_brackets", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "multiple_closures_with_trailing_closure", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "nesting", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "nimble_operator", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "no_extension_access_modifier", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "no_fallthrough_only", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "no_grouping_extension", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "no_space_in_method_call", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "notification_center_detachment", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "nslocalizedstring_key", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "nslocalizedstring_require_bundle", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "nsobject_prefer_isequal", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "number_separator", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "object_literal", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "opening_brace", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "operator_usage_whitespace", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "operator_whitespace", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "optional_enum_case_matching", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "orphaned_doc_comment", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "overridden_super_call", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "override_in_extension", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "pattern_matching_keywords", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "prefer_self_type_over_type_of_self", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "prefixed_toplevel_constant", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "private_action", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "private_outlet", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "private_over_fileprivate", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "private_unit_test", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "prohibited_interface_builder", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "prohibited_super_call", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "protocol_property_accessors_order", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "quick_discouraged_call", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "quick_discouraged_focused_test", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "quick_discouraged_pending_test", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "raw_value_for_camel_cased_codable_enum", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "reduce_boolean", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "reduce_into", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "redundant_discardable_let", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "redundant_nil_coalescing", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "redundant_objc_attribute", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "redundant_optional_initialization", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "redundant_set_access_control", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "redundant_string_enum_value", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "redundant_type_annotation", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "redundant_void_return", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "required_deinit", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "required_enum_case", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "return_arrow_whitespace", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "shorthand_operator", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "single_test_class", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "sorted_first_last", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "sorted_imports", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "statement_position", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "static_operator", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "strict_fileprivate", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "strong_iboutlet", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "superfluous_disable_command", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "switch_case_alignment", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "switch_case_on_newline", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "syntactic_sugar", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "todo", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "toggle_bool", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "trailing_closure", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "trailing_comma", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "trailing_newline", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "trailing_semicolon", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "trailing_whitespace", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "type_body_length", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "type_contents_order", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "type_name", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "unavailable_function", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "unneeded_break_in_switch", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "unneeded_parentheses_in_closure_argument", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "unowned_variable_capture", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "untyped_error_in_catch", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "unused_capture_list", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "unused_closure_parameter", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "unused_control_flow_label", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "unused_declaration", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "unused_enumerated", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "unused_import", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "unused_optional_binding", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "unused_setter_value", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "valid_ibinspectable", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "vertical_parameter_alignment", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "vertical_parameter_alignment_on_call", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "vertical_whitespace", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "vertical_whitespace_between_cases", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "vertical_whitespace_closing_braces", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "vertical_whitespace_opening_braces", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "void_return", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "weak_delegate", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "xct_specific_matcher", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false }, { "patternId": "xctfail_message", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": true }, { "patternId": "yoda_condition", "level": "Info", - "category": "CodeStyle" + "category": "CodeStyle", + "enabled": false } ] } From 2dd58867155fcf91b4d94aade23d7e5acee71e44 Mon Sep 17 00:00:00 2001 From: Joao Machado Date: Fri, 18 Sep 2020 11:50:36 +0100 Subject: [PATCH 040/119] Bump codacy-seed --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 94d5d60..25e42cf 100755 --- a/build.sbt +++ b/build.sbt @@ -16,7 +16,7 @@ Compile / sourceGenerators += Def.task { Seq(file) }.taskValue -libraryDependencies += "com.codacy" %% "codacy-engine-scala-seed" % "5.0.0" +libraryDependencies += "com.codacy" %% "codacy-engine-scala-seed" % "5.0.1" enablePlugins(GraalVMNativeImagePlugin) From b2c1ba8b7696f646c0dd41ed864817e25ec9bdcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20=20Melo?= Date: Wed, 28 Oct 2020 16:13:49 +0000 Subject: [PATCH 041/119] meta: Bump gajira-comment and gajira-create on Github workflow --- .github/workflows/comment_issue.yml | 2 +- .github/workflows/create_issue.yml | 2 +- .github/workflows/create_issue_on_label.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/comment_issue.yml b/.github/workflows/comment_issue.yml index 64b5ed0..12fb218 100644 --- a/.github/workflows/comment_issue.yml +++ b/.github/workflows/comment_issue.yml @@ -82,7 +82,7 @@ jobs: - name: Jira Add comment on issue if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' id: add_comment_jira_issue - uses: atlassian/gajira-comment@v2.0.0 + uses: atlassian/gajira-comment@v2.0.2 env: GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} diff --git a/.github/workflows/create_issue.yml b/.github/workflows/create_issue.yml index e8f62f0..14c9f3b 100644 --- a/.github/workflows/create_issue.yml +++ b/.github/workflows/create_issue.yml @@ -27,7 +27,7 @@ jobs: - name: Jira Create issue if: env.JIRA_CREATE_ISSUE_AUTO == 'true' id: create_jira_issue - uses: atlassian/gajira-create@v2.0.0 + uses: atlassian/gajira-create@v2.0.1 with: project: ${{ secrets.JIRA_PROJECT }} issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} diff --git a/.github/workflows/create_issue_on_label.yml b/.github/workflows/create_issue_on_label.yml index 632a3aa..de4ab93 100644 --- a/.github/workflows/create_issue_on_label.yml +++ b/.github/workflows/create_issue_on_label.yml @@ -27,7 +27,7 @@ jobs: - name: Jira Create issue if: github.event.label.name == env.JIRA_ISSUE_LABEL id: create_jira_issue - uses: atlassian/gajira-create@v2.0.0 + uses: atlassian/gajira-create@v2.0.1 with: project: ${{ secrets.JIRA_PROJECT }} issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} From fd899e982bb7697ad4526829767617ea7b865fb9 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 29 Mar 2021 17:20:12 +0200 Subject: [PATCH 042/119] fix: Timeout and other setting are not read at runtime - Update sbt-native-packager to 1.8.1 - Remove "--initialize-at-build-time" option - Update Graalvm to 21.0.0 --- .gitignore | 1 + build.sbt | 11 +++++------ project/build.properties | 2 +- project/plugins.sbt | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index c313053..75c3c80 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ target .metals .bloop .vscode +.bsp diff --git a/build.sbt b/build.sbt index 25e42cf..5d44990 100755 --- a/build.sbt +++ b/build.sbt @@ -16,20 +16,19 @@ Compile / sourceGenerators += Def.task { Seq(file) }.taskValue -libraryDependencies += "com.codacy" %% "codacy-engine-scala-seed" % "5.0.1" - enablePlugins(GraalVMNativeImagePlugin) -val graalVersion = "20.1.0-java11" +libraryDependencies ++= Seq( + "com.codacy" %% "codacy-engine-scala-seed" % "5.0.1", + "org.scalameta" %% "svm-subs" % "20.2.0" +) -graalVMNativeImageGraalVersion := Some(graalVersion) -containerBuildImage := Some(s"oracle/graalvm-ce:$graalVersion") +graalVMNativeImageGraalVersion := Some("21.0.0") graalVMNativeImageOptions ++= Seq( "-O1", "-H:+ReportExceptionStackTraces", "--no-fallback", "--no-server", - "--initialize-at-build-time", "--report-unsupported-elements-at-runtime", "--static" ) diff --git a/project/build.properties b/project/build.properties index a919a9b..d91c272 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.8 +sbt.version=1.4.6 diff --git a/project/plugins.sbt b/project/plugins.sbt index 4f2f225..46fe6a2 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,2 @@ -addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "20.0.7") -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.4") +addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "21.0.0") +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1") From ea98190cd5f78aab339d126bfcdd86feaa83de2b Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Tue, 30 Mar 2021 16:25:42 +0200 Subject: [PATCH 043/119] feature: Add documentation generator --- .circleci/config.yml | 6 + .gitignore | 1 + doc-generator.sc | 96 + docs/description/attributes.md | 5 + .../description/closure_parameter_position.md | 52 +- docs/description/computed_accessors_order.md | 267 ++ docs/description/description.json | 1933 ++++++------- docs/description/empty_enum_arguments.md | 20 + docs/description/explicit_acl.md | 50 +- docs/description/extension_access_modifier.md | 18 + docs/description/file_types_order.md | 46 +- .../description/ibinspectable_in_extension.md | 27 + docs/description/implicit_return.md | 2 +- .../multiline_arguments_brackets.md | 34 + .../multiline_parameters_brackets.md | 6 + docs/description/no_space_in_method_call.md | 4 + docs/description/opening_brace.md | 23 +- .../prefer_zero_over_explicit_init.md | 55 + .../raw_value_for_camel_cased_codable_enum.md | 13 + docs/description/switch_case_on_newline.md | 7 + .../unneeded_notification_center_removal.md | 56 + docs/patterns.json | 2518 +++++++++-------- 22 files changed, 3074 insertions(+), 2165 deletions(-) create mode 100644 doc-generator.sc create mode 100644 docs/description/computed_accessors_order.md create mode 100644 docs/description/ibinspectable_in_extension.md create mode 100644 docs/description/prefer_zero_over_explicit_init.md create mode 100644 docs/description/unneeded_notification_center_removal.md diff --git a/.circleci/config.yml b/.circleci/config.yml index 87fea04..50ab245 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,6 +18,12 @@ workflows: sbt:scalafmt::test; graalvm-native-image:packageBin" docker build -t $CIRCLE_PROJECT_REPONAME:latest . + # Install Ammonite + sudo sh -c '(echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/Ammonite/releases/download/2.3.8/2.13-2.3.8) > /usr/local/bin/amm && chmod +x /usr/local/bin/amm' + # Run doc-generator + sudo amm doc-generator.sc + # Update docker image with generated docs + docker build -t $CIRCLE_PROJECT_REPONAME:latest . docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest persist_to_workspace: true requires: diff --git a/.gitignore b/.gitignore index 75c3c80..ad209d4 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ target .bloop .vscode .bsp +.ammonite diff --git a/doc-generator.sc b/doc-generator.sc new file mode 100644 index 0000000..c013fd8 --- /dev/null +++ b/doc-generator.sc @@ -0,0 +1,96 @@ +import $ivy.`com.codacy::codacy-engine-scala-seed:5.0.3` + +import com.codacy.plugins.api._ +import com.codacy.plugins.api.results._ +import play.api.libs.json.Json + +val tempDir = os.temp.dir(dir = os.pwd / "target") + +val workdir = "/workdir" + +val baseCommand = Seq( + "docker", + "run", + s"--volume=$tempDir:$workdir", + s"-w=$workdir", + s"--user=root", + "--entrypoint=swiftlint", + "codacy-swiftlint" +) + +os.proc(baseCommand :+ "generate-docs").call() +// Hack: docker in CircleCI makes files only available to the root user +os.proc("sudo", "chmod", "-R", "777", tempDir).call() + +val rulesOutput = os.proc(baseCommand :+ "rules").call().out.lines().map(_.split('|').map(_.trim).toList.tail).tail + +val version = os.proc(baseCommand :+ "version").call().out.text().trim + +val mdFiles = os.list(tempDir / "rule_docs").filter(_.last != "Rule Directory.md") + +val docsDirectory = os.pwd / "docs" +val descriptionDirectory = docsDirectory / "description" + +val patternDescriptions = mdFiles.map { file => + val patternId = file.last.stripSuffix(".md") + val lines = os.read(file).linesIterator + val title = lines.next().stripPrefix("# ") + lines.next() + val description = lines.next() + Pattern.Description(Pattern.Id(patternId), Pattern.Title(title), Some(Pattern.DescriptionText(description)), None) +} + +val ids = rulesOutput.head.zipWithIndex.toMap + +case class SwiftlintRule( + identifier: String, + correctable: Boolean, + enabledInYourConfig: Boolean, + kind: String, + configuration: String +) + +val swiftLintRules = rulesOutput.tail + .filter(_.length == ids.size) + .map { arr => + def toBoolean(s: String) = s == "yes" + SwiftlintRule( + identifier = arr(ids("identifier")), + correctable = toBoolean(arr(ids("correctable"))), + enabledInYourConfig = toBoolean(arr(ids("enabled in your config"))), + kind = arr(ids("kind")), + configuration = arr(ids("configuration")) + ) + } + +def configurationToLevel(kind: String) = kind match { + case "warning" => Result.Level.Warn + case "error" => Result.Level.Err + case _ => Result.Level.Info +} + +def kindToCategory(kind: String) = kind match { + case "style" => Pattern.Category.CodeStyle + case "lint" => Pattern.Category.ErrorProne + case "performance" => Pattern.Category.Performance + case "metrics" => Pattern.Category.Complexity + case _ => Pattern.Category.ErrorProne +} + +val patternSpecifications = swiftLintRules.map { swiftLintRule => + Pattern.Specification( + Pattern.Id(swiftLintRule.identifier), + configurationToLevel(swiftLintRule.configuration), + kindToCategory(swiftLintRule.kind), + subcategory = None, + enabled = swiftLintRule.enabledInYourConfig + ) +} + +val specification = Tool.Specification(Tool.Name("swiftlint"), Some(Tool.Version(version)), patternSpecifications.toSet) + +os.write.over(os.pwd / "docs" / "patterns.json", Json.prettyPrint(Json.toJson(specification)) + "\n") +os.remove.all(descriptionDirectory) +mdFiles.foreach(os.copy.into(_, descriptionDirectory, replaceExisting = true, createFolders = true)) +os.write.over(descriptionDirectory / "description.json", Json.prettyPrint(Json.toJson(patternDescriptions)) + "\n") +os.remove.all(tempDir) diff --git a/docs/description/attributes.md b/docs/description/attributes.md index 98ec152..06a3627 100644 --- a/docs/description/attributes.md +++ b/docs/description/attributes.md @@ -197,6 +197,11 @@ class DeleteMeTests: XCTestCase { internal func foo(identifier: String, completion: @escaping (() -> Void)) {} ``` +```swift +@objc +internal func foo(identifier: String, completion: @autoclosure (() -> Bool)) {} +``` + ```swift func printBoolOrTrue(_ expression: @autoclosure () throws -> Bool?) rethrows { try print(expression() ?? true) diff --git a/docs/description/closure_parameter_position.md b/docs/description/closure_parameter_position.md index 8e1c8d8..7b1e585 100644 --- a/docs/description/closure_parameter_position.md +++ b/docs/description/closure_parameter_position.md @@ -80,64 +80,70 @@ let mediaView: UIView = { [weak self] index in ```swift [1, 2].map { - ↓number in - number + 1 + ↓number in + number + 1 } - ``` ```swift [1, 2].map { - ↓number -> Int in - number + 1 + ↓number -> Int in + number + 1 } - ``` ```swift [1, 2].map { - (↓number: Int) -> Int in - number + 1 + (↓number: Int) -> Int in + number + 1 } - ``` ```swift [1, 2].map { - [weak self] ↓number in - number + 1 + [weak ↓self] ↓number in + number + 1 } - ``` ```swift [1, 2].map { [weak self] - ↓number in - number + 1 + ↓number in + number + 1 } - ``` ```swift [1, 2].map({ - ↓number in - number + 1 + ↓number in + number + 1 }) - ``` ```swift [1, 2].something(closure: { - ↓number in - number + 1 + ↓number in + number + 1 }) - ``` ```swift [1, 2].reduce(0) { - ↓sum, ↓number in - number + sum + ↓sum, ↓number in + number + sum +}) +``` + +```swift +f.completionHandler = { + ↓thing in + doStuff() } +``` +```swift +foo { + [weak ↓self] in + self?.bar() +} ``` \ No newline at end of file diff --git a/docs/description/computed_accessors_order.md b/docs/description/computed_accessors_order.md new file mode 100644 index 0000000..d9ca38b --- /dev/null +++ b/docs/description/computed_accessors_order.md @@ -0,0 +1,267 @@ +# Computed Accessors Order + +Getter and setters in computed properties and subscripts should be in a consistent order. + +* **Identifier:** computed_accessors_order +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 4.1.0 +* **Default configuration:** warning, order: get_set + +## Non Triggering Examples + +```swift +class Foo { + var foo: Int { + get { return 3 } + set { _abc = newValue } + } +} +``` + +```swift +class Foo { + var foo: Int { + return 20 + } +} +``` + +```swift +class Foo { + static var foo: Int { + return 20 + } +} +``` + +```swift +class Foo { + static var foo: Int { + get { return 3 } + set { _abc = newValue } + } +} +``` + +```swift +class Foo { + var foo: Int +} +``` + +```swift +class Foo { + var foo: Int { + return getValueFromDisk() + } +} +``` + +```swift +class Foo { + var foo: String { + return "get" + } +} +``` + +```swift +protocol Foo { + var foo: Int { get } +``` + +```swift +protocol Foo { + var foo: Int { get set } +``` + +```swift +protocol Foo { + var foo: Int { set get } +``` + +```swift +class Foo { + var foo: Int { + struct Bar { + var bar: Int { + get { return 1 } + set { _ = newValue } + } + } + + return Bar().bar + } +} +``` + +```swift +var _objCTaggedPointerBits: UInt { + @inline(__always) get { return 0 } + set { print(newValue) } +} +``` + +```swift +var next: Int? { + mutating get { + defer { self.count += 1 } + return self.count + } + set { + self.count = newValue + } +} +``` + +```swift +extension Foo { + var bar: Bool { + get { _bar } + set { self._bar = newValue } + } +} +``` + +```swift +extension Foo { + var bar: Bool { + get { _bar } + set(newValue) { self._bar = newValue } + } +} +``` + +```swift +extension Reactive where Base: UITapGestureRecognizer { + var tapped: CocoaAction? { + get { + return associatedAction.withValue { $0.flatMap { $0.action } } + } + nonmutating set { + setAction(newValue) + } + } +} +``` + +```swift +extension Test { + var foo: Bool { + get { + bar?.boolValue ?? true // Comment mentioning word set which triggers violation + } + set { + bar = NSNumber(value: newValue as Bool) + } + } +} +``` + +```swift +class Foo { + subscript(i: Int) -> Int { + return 20 + } +} +``` + +```swift +class Foo { + subscript(i: Int) -> Int { + get { return 3 } + set { _abc = newValue } + } +} +``` + +```swift +protocol Foo { + subscript(i: Int) -> Int { get } +} +``` + +```swift +protocol Foo { + subscript(i: Int) -> Int { get set } +} +``` + +```swift +protocol Foo { + subscript(i: Int) -> Int { set get } +} +``` + +## Triggering Examples + +```swift +class Foo { + var foo: Int { + ↓set { + print(newValue) + } + get { + return 20 + } + } +} +``` + +```swift +class Foo { + static var foo: Int { + ↓set { + print(newValue) + } + get { + return 20 + } + } +} +``` + +```swift +var foo: Int { + ↓set { print(newValue) } + get { return 20 } +} +``` + +```swift +extension Foo { + var bar: Bool { + ↓set { print(bar) } + get { _bar } + } +} +``` + +```swift +class Foo { + var foo: Int { + ↓set { + print(newValue) + } + mutating get { + return 20 + } + } +} +``` + +```swift +class Foo { + subscript(i: Int) -> Int { + ↓set { + print(i) + } + get { + return 20 + } + } +} +``` \ No newline at end of file diff --git a/docs/description/description.json b/docs/description/description.json index 45cf6f9..cf7943d 100644 --- a/docs/description/description.json +++ b/docs/description/description.json @@ -1,957 +1,976 @@ -[ - { - "patternId": "anyobject_protocol", - "title": "AnyObject Protocol", - "description": "Prefer using `AnyObject` over `class` for class-only protocols." - }, - { - "patternId": "array_init", - "title": "Array Init", - "description": "Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array." - }, - { - "patternId": "attributes", - "title": "Attributes", - "description": "Attributes should be on their own lines in functions and types, but on the same line as variables and imports." - }, - { - "patternId": "block_based_kvo", - "title": "Block Based KVO", - "description": "Prefer the new block based KVO API with keypaths when using Swift 3.2 or later." - }, - { - "patternId": "class_delegate_protocol", - "title": "Class Delegate Protocol", - "description": "Delegate protocols should be class-only so they can be weakly referenced." - }, - { - "patternId": "closing_brace", - "title": "Closing Brace Spacing", - "description": "Closing brace with closing parenthesis should not have any whitespaces in the middle." - }, - { - "patternId": "closure_body_length", - "title": "Closure Body Length", - "description": "Closure bodies should not span too many lines." - }, - { - "patternId": "closure_end_indentation", - "title": "Closure End Indentation", - "description": "Closure end should have the same indentation as the line that started it." - }, - { - "patternId": "closure_parameter_position", - "title": "Closure Parameter Position", - "description": "Closure parameters should be on the same line as opening brace." - }, - { - "patternId": "closure_spacing", - "title": "Closure Spacing", - "description": "Closure expressions should have a single space inside each brace." - }, - { - "patternId": "collection_alignment", - "title": "Collection Element Alignment", - "description": "All elements in a collection literal should be vertically aligned" - }, - { - "patternId": "colon", - "title": "Colon", - "description": "Colons should be next to the identifier when specifying a type and next to the key in dictionary literals." - }, - { - "patternId": "comma", - "title": "Comma Spacing", - "description": "There should be no space before and one after any comma." - }, - { - "patternId": "compiler_protocol_init", - "title": "Compiler Protocol Init", - "description": "The initializers declared in compiler protocols such as `ExpressibleByArrayLiteral` shouldn't be called directly." - }, - { - "patternId": "conditional_returns_on_newline", - "title": "Conditional Returns on Newline", - "description": "Conditional statements should always return on the next line" - }, - { - "patternId": "contains_over_filter_count", - "title": "Contains Over Filter Count", - "description": "Prefer `contains` over comparing `filter(where:).count` to 0." - }, - { - "patternId": "contains_over_filter_is_empty", - "title": "Contains Over Filter Is Empty", - "description": "Prefer `contains` over using `filter(where:).isEmpty`" - }, - { - "patternId": "contains_over_first_not_nil", - "title": "Contains over first not nil", - "description": "Prefer `contains` over `first(where:) != nil` and `firstIndex(where:) != nil`." - }, - { - "patternId": "contains_over_range_nil_comparison", - "title": "Contains over range(of:) comparison to nil", - "description": "Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`." - }, - { - "patternId": "control_statement", - "title": "Control Statement", - "description": "`if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses." - }, - { - "patternId": "convenience_type", - "title": "Convenience Type", - "description": "Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation." - }, - { - "patternId": "custom_rules", - "title": "Custom Rules", - "description": "Create custom rules by providing a regex string. Optionally specify what syntax kinds to match against, the severity level, and what message to display." - }, - { - "patternId": "cyclomatic_complexity", - "title": "Cyclomatic Complexity", - "description": "Complexity of function bodies should be limited." - }, - { - "patternId": "deployment_target", - "title": "Deployment Target", - "description": "Availability checks or attributes shouldn't be using older versions that are satisfied by the deployment target." - }, - { - "patternId": "discarded_notification_center_observer", - "title": "Discarded Notification Center Observer", - "description": "When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later." - }, - { - "patternId": "discouraged_direct_init", - "title": "Discouraged Direct Initialization", - "description": "Discouraged direct initialization of types that can be harmful." - }, - { - "patternId": "discouraged_object_literal", - "title": "Discouraged Object Literal", - "description": "Prefer initializers over object literals." - }, - { - "patternId": "discouraged_optional_boolean", - "title": "Discouraged Optional Boolean", - "description": "Prefer non-optional booleans over optional booleans." - }, - { - "patternId": "discouraged_optional_collection", - "title": "Discouraged Optional Collection", - "description": "Prefer empty collection over optional collection." - }, - { - "patternId": "duplicate_enum_cases", - "title": "Duplicate Enum Cases", - "description": "Enum can't contain multiple cases with the same name." - }, - { - "patternId": "duplicate_imports", - "title": "Duplicate Imports", - "description": "Imports should be unique." - }, - { - "patternId": "dynamic_inline", - "title": "Dynamic Inline", - "description": "Avoid using 'dynamic' and '@inline(__always)' together." - }, - { - "patternId": "empty_collection_literal", - "title": "Empty Collection Literal", - "description": "Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal." - }, - { - "patternId": "empty_count", - "title": "Empty Count", - "description": "Prefer checking `isEmpty` over comparing `count` to zero." - }, - { - "patternId": "empty_enum_arguments", - "title": "Empty Enum Arguments", - "description": "Arguments can be omitted when matching enums with associated types if they are not used." - }, - { - "patternId": "empty_parameters", - "title": "Empty Parameters", - "description": "Prefer `() -> ` over `Void -> `." - }, - { - "patternId": "empty_parentheses_with_trailing_closure", - "title": "Empty Parentheses with Trailing Closure", - "description": "When using trailing closures, empty parentheses should be avoided after the method call." - }, - { - "patternId": "empty_string", - "title": "Empty String", - "description": "Prefer checking `isEmpty` over comparing `string` to an empty string literal." - }, - { - "patternId": "empty_xctest_method", - "title": "Empty XCTest Method", - "description": "Empty XCTest method should be avoided." - }, - { - "patternId": "enum_case_associated_values_count", - "title": "Enum Case Associated Values Count", - "description": "Number of associated values in an enum case should be low" - }, - { - "patternId": "expiring_todo", - "title": "ExpiringTodo", - "description": "TODOs and FIXMEs should be resolved prior to their expiry date." - }, - { - "patternId": "explicit_acl", - "title": "Explicit ACL", - "description": "All declarations should specify Access Control Level keywords explicitly." - }, - { - "patternId": "explicit_enum_raw_value", - "title": "Explicit Enum Raw Value", - "description": "Enums should be explicitly assigned their raw values." - }, - { - "patternId": "explicit_init", - "title": "Explicit Init", - "description": "Explicitly calling .init() should be avoided." - }, - { - "patternId": "explicit_self", - "title": "Explicit Self", - "description": "Instance variables and functions should be explicitly accessed with 'self.'." - }, - { - "patternId": "explicit_top_level_acl", - "title": "Explicit Top Level ACL", - "description": "Top-level declarations should specify Access Control Level keywords explicitly." - }, - { - "patternId": "explicit_type_interface", - "title": "Explicit Type Interface", - "description": "Properties should have a type interface" - }, - { - "patternId": "extension_access_modifier", - "title": "Extension Access Modifier", - "description": "Prefer to use extension access modifiers" - }, - { - "patternId": "fallthrough", - "title": "Fallthrough", - "description": "Fallthrough should be avoided." - }, - { - "patternId": "fatal_error_message", - "title": "Fatal Error Message", - "description": "A fatalError call should have a message." - }, - { - "patternId": "file_header", - "title": "File Header", - "description": "Header comments should be consistent with project patterns. The SWIFTLINT_CURRENT_FILENAME placeholder can optionally be used in the required and forbidden patterns. It will be replaced by the real file name." - }, - { - "patternId": "file_length", - "title": "File Line Length", - "description": "Files should not span too many lines." - }, - { - "patternId": "file_name", - "title": "File Name", - "description": "File name should match a type or extension declared in the file (if any)." - }, - { - "patternId": "file_name_no_space", - "title": "File Name No Space", - "description": "File name should not contain any whitespace." - }, - { - "patternId": "file_types_order", - "title": "File Types Order", - "description": "Specifies how the types within a file should be ordered." - }, - { - "patternId": "first_where", - "title": "First Where", - "description": "Prefer using `.first(where:)` over `.filter { }.first` in collections." - }, - { - "patternId": "flatmap_over_map_reduce", - "title": "FlatMap over map and reduce", - "description": "Prefer `flatMap` over `map` followed by `reduce([], +)`." - }, - { - "patternId": "for_where", - "title": "For Where", - "description": "`where` clauses are preferred over a single `if` inside a `for`." - }, - { - "patternId": "force_cast", - "title": "Force Cast", - "description": "Force casts should be avoided." - }, - { - "patternId": "force_try", - "title": "Force Try", - "description": "Force tries should be avoided." - }, - { - "patternId": "force_unwrapping", - "title": "Force Unwrapping", - "description": "Force unwrapping should be avoided." - }, - { - "patternId": "function_body_length", - "title": "Function Body Length", - "description": "Functions bodies should not span too many lines." - }, - { - "patternId": "function_default_parameter_at_end", - "title": "Function Default Parameter at End", - "description": "Prefer to locate parameters with defaults toward the end of the parameter list." - }, - { - "patternId": "function_parameter_count", - "title": "Function Parameter Count", - "description": "Number of function parameters should be low." - }, - { - "patternId": "generic_type_name", - "title": "Generic Type Name", - "description": "Generic type name should only contain alphanumeric characters, start with an uppercase character and span between 1 and 20 characters in length." - }, - { - "patternId": "identical_operands", - "title": "Identical Operands", - "description": "Comparing two identical operands is likely a mistake." - }, - { - "patternId": "identifier_name", - "title": "Identifier Name", - "description": "Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared static and immutable. Variable names should not be too long or too short." - }, - { - "patternId": "implicit_getter", - "title": "Implicit Getter", - "description": "Computed read-only properties and subscripts should avoid using the get keyword." - }, - { - "patternId": "implicit_return", - "title": "Implicit Return", - "description": "Prefer implicit returns in closures, functions and getters." - }, - { - "patternId": "implicitly_unwrapped_optional", - "title": "Implicitly Unwrapped Optional", - "description": "Implicitly unwrapped optionals should be avoided when possible." - }, - { - "patternId": "indentation_width", - "title": "Indentation Width", - "description": "Indent code using either one tab or the configured amount of spaces, unindent to match previous indentations. Don't indent the first line." - }, - { - "patternId": "inert_defer", - "title": "Inert Defer", - "description": "If defer is at the end of its parent scope, it will be executed right where it is anyway." - }, - { - "patternId": "is_disjoint", - "title": "Is Disjoint", - "description": "Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty`." - }, - { - "patternId": "joined_default_parameter", - "title": "Joined Default Parameter", - "description": "Discouraged explicit usage of the default separator." - }, - { - "patternId": "large_tuple", - "title": "Large Tuple", - "description": "Tuples shouldn't have too many members. Create a custom type instead." - }, - { - "patternId": "last_where", - "title": "Last Where", - "description": "Prefer using `.last(where:)` over `.filter { }.last` in collections." - }, - { - "patternId": "leading_whitespace", - "title": "Leading Whitespace", - "description": "Files should not contain leading whitespace." - }, - { - "patternId": "legacy_cggeometry_functions", - "title": "Legacy CGGeometry Functions", - "description": "Struct extension properties and methods are preferred over legacy functions" - }, - { - "patternId": "legacy_constant", - "title": "Legacy Constant", - "description": "Struct-scoped constants are preferred over legacy global constants." - }, - { - "patternId": "legacy_constructor", - "title": "Legacy Constructor", - "description": "Swift constructors are preferred over legacy convenience functions." - }, - { - "patternId": "legacy_hashing", - "title": "Legacy Hashing", - "description": "Prefer using the `hash(into:)` function instead of overriding `hashValue`" - }, - { - "patternId": "legacy_multiple", - "title": "Legacy Multiple", - "description": "Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`)." - }, - { - "patternId": "legacy_nsgeometry_functions", - "title": "Legacy NSGeometry Functions", - "description": "Struct extension properties and methods are preferred over legacy functions" - }, - { - "patternId": "legacy_random", - "title": "Legacy Random", - "description": "Prefer using `type.random(in:)` over legacy functions." - }, - { - "patternId": "let_var_whitespace", - "title": "Variable Declaration Whitespace", - "description": "Let and var should be separated from other statements by a blank line." - }, - { - "patternId": "line_length", - "title": "Line Length", - "description": "Lines should not span too many characters." - }, - { - "patternId": "literal_expression_end_indentation", - "title": "Literal Expression End Indentation", - "description": "Array and dictionary literal end should have the same indentation as the line that started it." - }, - { - "patternId": "lower_acl_than_parent", - "title": "Lower ACL than parent", - "description": "Ensure definitions have a lower access control level than their enclosing parent" - }, - { - "patternId": "mark", - "title": "Mark", - "description": "MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...'" - }, - { - "patternId": "missing_docs", - "title": "Missing Docs", - "description": "Declarations should be documented." - }, - { - "patternId": "modifier_order", - "title": "Modifier Order", - "description": "Modifier order should be consistent." - }, - { - "patternId": "multiline_arguments", - "title": "Multiline Arguments", - "description": "Arguments should be either on the same line, or one per line." - }, - { - "patternId": "multiline_arguments_brackets", - "title": "Multiline Arguments Brackets", - "description": "Multiline arguments should have their surrounding brackets in a new line." - }, - { - "patternId": "multiline_function_chains", - "title": "Multiline Function Chains", - "description": "Chained function calls should be either on the same line, or one per line." - }, - { - "patternId": "multiline_literal_brackets", - "title": "Multiline Literal Brackets", - "description": "Multiline literals should have their surrounding brackets in a new line." - }, - { - "patternId": "multiline_parameters", - "title": "Multiline Parameters", - "description": "Functions and methods parameters should be either on the same line, or one per line." - }, - { - "patternId": "multiline_parameters_brackets", - "title": "Multiline Parameters Brackets", - "description": "Multiline parameters should have their surrounding brackets in a new line." - }, - { - "patternId": "multiple_closures_with_trailing_closure", - "title": "Multiple Closures with Trailing Closure", - "description": "Trailing closure syntax should not be used when passing more than one closure argument." - }, - { - "patternId": "nesting", - "title": "Nesting", - "description": "Types should be nested at most 1 level deep, and statements should be nested at most 5 levels deep." - }, - { - "patternId": "nimble_operator", - "title": "Nimble Operator", - "description": "Prefer Nimble operator overloads over free matcher functions." - }, - { - "patternId": "no_extension_access_modifier", - "title": "No Extension Access Modifier", - "description": "Prefer not to use extension access modifiers" - }, - { - "patternId": "no_fallthrough_only", - "title": "No Fallthrough Only", - "description": "Fallthroughs can only be used if the `case` contains at least one other statement." - }, - { - "patternId": "no_grouping_extension", - "title": "No Grouping Extension", - "description": "Extensions shouldn't be used to group code within the same source file." - }, - { - "patternId": "no_space_in_method_call", - "title": "No Space in Method Call", - "description": "Don't add a space between the method name and the parentheses." - }, - { - "patternId": "notification_center_detachment", - "title": "Notification Center Detachment", - "description": "An object should only remove itself as an observer in `deinit`." - }, - { - "patternId": "nslocalizedstring_key", - "title": "NSLocalizedString Key", - "description": "Static strings should be used as key in NSLocalizedString in order to genstrings work." - }, - { - "patternId": "nslocalizedstring_require_bundle", - "title": "NSLocalizedString Require Bundle", - "description": "Calls to NSLocalizedString should specify the bundle which contains the strings file." - }, - { - "patternId": "nsobject_prefer_isequal", - "title": "NSObject Prefer isEqual", - "description": "NSObject subclasses should implement isEqual instead of ==." - }, - { - "patternId": "number_separator", - "title": "Number Separator", - "description": "Underscores should be used as thousand separator in large decimal numbers." - }, - { - "patternId": "object_literal", - "title": "Object Literal", - "description": "Prefer object literals over image and color inits." - }, - { - "patternId": "opening_brace", - "title": "Opening Brace Spacing", - "description": "Opening braces should be preceded by a single space and on the same line as the declaration." - }, - { - "patternId": "operator_usage_whitespace", - "title": "Operator Usage Whitespace", - "description": "Operators should be surrounded by a single whitespace when they are being used." - }, - { - "patternId": "operator_whitespace", - "title": "Operator Function Whitespace", - "description": "Operators should be surrounded by a single whitespace when defining them." - }, - { - "patternId": "optional_enum_case_matching", - "title": "Optional Enum Case Match", - "description": "Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above." - }, - { - "patternId": "orphaned_doc_comment", - "title": "Orphaned Doc Comment", - "description": "A doc comment should be attached to a declaration." - }, - { - "patternId": "overridden_super_call", - "title": "Overridden methods call super", - "description": "Some overridden methods should always call super" - }, - { - "patternId": "override_in_extension", - "title": "Override in Extension", - "description": "Extensions shouldn't override declarations." - }, - { - "patternId": "pattern_matching_keywords", - "title": "Pattern Matching Keywords", - "description": "Combine multiple pattern matching bindings by moving keywords out of tuples." - }, - { - "patternId": "prefer_self_type_over_type_of_self", - "title": "Prefer Self Type Over Type of Self", - "description": "Prefer `Self` over `type(of: self)` when accessing properties or calling methods." - }, - { - "patternId": "prefixed_toplevel_constant", - "title": "Prefixed Top-Level Constant", - "description": "Top-level constants should be prefixed by `k`." - }, - { - "patternId": "private_action", - "title": "Private Actions", - "description": "IBActions should be private." - }, - { - "patternId": "private_outlet", - "title": "Private Outlets", - "description": "IBOutlets should be private to avoid leaking UIKit to higher layers." - }, - { - "patternId": "private_over_fileprivate", - "title": "Private over fileprivate", - "description": "Prefer `private` over `fileprivate` declarations." - }, - { - "patternId": "private_unit_test", - "title": "Private Unit Test", - "description": "Unit tests marked private are silently skipped." - }, - { - "patternId": "prohibited_interface_builder", - "title": "Prohibited Interface Builder", - "description": "Creating views using Interface Builder should be avoided." - }, - { - "patternId": "prohibited_super_call", - "title": "Prohibited calls to super", - "description": "Some methods should not call super" - }, - { - "patternId": "protocol_property_accessors_order", - "title": "Protocol Property Accessors Order", - "description": "When declaring properties in protocols, the order of accessors should be `get set`." - }, - { - "patternId": "quick_discouraged_call", - "title": "Quick Discouraged Call", - "description": "Discouraged call inside 'describe' and/or 'context' block." - }, - { - "patternId": "quick_discouraged_focused_test", - "title": "Quick Discouraged Focused Test", - "description": "Discouraged focused test. Other tests won't run while this one is focused." - }, - { - "patternId": "quick_discouraged_pending_test", - "title": "Quick Discouraged Pending Test", - "description": "Discouraged pending test. This test won't run while it's marked as pending." - }, - { - "patternId": "raw_value_for_camel_cased_codable_enum", - "title": "Raw Value For Camel Cased Codable Enum", - "description": "Camel cased cases of Codable String enums should have raw value." - }, - { - "patternId": "reduce_boolean", - "title": "Reduce Boolean", - "description": "Prefer using `.allSatisfy()` or `.contains()` over `reduce(true)` or `reduce(false)`" - }, - { - "patternId": "reduce_into", - "title": "Reduce Into", - "description": "Prefer `reduce(into:_:)` over `reduce(_:_:)` for copy-on-write types" - }, - { - "patternId": "redundant_discardable_let", - "title": "Redundant Discardable Let", - "description": "Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function." - }, - { - "patternId": "redundant_nil_coalescing", - "title": "Redundant Nil Coalescing", - "description": "nil coalescing operator is only evaluated if the lhs is nil, coalescing operator with nil as rhs is redundant" - }, - { - "patternId": "redundant_objc_attribute", - "title": "Redundant @objc Attribute", - "description": "Objective-C attribute (@objc) is redundant in declaration." - }, - { - "patternId": "redundant_optional_initialization", - "title": "Redundant Optional Initialization", - "description": "Initializing an optional variable with nil is redundant." - }, - { - "patternId": "redundant_set_access_control", - "title": "Redundant Set Access Control Rule", - "description": "Property setter access level shouldn't be explicit if it's the same as the variable access level." - }, - { - "patternId": "redundant_string_enum_value", - "title": "Redundant String Enum Value", - "description": "String enum values can be omitted when they are equal to the enumcase name." - }, - { - "patternId": "redundant_type_annotation", - "title": "Redundant Type Annotation", - "description": "Variables should not have redundant type annotation" - }, - { - "patternId": "redundant_void_return", - "title": "Redundant Void Return", - "description": "Returning Void in a function declaration is redundant." - }, - { - "patternId": "required_deinit", - "title": "Required Deinit", - "description": "Classes should have an explicit deinit method." - }, - { - "patternId": "required_enum_case", - "title": "Required Enum Case", - "description": "Enums conforming to a specified protocol must implement a specific case(s)." - }, - { - "patternId": "return_arrow_whitespace", - "title": "Returning Whitespace", - "description": "Return arrow and return type should be separated by a single space or on a separate line." - }, - { - "patternId": "shorthand_operator", - "title": "Shorthand Operator", - "description": "Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning." - }, - { - "patternId": "single_test_class", - "title": "Single Test Class", - "description": "Test files should contain a single QuickSpec or XCTestCase class." - }, - { - "patternId": "sorted_first_last", - "title": "Min or Max over Sorted First or Last", - "description": "Prefer using `min()` or `max()` over `sorted().first` or `sorted().last`" - }, - { - "patternId": "sorted_imports", - "title": "Sorted Imports", - "description": "Imports should be sorted." - }, - { - "patternId": "statement_position", - "title": "Statement Position", - "description": "Else and catch should be on the same line, one space after the previous declaration." - }, - { - "patternId": "static_operator", - "title": "Static Operator", - "description": "Operators should be declared as static functions, not free functions." - }, - { - "patternId": "strict_fileprivate", - "title": "Strict fileprivate", - "description": "`fileprivate` should be avoided." - }, - { - "patternId": "strong_iboutlet", - "title": "Strong IBOutlet", - "description": "@IBOutlets shouldn't be declared as weak." - }, - { - "patternId": "superfluous_disable_command", - "title": "Superfluous Disable Command", - "description": "SwiftLint 'disable' commands are superfluous when the disabled rule would not have triggered a violation in the disabled region. Use \" - \" if you wish to document a command." - }, - { - "patternId": "switch_case_alignment", - "title": "Switch and Case Statement Alignment", - "description": "Case statements should vertically align with their enclosing switch statement, or indented if configured otherwise." - }, - { - "patternId": "switch_case_on_newline", - "title": "Switch Case on Newline", - "description": "Cases inside a switch should always be on a newline" - }, - { - "patternId": "syntactic_sugar", - "title": "Syntactic Sugar", - "description": "Shorthand syntactic sugar should be used, i.e. [Int] instead of Array." - }, - { - "patternId": "todo", - "title": "Todo", - "description": "TODOs and FIXMEs should be resolved." - }, - { - "patternId": "toggle_bool", - "title": "Toggle Bool", - "description": "Prefer `someBool.toggle()` over `someBool = !someBool`." - }, - { - "patternId": "trailing_closure", - "title": "Trailing Closure", - "description": "Trailing closure syntax should be used whenever possible." - }, - { - "patternId": "trailing_comma", - "title": "Trailing Comma", - "description": "Trailing commas in arrays and dictionaries should be avoided/enforced." - }, - { - "patternId": "trailing_newline", - "title": "Trailing Newline", - "description": "Files should have a single trailing newline." - }, - { - "patternId": "trailing_semicolon", - "title": "Trailing Semicolon", - "description": "Lines should not have trailing semicolons." - }, - { - "patternId": "trailing_whitespace", - "title": "Trailing Whitespace", - "description": "Lines should not have trailing whitespace." - }, - { - "patternId": "type_body_length", - "title": "Type Body Length", - "description": "Type bodies should not span too many lines." - }, - { - "patternId": "type_contents_order", - "title": "Type Contents Order", - "description": "Specifies the order of subtypes, properties, methods & more within a type." - }, - { - "patternId": "type_name", - "title": "Type Name", - "description": "Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 40 characters in length." - }, - { - "patternId": "unavailable_function", - "title": "Unavailable Function", - "description": "Unimplemented functions should be marked as unavailable." - }, - { - "patternId": "unneeded_break_in_switch", - "title": "Unneeded Break in Switch", - "description": "Avoid using unneeded break statements." - }, - { - "patternId": "unneeded_parentheses_in_closure_argument", - "title": "Unneeded Parentheses in Closure Argument", - "description": "Parentheses are not needed when declaring closure arguments." - }, - { - "patternId": "unowned_variable_capture", - "title": "Unowned Variable Capture", - "description": "Prefer capturing references as weak to avoid potential crashes." - }, - { - "patternId": "untyped_error_in_catch", - "title": "Untyped Error in Catch", - "description": "Catch statements should not declare error variables without type casting." - }, - { - "patternId": "unused_capture_list", - "title": "Unused Capture List", - "description": "Unused reference in a capture list should be removed." - }, - { - "patternId": "unused_closure_parameter", - "title": "Unused Closure Parameter", - "description": "Unused parameter in a closure should be replaced with _." - }, - { - "patternId": "unused_control_flow_label", - "title": "Unused Control Flow Label", - "description": "Unused control flow label should be removed." - }, - { - "patternId": "unused_declaration", - "title": "Unused Declaration", - "description": "Declarations should be referenced at least once within all files linted." - }, - { - "patternId": "unused_enumerated", - "title": "Unused Enumerated", - "description": "When the index or the item is not used, `.enumerated()` can be removed." - }, - { - "patternId": "unused_import", - "title": "Unused Import", - "description": "All imported modules should be required to make the file compile." - }, - { - "patternId": "unused_optional_binding", - "title": "Unused Optional Binding", - "description": "Prefer `!= nil` over `let _ =`" - }, - { - "patternId": "unused_setter_value", - "title": "Unused Setter Value", - "description": "Setter value is not used." - }, - { - "patternId": "valid_ibinspectable", - "title": "Valid IBInspectable", - "description": "@IBInspectable should be applied to variables only, have its type explicit and be of a supported type" - }, - { - "patternId": "vertical_parameter_alignment", - "title": "Vertical Parameter Alignment", - "description": "Function parameters should be aligned vertically if they're in multiple lines in a declaration." - }, - { - "patternId": "vertical_parameter_alignment_on_call", - "title": "Vertical Parameter Alignment On Call", - "description": "Function parameters should be aligned vertically if they're in multiple lines in a method call." - }, - { - "patternId": "vertical_whitespace", - "title": "Vertical Whitespace", - "description": "Limit vertical whitespace to a single empty line." - }, - { - "patternId": "vertical_whitespace_between_cases", - "title": "Vertical Whitespace Between Cases", - "description": "Include a single empty line between switch cases." - }, - { - "patternId": "vertical_whitespace_closing_braces", - "title": "Vertical Whitespace before Closing Braces", - "description": "Don't include vertical whitespace (empty line) before closing braces." - }, - { - "patternId": "vertical_whitespace_opening_braces", - "title": "Vertical Whitespace after Opening Braces", - "description": "Don't include vertical whitespace (empty line) after opening braces." - }, - { - "patternId": "void_return", - "title": "Void Return", - "description": "Prefer `-> Void` over `-> ()`." - }, - { - "patternId": "weak_delegate", - "title": "Weak Delegate", - "description": "Delegates should be weak to avoid reference cycles." - }, - { - "patternId": "xct_specific_matcher", - "title": "XCTest Specific Matcher", - "description": "Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual`" - }, - { - "patternId": "xctfail_message", - "title": "XCTFail Message", - "description": "An XCTFail call should include a description of the assertion." - }, - { - "patternId": "yoda_condition", - "title": "Yoda condition rule", - "description": "The variable should be placed on the left, the constant on the right of a comparison operator." - } -] +[ { + "patternId" : "anyobject_protocol", + "title" : "AnyObject Protocol", + "description" : "Prefer using `AnyObject` over `class` for class-only protocols.", + "parameters" : [ ] +}, { + "patternId" : "array_init", + "title" : "Array Init", + "description" : "Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array.", + "parameters" : [ ] +}, { + "patternId" : "attributes", + "title" : "Attributes", + "description" : "Attributes should be on their own lines in functions and types, but on the same line as variables and imports.", + "parameters" : [ ] +}, { + "patternId" : "block_based_kvo", + "title" : "Block Based KVO", + "description" : "Prefer the new block based KVO API with keypaths when using Swift 3.2 or later.", + "parameters" : [ ] +}, { + "patternId" : "class_delegate_protocol", + "title" : "Class Delegate Protocol", + "description" : "Delegate protocols should be class-only so they can be weakly referenced.", + "parameters" : [ ] +}, { + "patternId" : "closing_brace", + "title" : "Closing Brace Spacing", + "description" : "Closing brace with closing parenthesis should not have any whitespaces in the middle.", + "parameters" : [ ] +}, { + "patternId" : "closure_body_length", + "title" : "Closure Body Length", + "description" : "Closure bodies should not span too many lines.", + "parameters" : [ ] +}, { + "patternId" : "closure_end_indentation", + "title" : "Closure End Indentation", + "description" : "Closure end should have the same indentation as the line that started it.", + "parameters" : [ ] +}, { + "patternId" : "closure_parameter_position", + "title" : "Closure Parameter Position", + "description" : "Closure parameters should be on the same line as opening brace.", + "parameters" : [ ] +}, { + "patternId" : "closure_spacing", + "title" : "Closure Spacing", + "description" : "Closure expressions should have a single space inside each brace.", + "parameters" : [ ] +}, { + "patternId" : "collection_alignment", + "title" : "Collection Element Alignment", + "description" : "All elements in a collection literal should be vertically aligned", + "parameters" : [ ] +}, { + "patternId" : "colon", + "title" : "Colon", + "description" : "Colons should be next to the identifier when specifying a type and next to the key in dictionary literals.", + "parameters" : [ ] +}, { + "patternId" : "comma", + "title" : "Comma Spacing", + "description" : "There should be no space before and one after any comma.", + "parameters" : [ ] +}, { + "patternId" : "compiler_protocol_init", + "title" : "Compiler Protocol Init", + "description" : "The initializers declared in compiler protocols such as `ExpressibleByArrayLiteral` shouldn't be called directly.", + "parameters" : [ ] +}, { + "patternId" : "computed_accessors_order", + "title" : "Computed Accessors Order", + "description" : "Getter and setters in computed properties and subscripts should be in a consistent order.", + "parameters" : [ ] +}, { + "patternId" : "conditional_returns_on_newline", + "title" : "Conditional Returns on Newline", + "description" : "Conditional statements should always return on the next line", + "parameters" : [ ] +}, { + "patternId" : "contains_over_filter_count", + "title" : "Contains Over Filter Count", + "description" : "Prefer `contains` over comparing `filter(where:).count` to 0.", + "parameters" : [ ] +}, { + "patternId" : "contains_over_filter_is_empty", + "title" : "Contains Over Filter Is Empty", + "description" : "Prefer `contains` over using `filter(where:).isEmpty`", + "parameters" : [ ] +}, { + "patternId" : "contains_over_first_not_nil", + "title" : "Contains over first not nil", + "description" : "Prefer `contains` over `first(where:) != nil` and `firstIndex(where:) != nil`.", + "parameters" : [ ] +}, { + "patternId" : "contains_over_range_nil_comparison", + "title" : "Contains over range(of:) comparison to nil", + "description" : "Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`.", + "parameters" : [ ] +}, { + "patternId" : "control_statement", + "title" : "Control Statement", + "description" : "`if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses.", + "parameters" : [ ] +}, { + "patternId" : "convenience_type", + "title" : "Convenience Type", + "description" : "Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation.", + "parameters" : [ ] +}, { + "patternId" : "custom_rules", + "title" : "Custom Rules", + "description" : "Create custom rules by providing a regex string. Optionally specify what syntax kinds to match against, the severity level, and what message to display.", + "parameters" : [ ] +}, { + "patternId" : "cyclomatic_complexity", + "title" : "Cyclomatic Complexity", + "description" : "Complexity of function bodies should be limited.", + "parameters" : [ ] +}, { + "patternId" : "deployment_target", + "title" : "Deployment Target", + "description" : "Availability checks or attributes shouldn't be using older versions that are satisfied by the deployment target.", + "parameters" : [ ] +}, { + "patternId" : "discarded_notification_center_observer", + "title" : "Discarded Notification Center Observer", + "description" : "When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later.", + "parameters" : [ ] +}, { + "patternId" : "discouraged_direct_init", + "title" : "Discouraged Direct Initialization", + "description" : "Discouraged direct initialization of types that can be harmful.", + "parameters" : [ ] +}, { + "patternId" : "discouraged_object_literal", + "title" : "Discouraged Object Literal", + "description" : "Prefer initializers over object literals.", + "parameters" : [ ] +}, { + "patternId" : "discouraged_optional_boolean", + "title" : "Discouraged Optional Boolean", + "description" : "Prefer non-optional booleans over optional booleans.", + "parameters" : [ ] +}, { + "patternId" : "discouraged_optional_collection", + "title" : "Discouraged Optional Collection", + "description" : "Prefer empty collection over optional collection.", + "parameters" : [ ] +}, { + "patternId" : "duplicate_enum_cases", + "title" : "Duplicate Enum Cases", + "description" : "Enum can't contain multiple cases with the same name.", + "parameters" : [ ] +}, { + "patternId" : "duplicate_imports", + "title" : "Duplicate Imports", + "description" : "Imports should be unique.", + "parameters" : [ ] +}, { + "patternId" : "dynamic_inline", + "title" : "Dynamic Inline", + "description" : "Avoid using 'dynamic' and '@inline(__always)' together.", + "parameters" : [ ] +}, { + "patternId" : "empty_collection_literal", + "title" : "Empty Collection Literal", + "description" : "Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal.", + "parameters" : [ ] +}, { + "patternId" : "empty_count", + "title" : "Empty Count", + "description" : "Prefer checking `isEmpty` over comparing `count` to zero.", + "parameters" : [ ] +}, { + "patternId" : "empty_enum_arguments", + "title" : "Empty Enum Arguments", + "description" : "Arguments can be omitted when matching enums with associated types if they are not used.", + "parameters" : [ ] +}, { + "patternId" : "empty_parameters", + "title" : "Empty Parameters", + "description" : "Prefer `() -> ` over `Void -> `.", + "parameters" : [ ] +}, { + "patternId" : "empty_parentheses_with_trailing_closure", + "title" : "Empty Parentheses with Trailing Closure", + "description" : "When using trailing closures, empty parentheses should be avoided after the method call.", + "parameters" : [ ] +}, { + "patternId" : "empty_string", + "title" : "Empty String", + "description" : "Prefer checking `isEmpty` over comparing `string` to an empty string literal.", + "parameters" : [ ] +}, { + "patternId" : "empty_xctest_method", + "title" : "Empty XCTest Method", + "description" : "Empty XCTest method should be avoided.", + "parameters" : [ ] +}, { + "patternId" : "enum_case_associated_values_count", + "title" : "Enum Case Associated Values Count", + "description" : "Number of associated values in an enum case should be low", + "parameters" : [ ] +}, { + "patternId" : "expiring_todo", + "title" : "ExpiringTodo", + "description" : "TODOs and FIXMEs should be resolved prior to their expiry date.", + "parameters" : [ ] +}, { + "patternId" : "explicit_acl", + "title" : "Explicit ACL", + "description" : "All declarations should specify Access Control Level keywords explicitly.", + "parameters" : [ ] +}, { + "patternId" : "explicit_enum_raw_value", + "title" : "Explicit Enum Raw Value", + "description" : "Enums should be explicitly assigned their raw values.", + "parameters" : [ ] +}, { + "patternId" : "explicit_init", + "title" : "Explicit Init", + "description" : "Explicitly calling .init() should be avoided.", + "parameters" : [ ] +}, { + "patternId" : "explicit_self", + "title" : "Explicit Self", + "description" : "Instance variables and functions should be explicitly accessed with 'self.'.", + "parameters" : [ ] +}, { + "patternId" : "explicit_top_level_acl", + "title" : "Explicit Top Level ACL", + "description" : "Top-level declarations should specify Access Control Level keywords explicitly.", + "parameters" : [ ] +}, { + "patternId" : "explicit_type_interface", + "title" : "Explicit Type Interface", + "description" : "Properties should have a type interface", + "parameters" : [ ] +}, { + "patternId" : "extension_access_modifier", + "title" : "Extension Access Modifier", + "description" : "Prefer to use extension access modifiers", + "parameters" : [ ] +}, { + "patternId" : "fallthrough", + "title" : "Fallthrough", + "description" : "Fallthrough should be avoided.", + "parameters" : [ ] +}, { + "patternId" : "fatal_error_message", + "title" : "Fatal Error Message", + "description" : "A fatalError call should have a message.", + "parameters" : [ ] +}, { + "patternId" : "file_header", + "title" : "File Header", + "description" : "Header comments should be consistent with project patterns. The SWIFTLINT_CURRENT_FILENAME placeholder can optionally be used in the required and forbidden patterns. It will be replaced by the real file name.", + "parameters" : [ ] +}, { + "patternId" : "file_length", + "title" : "File Line Length", + "description" : "Files should not span too many lines.", + "parameters" : [ ] +}, { + "patternId" : "file_name", + "title" : "File Name", + "description" : "File name should match a type or extension declared in the file (if any).", + "parameters" : [ ] +}, { + "patternId" : "file_name_no_space", + "title" : "File Name No Space", + "description" : "File name should not contain any whitespace.", + "parameters" : [ ] +}, { + "patternId" : "file_types_order", + "title" : "File Types Order", + "description" : "Specifies how the types within a file should be ordered.", + "parameters" : [ ] +}, { + "patternId" : "first_where", + "title" : "First Where", + "description" : "Prefer using `.first(where:)` over `.filter { }.first` in collections.", + "parameters" : [ ] +}, { + "patternId" : "flatmap_over_map_reduce", + "title" : "FlatMap over map and reduce", + "description" : "Prefer `flatMap` over `map` followed by `reduce([], +)`.", + "parameters" : [ ] +}, { + "patternId" : "for_where", + "title" : "For Where", + "description" : "`where` clauses are preferred over a single `if` inside a `for`.", + "parameters" : [ ] +}, { + "patternId" : "force_cast", + "title" : "Force Cast", + "description" : "Force casts should be avoided.", + "parameters" : [ ] +}, { + "patternId" : "force_try", + "title" : "Force Try", + "description" : "Force tries should be avoided.", + "parameters" : [ ] +}, { + "patternId" : "force_unwrapping", + "title" : "Force Unwrapping", + "description" : "Force unwrapping should be avoided.", + "parameters" : [ ] +}, { + "patternId" : "function_body_length", + "title" : "Function Body Length", + "description" : "Functions bodies should not span too many lines.", + "parameters" : [ ] +}, { + "patternId" : "function_default_parameter_at_end", + "title" : "Function Default Parameter at End", + "description" : "Prefer to locate parameters with defaults toward the end of the parameter list.", + "parameters" : [ ] +}, { + "patternId" : "function_parameter_count", + "title" : "Function Parameter Count", + "description" : "Number of function parameters should be low.", + "parameters" : [ ] +}, { + "patternId" : "generic_type_name", + "title" : "Generic Type Name", + "description" : "Generic type name should only contain alphanumeric characters, start with an uppercase character and span between 1 and 20 characters in length.", + "parameters" : [ ] +}, { + "patternId" : "ibinspectable_in_extension", + "title" : "IBInspectable in Extension", + "description" : "Extensions shouldn't add @IBInspectable properties.", + "parameters" : [ ] +}, { + "patternId" : "identical_operands", + "title" : "Identical Operands", + "description" : "Comparing two identical operands is likely a mistake.", + "parameters" : [ ] +}, { + "patternId" : "identifier_name", + "title" : "Identifier Name", + "description" : "Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared static and immutable. Variable names should not be too long or too short.", + "parameters" : [ ] +}, { + "patternId" : "implicit_getter", + "title" : "Implicit Getter", + "description" : "Computed read-only properties and subscripts should avoid using the get keyword.", + "parameters" : [ ] +}, { + "patternId" : "implicit_return", + "title" : "Implicit Return", + "description" : "Prefer implicit returns in closures, functions and getters.", + "parameters" : [ ] +}, { + "patternId" : "implicitly_unwrapped_optional", + "title" : "Implicitly Unwrapped Optional", + "description" : "Implicitly unwrapped optionals should be avoided when possible.", + "parameters" : [ ] +}, { + "patternId" : "indentation_width", + "title" : "Indentation Width", + "description" : "Indent code using either one tab or the configured amount of spaces, unindent to match previous indentations. Don't indent the first line.", + "parameters" : [ ] +}, { + "patternId" : "inert_defer", + "title" : "Inert Defer", + "description" : "If defer is at the end of its parent scope, it will be executed right where it is anyway.", + "parameters" : [ ] +}, { + "patternId" : "is_disjoint", + "title" : "Is Disjoint", + "description" : "Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty`.", + "parameters" : [ ] +}, { + "patternId" : "joined_default_parameter", + "title" : "Joined Default Parameter", + "description" : "Discouraged explicit usage of the default separator.", + "parameters" : [ ] +}, { + "patternId" : "large_tuple", + "title" : "Large Tuple", + "description" : "Tuples shouldn't have too many members. Create a custom type instead.", + "parameters" : [ ] +}, { + "patternId" : "last_where", + "title" : "Last Where", + "description" : "Prefer using `.last(where:)` over `.filter { }.last` in collections.", + "parameters" : [ ] +}, { + "patternId" : "leading_whitespace", + "title" : "Leading Whitespace", + "description" : "Files should not contain leading whitespace.", + "parameters" : [ ] +}, { + "patternId" : "legacy_cggeometry_functions", + "title" : "Legacy CGGeometry Functions", + "description" : "Struct extension properties and methods are preferred over legacy functions", + "parameters" : [ ] +}, { + "patternId" : "legacy_constant", + "title" : "Legacy Constant", + "description" : "Struct-scoped constants are preferred over legacy global constants.", + "parameters" : [ ] +}, { + "patternId" : "legacy_constructor", + "title" : "Legacy Constructor", + "description" : "Swift constructors are preferred over legacy convenience functions.", + "parameters" : [ ] +}, { + "patternId" : "legacy_hashing", + "title" : "Legacy Hashing", + "description" : "Prefer using the `hash(into:)` function instead of overriding `hashValue`", + "parameters" : [ ] +}, { + "patternId" : "legacy_multiple", + "title" : "Legacy Multiple", + "description" : "Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`).", + "parameters" : [ ] +}, { + "patternId" : "legacy_nsgeometry_functions", + "title" : "Legacy NSGeometry Functions", + "description" : "Struct extension properties and methods are preferred over legacy functions", + "parameters" : [ ] +}, { + "patternId" : "legacy_random", + "title" : "Legacy Random", + "description" : "Prefer using `type.random(in:)` over legacy functions.", + "parameters" : [ ] +}, { + "patternId" : "let_var_whitespace", + "title" : "Variable Declaration Whitespace", + "description" : "Let and var should be separated from other statements by a blank line.", + "parameters" : [ ] +}, { + "patternId" : "line_length", + "title" : "Line Length", + "description" : "Lines should not span too many characters.", + "parameters" : [ ] +}, { + "patternId" : "literal_expression_end_indentation", + "title" : "Literal Expression End Indentation", + "description" : "Array and dictionary literal end should have the same indentation as the line that started it.", + "parameters" : [ ] +}, { + "patternId" : "lower_acl_than_parent", + "title" : "Lower ACL than parent", + "description" : "Ensure definitions have a lower access control level than their enclosing parent", + "parameters" : [ ] +}, { + "patternId" : "mark", + "title" : "Mark", + "description" : "MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...'", + "parameters" : [ ] +}, { + "patternId" : "missing_docs", + "title" : "Missing Docs", + "description" : "Declarations should be documented.", + "parameters" : [ ] +}, { + "patternId" : "modifier_order", + "title" : "Modifier Order", + "description" : "Modifier order should be consistent.", + "parameters" : [ ] +}, { + "patternId" : "multiline_arguments", + "title" : "Multiline Arguments", + "description" : "Arguments should be either on the same line, or one per line.", + "parameters" : [ ] +}, { + "patternId" : "multiline_arguments_brackets", + "title" : "Multiline Arguments Brackets", + "description" : "Multiline arguments should have their surrounding brackets in a new line.", + "parameters" : [ ] +}, { + "patternId" : "multiline_function_chains", + "title" : "Multiline Function Chains", + "description" : "Chained function calls should be either on the same line, or one per line.", + "parameters" : [ ] +}, { + "patternId" : "multiline_literal_brackets", + "title" : "Multiline Literal Brackets", + "description" : "Multiline literals should have their surrounding brackets in a new line.", + "parameters" : [ ] +}, { + "patternId" : "multiline_parameters", + "title" : "Multiline Parameters", + "description" : "Functions and methods parameters should be either on the same line, or one per line.", + "parameters" : [ ] +}, { + "patternId" : "multiline_parameters_brackets", + "title" : "Multiline Parameters Brackets", + "description" : "Multiline parameters should have their surrounding brackets in a new line.", + "parameters" : [ ] +}, { + "patternId" : "multiple_closures_with_trailing_closure", + "title" : "Multiple Closures with Trailing Closure", + "description" : "Trailing closure syntax should not be used when passing more than one closure argument.", + "parameters" : [ ] +}, { + "patternId" : "nesting", + "title" : "Nesting", + "description" : "Types should be nested at most 1 level deep, and statements should be nested at most 5 levels deep.", + "parameters" : [ ] +}, { + "patternId" : "nimble_operator", + "title" : "Nimble Operator", + "description" : "Prefer Nimble operator overloads over free matcher functions.", + "parameters" : [ ] +}, { + "patternId" : "no_extension_access_modifier", + "title" : "No Extension Access Modifier", + "description" : "Prefer not to use extension access modifiers", + "parameters" : [ ] +}, { + "patternId" : "no_fallthrough_only", + "title" : "No Fallthrough Only", + "description" : "Fallthroughs can only be used if the `case` contains at least one other statement.", + "parameters" : [ ] +}, { + "patternId" : "no_grouping_extension", + "title" : "No Grouping Extension", + "description" : "Extensions shouldn't be used to group code within the same source file.", + "parameters" : [ ] +}, { + "patternId" : "no_space_in_method_call", + "title" : "No Space in Method Call", + "description" : "Don't add a space between the method name and the parentheses.", + "parameters" : [ ] +}, { + "patternId" : "notification_center_detachment", + "title" : "Notification Center Detachment", + "description" : "An object should only remove itself as an observer in `deinit`.", + "parameters" : [ ] +}, { + "patternId" : "nslocalizedstring_key", + "title" : "NSLocalizedString Key", + "description" : "Static strings should be used as key in NSLocalizedString in order to genstrings work.", + "parameters" : [ ] +}, { + "patternId" : "nslocalizedstring_require_bundle", + "title" : "NSLocalizedString Require Bundle", + "description" : "Calls to NSLocalizedString should specify the bundle which contains the strings file.", + "parameters" : [ ] +}, { + "patternId" : "nsobject_prefer_isequal", + "title" : "NSObject Prefer isEqual", + "description" : "NSObject subclasses should implement isEqual instead of ==.", + "parameters" : [ ] +}, { + "patternId" : "number_separator", + "title" : "Number Separator", + "description" : "Underscores should be used as thousand separator in large decimal numbers.", + "parameters" : [ ] +}, { + "patternId" : "object_literal", + "title" : "Object Literal", + "description" : "Prefer object literals over image and color inits.", + "parameters" : [ ] +}, { + "patternId" : "opening_brace", + "title" : "Opening Brace Spacing", + "description" : "Opening braces should be preceded by a single space and on the same line as the declaration.", + "parameters" : [ ] +}, { + "patternId" : "operator_usage_whitespace", + "title" : "Operator Usage Whitespace", + "description" : "Operators should be surrounded by a single whitespace when they are being used.", + "parameters" : [ ] +}, { + "patternId" : "operator_whitespace", + "title" : "Operator Function Whitespace", + "description" : "Operators should be surrounded by a single whitespace when defining them.", + "parameters" : [ ] +}, { + "patternId" : "optional_enum_case_matching", + "title" : "Optional Enum Case Match", + "description" : "Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above.", + "parameters" : [ ] +}, { + "patternId" : "orphaned_doc_comment", + "title" : "Orphaned Doc Comment", + "description" : "A doc comment should be attached to a declaration.", + "parameters" : [ ] +}, { + "patternId" : "overridden_super_call", + "title" : "Overridden methods call super", + "description" : "Some overridden methods should always call super", + "parameters" : [ ] +}, { + "patternId" : "override_in_extension", + "title" : "Override in Extension", + "description" : "Extensions shouldn't override declarations.", + "parameters" : [ ] +}, { + "patternId" : "pattern_matching_keywords", + "title" : "Pattern Matching Keywords", + "description" : "Combine multiple pattern matching bindings by moving keywords out of tuples.", + "parameters" : [ ] +}, { + "patternId" : "prefer_self_type_over_type_of_self", + "title" : "Prefer Self Type Over Type of Self", + "description" : "Prefer `Self` over `type(of: self)` when accessing properties or calling methods.", + "parameters" : [ ] +}, { + "patternId" : "prefer_zero_over_explicit_init", + "title" : "Prefer Zero Over Explicit Init", + "description" : "Prefer `.zero` over explicit init with zero parameters (e.g. `CGPoint(x: 0, y: 0)`)", + "parameters" : [ ] +}, { + "patternId" : "prefixed_toplevel_constant", + "title" : "Prefixed Top-Level Constant", + "description" : "Top-level constants should be prefixed by `k`.", + "parameters" : [ ] +}, { + "patternId" : "private_action", + "title" : "Private Actions", + "description" : "IBActions should be private.", + "parameters" : [ ] +}, { + "patternId" : "private_outlet", + "title" : "Private Outlets", + "description" : "IBOutlets should be private to avoid leaking UIKit to higher layers.", + "parameters" : [ ] +}, { + "patternId" : "private_over_fileprivate", + "title" : "Private over fileprivate", + "description" : "Prefer `private` over `fileprivate` declarations.", + "parameters" : [ ] +}, { + "patternId" : "private_unit_test", + "title" : "Private Unit Test", + "description" : "Unit tests marked private are silently skipped.", + "parameters" : [ ] +}, { + "patternId" : "prohibited_interface_builder", + "title" : "Prohibited Interface Builder", + "description" : "Creating views using Interface Builder should be avoided.", + "parameters" : [ ] +}, { + "patternId" : "prohibited_super_call", + "title" : "Prohibited calls to super", + "description" : "Some methods should not call super", + "parameters" : [ ] +}, { + "patternId" : "protocol_property_accessors_order", + "title" : "Protocol Property Accessors Order", + "description" : "When declaring properties in protocols, the order of accessors should be `get set`.", + "parameters" : [ ] +}, { + "patternId" : "quick_discouraged_call", + "title" : "Quick Discouraged Call", + "description" : "Discouraged call inside 'describe' and/or 'context' block.", + "parameters" : [ ] +}, { + "patternId" : "quick_discouraged_focused_test", + "title" : "Quick Discouraged Focused Test", + "description" : "Discouraged focused test. Other tests won't run while this one is focused.", + "parameters" : [ ] +}, { + "patternId" : "quick_discouraged_pending_test", + "title" : "Quick Discouraged Pending Test", + "description" : "Discouraged pending test. This test won't run while it's marked as pending.", + "parameters" : [ ] +}, { + "patternId" : "raw_value_for_camel_cased_codable_enum", + "title" : "Raw Value For Camel Cased Codable Enum", + "description" : "Camel cased cases of Codable String enums should have raw value.", + "parameters" : [ ] +}, { + "patternId" : "reduce_boolean", + "title" : "Reduce Boolean", + "description" : "Prefer using `.allSatisfy()` or `.contains()` over `reduce(true)` or `reduce(false)`", + "parameters" : [ ] +}, { + "patternId" : "reduce_into", + "title" : "Reduce Into", + "description" : "Prefer `reduce(into:_:)` over `reduce(_:_:)` for copy-on-write types", + "parameters" : [ ] +}, { + "patternId" : "redundant_discardable_let", + "title" : "Redundant Discardable Let", + "description" : "Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function.", + "parameters" : [ ] +}, { + "patternId" : "redundant_nil_coalescing", + "title" : "Redundant Nil Coalescing", + "description" : "nil coalescing operator is only evaluated if the lhs is nil, coalescing operator with nil as rhs is redundant", + "parameters" : [ ] +}, { + "patternId" : "redundant_objc_attribute", + "title" : "Redundant @objc Attribute", + "description" : "Objective-C attribute (@objc) is redundant in declaration.", + "parameters" : [ ] +}, { + "patternId" : "redundant_optional_initialization", + "title" : "Redundant Optional Initialization", + "description" : "Initializing an optional variable with nil is redundant.", + "parameters" : [ ] +}, { + "patternId" : "redundant_set_access_control", + "title" : "Redundant Set Access Control Rule", + "description" : "Property setter access level shouldn't be explicit if it's the same as the variable access level.", + "parameters" : [ ] +}, { + "patternId" : "redundant_string_enum_value", + "title" : "Redundant String Enum Value", + "description" : "String enum values can be omitted when they are equal to the enumcase name.", + "parameters" : [ ] +}, { + "patternId" : "redundant_type_annotation", + "title" : "Redundant Type Annotation", + "description" : "Variables should not have redundant type annotation", + "parameters" : [ ] +}, { + "patternId" : "redundant_void_return", + "title" : "Redundant Void Return", + "description" : "Returning Void in a function declaration is redundant.", + "parameters" : [ ] +}, { + "patternId" : "required_deinit", + "title" : "Required Deinit", + "description" : "Classes should have an explicit deinit method.", + "parameters" : [ ] +}, { + "patternId" : "required_enum_case", + "title" : "Required Enum Case", + "description" : "Enums conforming to a specified protocol must implement a specific case(s).", + "parameters" : [ ] +}, { + "patternId" : "return_arrow_whitespace", + "title" : "Returning Whitespace", + "description" : "Return arrow and return type should be separated by a single space or on a separate line.", + "parameters" : [ ] +}, { + "patternId" : "shorthand_operator", + "title" : "Shorthand Operator", + "description" : "Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning.", + "parameters" : [ ] +}, { + "patternId" : "single_test_class", + "title" : "Single Test Class", + "description" : "Test files should contain a single QuickSpec or XCTestCase class.", + "parameters" : [ ] +}, { + "patternId" : "sorted_first_last", + "title" : "Min or Max over Sorted First or Last", + "description" : "Prefer using `min()` or `max()` over `sorted().first` or `sorted().last`", + "parameters" : [ ] +}, { + "patternId" : "sorted_imports", + "title" : "Sorted Imports", + "description" : "Imports should be sorted.", + "parameters" : [ ] +}, { + "patternId" : "statement_position", + "title" : "Statement Position", + "description" : "Else and catch should be on the same line, one space after the previous declaration.", + "parameters" : [ ] +}, { + "patternId" : "static_operator", + "title" : "Static Operator", + "description" : "Operators should be declared as static functions, not free functions.", + "parameters" : [ ] +}, { + "patternId" : "strict_fileprivate", + "title" : "Strict fileprivate", + "description" : "`fileprivate` should be avoided.", + "parameters" : [ ] +}, { + "patternId" : "strong_iboutlet", + "title" : "Strong IBOutlet", + "description" : "@IBOutlets shouldn't be declared as weak.", + "parameters" : [ ] +}, { + "patternId" : "superfluous_disable_command", + "title" : "Superfluous Disable Command", + "description" : "SwiftLint 'disable' commands are superfluous when the disabled rule would not have triggered a violation in the disabled region. Use \" - \" if you wish to document a command.", + "parameters" : [ ] +}, { + "patternId" : "switch_case_alignment", + "title" : "Switch and Case Statement Alignment", + "description" : "Case statements should vertically align with their enclosing switch statement, or indented if configured otherwise.", + "parameters" : [ ] +}, { + "patternId" : "switch_case_on_newline", + "title" : "Switch Case on Newline", + "description" : "Cases inside a switch should always be on a newline", + "parameters" : [ ] +}, { + "patternId" : "syntactic_sugar", + "title" : "Syntactic Sugar", + "description" : "Shorthand syntactic sugar should be used, i.e. [Int] instead of Array.", + "parameters" : [ ] +}, { + "patternId" : "todo", + "title" : "Todo", + "description" : "TODOs and FIXMEs should be resolved.", + "parameters" : [ ] +}, { + "patternId" : "toggle_bool", + "title" : "Toggle Bool", + "description" : "Prefer `someBool.toggle()` over `someBool = !someBool`.", + "parameters" : [ ] +}, { + "patternId" : "trailing_closure", + "title" : "Trailing Closure", + "description" : "Trailing closure syntax should be used whenever possible.", + "parameters" : [ ] +}, { + "patternId" : "trailing_comma", + "title" : "Trailing Comma", + "description" : "Trailing commas in arrays and dictionaries should be avoided/enforced.", + "parameters" : [ ] +}, { + "patternId" : "trailing_newline", + "title" : "Trailing Newline", + "description" : "Files should have a single trailing newline.", + "parameters" : [ ] +}, { + "patternId" : "trailing_semicolon", + "title" : "Trailing Semicolon", + "description" : "Lines should not have trailing semicolons.", + "parameters" : [ ] +}, { + "patternId" : "trailing_whitespace", + "title" : "Trailing Whitespace", + "description" : "Lines should not have trailing whitespace.", + "parameters" : [ ] +}, { + "patternId" : "type_body_length", + "title" : "Type Body Length", + "description" : "Type bodies should not span too many lines.", + "parameters" : [ ] +}, { + "patternId" : "type_contents_order", + "title" : "Type Contents Order", + "description" : "Specifies the order of subtypes, properties, methods & more within a type.", + "parameters" : [ ] +}, { + "patternId" : "type_name", + "title" : "Type Name", + "description" : "Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 40 characters in length.", + "parameters" : [ ] +}, { + "patternId" : "unavailable_function", + "title" : "Unavailable Function", + "description" : "Unimplemented functions should be marked as unavailable.", + "parameters" : [ ] +}, { + "patternId" : "unneeded_break_in_switch", + "title" : "Unneeded Break in Switch", + "description" : "Avoid using unneeded break statements.", + "parameters" : [ ] +}, { + "patternId" : "unneeded_notification_center_removal", + "title" : "Unneeded NotificationCenter Removal", + "description" : "Observers are automatically unregistered on dealloc (iOS 9 / macOS 10.11) so you should't call `removeObserver(self)` in the deinit.", + "parameters" : [ ] +}, { + "patternId" : "unneeded_parentheses_in_closure_argument", + "title" : "Unneeded Parentheses in Closure Argument", + "description" : "Parentheses are not needed when declaring closure arguments.", + "parameters" : [ ] +}, { + "patternId" : "unowned_variable_capture", + "title" : "Unowned Variable Capture", + "description" : "Prefer capturing references as weak to avoid potential crashes.", + "parameters" : [ ] +}, { + "patternId" : "untyped_error_in_catch", + "title" : "Untyped Error in Catch", + "description" : "Catch statements should not declare error variables without type casting.", + "parameters" : [ ] +}, { + "patternId" : "unused_capture_list", + "title" : "Unused Capture List", + "description" : "Unused reference in a capture list should be removed.", + "parameters" : [ ] +}, { + "patternId" : "unused_closure_parameter", + "title" : "Unused Closure Parameter", + "description" : "Unused parameter in a closure should be replaced with _.", + "parameters" : [ ] +}, { + "patternId" : "unused_control_flow_label", + "title" : "Unused Control Flow Label", + "description" : "Unused control flow label should be removed.", + "parameters" : [ ] +}, { + "patternId" : "unused_declaration", + "title" : "Unused Declaration", + "description" : "Declarations should be referenced at least once within all files linted.", + "parameters" : [ ] +}, { + "patternId" : "unused_enumerated", + "title" : "Unused Enumerated", + "description" : "When the index or the item is not used, `.enumerated()` can be removed.", + "parameters" : [ ] +}, { + "patternId" : "unused_import", + "title" : "Unused Import", + "description" : "All imported modules should be required to make the file compile.", + "parameters" : [ ] +}, { + "patternId" : "unused_optional_binding", + "title" : "Unused Optional Binding", + "description" : "Prefer `!= nil` over `let _ =`", + "parameters" : [ ] +}, { + "patternId" : "unused_setter_value", + "title" : "Unused Setter Value", + "description" : "Setter value is not used.", + "parameters" : [ ] +}, { + "patternId" : "valid_ibinspectable", + "title" : "Valid IBInspectable", + "description" : "@IBInspectable should be applied to variables only, have its type explicit and be of a supported type", + "parameters" : [ ] +}, { + "patternId" : "vertical_parameter_alignment", + "title" : "Vertical Parameter Alignment", + "description" : "Function parameters should be aligned vertically if they're in multiple lines in a declaration.", + "parameters" : [ ] +}, { + "patternId" : "vertical_parameter_alignment_on_call", + "title" : "Vertical Parameter Alignment On Call", + "description" : "Function parameters should be aligned vertically if they're in multiple lines in a method call.", + "parameters" : [ ] +}, { + "patternId" : "vertical_whitespace", + "title" : "Vertical Whitespace", + "description" : "Limit vertical whitespace to a single empty line.", + "parameters" : [ ] +}, { + "patternId" : "vertical_whitespace_between_cases", + "title" : "Vertical Whitespace Between Cases", + "description" : "Include a single empty line between switch cases.", + "parameters" : [ ] +}, { + "patternId" : "vertical_whitespace_closing_braces", + "title" : "Vertical Whitespace before Closing Braces", + "description" : "Don't include vertical whitespace (empty line) before closing braces.", + "parameters" : [ ] +}, { + "patternId" : "vertical_whitespace_opening_braces", + "title" : "Vertical Whitespace after Opening Braces", + "description" : "Don't include vertical whitespace (empty line) after opening braces.", + "parameters" : [ ] +}, { + "patternId" : "void_return", + "title" : "Void Return", + "description" : "Prefer `-> Void` over `-> ()`.", + "parameters" : [ ] +}, { + "patternId" : "weak_delegate", + "title" : "Weak Delegate", + "description" : "Delegates should be weak to avoid reference cycles.", + "parameters" : [ ] +}, { + "patternId" : "xct_specific_matcher", + "title" : "XCTest Specific Matcher", + "description" : "Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual`", + "parameters" : [ ] +}, { + "patternId" : "xctfail_message", + "title" : "XCTFail Message", + "description" : "An XCTFail call should include a description of the assertion.", + "parameters" : [ ] +}, { + "patternId" : "yoda_condition", + "title" : "Yoda condition rule", + "description" : "The variable should be placed on the left, the constant on the right of a comparison operator.", + "parameters" : [ ] +} ] diff --git a/docs/description/empty_enum_arguments.md b/docs/description/empty_enum_arguments.md index d2c1034..df8cf3e 100644 --- a/docs/description/empty_enum_arguments.md +++ b/docs/description/empty_enum_arguments.md @@ -60,6 +60,16 @@ default: break } ``` +```swift +if case .bar = foo { +} +``` + +```swift +guard case .bar = foo else { +} +``` + ## Triggering Examples ```swift @@ -93,4 +103,14 @@ func example(foo: Foo) { break } } +``` + +```swift +if case .bar↓(_) = foo { +} +``` + +```swift +guard case .bar↓(_) = foo else { +} ``` \ No newline at end of file diff --git a/docs/description/explicit_acl.md b/docs/description/explicit_acl.md index 1ae7aa3..99c00ad 100644 --- a/docs/description/explicit_acl.md +++ b/docs/description/explicit_acl.md @@ -85,25 +85,59 @@ extension A: Equatable {} extension A {} ``` +```swift +extension Foo { + internal func bar() {} +} +``` + +```swift +internal enum Foo { + case bar +} +``` + +```swift +extension Foo { + public var isValid: Bool { + let result = true + return result + } +} +``` + +```swift +extension Foo { + private var isValid: Bool { + get { + return true + } + set(newValue) { + print(newValue) + } + } +} +``` + ## Triggering Examples ```swift -enum A {} +↓enum A {} ``` ```swift -final class B {} +final ↓class B {} ``` ```swift -internal struct C { let d = 5 } +internal struct C { ↓let d = 5 } ``` ```swift -public struct C { let d = 5 } +public struct C { ↓let d = 5 } ``` @@ -114,6 +148,12 @@ func a() {} ```swift internal let a = 0 -func b() {} +↓func b() {} + +``` +```swift +extension Foo { + ↓func bar() {} +} ``` \ No newline at end of file diff --git a/docs/description/extension_access_modifier.md b/docs/description/extension_access_modifier.md index 44e3907..4ce8ccb 100644 --- a/docs/description/extension_access_modifier.md +++ b/docs/description/extension_access_modifier.md @@ -60,6 +60,13 @@ extension Foo { } ``` +```swift +extension Foo { + func setup() {} + public func update() {} +} +``` + ## Triggering Examples ```swift @@ -81,4 +88,15 @@ public extension Foo { public ↓func bar() {} public ↓func baz() {} } +``` + +```swift +↓extension Foo { + public var bar: Int { + let value = 1 + return value + } + + public var baz: Int { return 1 } +} ``` \ No newline at end of file diff --git a/docs/description/file_types_order.md b/docs/description/file_types_order.md index 634056b..50c8f20 100644 --- a/docs/description/file_types_order.md +++ b/docs/description/file_types_order.md @@ -8,7 +8,7 @@ Specifies how the types within a file should be ordered. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning, order: [[SwiftLintFramework.FileType.supportingType], [SwiftLintFramework.FileType.mainType], [SwiftLintFramework.FileType.extension]] +* **Default configuration:** warning, order: [[SwiftLintFramework.FileType.supportingType], [SwiftLintFramework.FileType.mainType], [SwiftLintFramework.FileType.extension], [SwiftLintFramework.FileType.previewProvider]] ## Non Triggering Examples @@ -71,18 +71,10 @@ class TestViewController: UIViewController { // Life-Cycle Methods override func viewDidLoad() { super.viewDidLoad() - - view1.setNeedsLayout() - view1.layoutIfNeeded() - hasLayoutedView1 = true } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() - - view2.setNeedsLayout() - view2.layoutIfNeeded() - hasLayoutedView2 = true } // IBActions @@ -125,10 +117,6 @@ extension TestViewController: UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 1 } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - return UITableViewCell() - } } ``` @@ -139,6 +127,18 @@ extension Bar { } ``` +```swift +struct ContentView: View { + var body: some View { + Text("Hello, World!") + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { ContentView() } +} +``` + ## Triggering Examples ```swift @@ -156,10 +156,6 @@ protocol TestViewControllerDelegate { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 1 } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - return UITableViewCell() - } } class TestViewController: UIViewController {} @@ -190,10 +186,6 @@ protocol TestViewControllerDelegate { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 1 } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - return UITableViewCell() - } } class TestViewController: UIViewController {} @@ -203,9 +195,13 @@ extension TestViewController: UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 1 } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - return UITableViewCell() - } } +``` + +```swift +// Preview Provider +↓struct ContentView_Previews: PreviewProvider {} + +// Main Type +struct ContentView: View {} ``` \ No newline at end of file diff --git a/docs/description/ibinspectable_in_extension.md b/docs/description/ibinspectable_in_extension.md new file mode 100644 index 0000000..2ee7c66 --- /dev/null +++ b/docs/description/ibinspectable_in_extension.md @@ -0,0 +1,27 @@ +# IBInspectable in Extension + +Extensions shouldn't add @IBInspectable properties. + +* **Identifier:** ibinspectable_in_extension +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class Foo { + @IBInspectable private var x: Int +} +``` + +## Triggering Examples + +```swift +extension Foo { + @IBInspectable private var x: Int +} +``` \ No newline at end of file diff --git a/docs/description/implicit_return.md b/docs/description/implicit_return.md index 91a1076..f31ca38 100644 --- a/docs/description/implicit_return.md +++ b/docs/description/implicit_return.md @@ -8,7 +8,7 @@ Prefer implicit returns in closures, functions and getters. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning, included: [closure, function, getter] +* **Default configuration:** warning, included: [function, closure, getter] ## Non Triggering Examples diff --git a/docs/description/multiline_arguments_brackets.md b/docs/description/multiline_arguments_brackets.md index c7fe99a..00a54bf 100644 --- a/docs/description/multiline_arguments_brackets.md +++ b/docs/description/multiline_arguments_brackets.md @@ -51,6 +51,33 @@ AlertViewModel.AlertAction(title: "some title", style: .default) { } ``` +```swift +public final class Logger { + public static let shared = Logger(outputs: [ + OSLoggerOutput(), + ErrorLoggerOutput() + ]) +} +``` + +```swift +let errors = try self.download([ + (description: description, priority: priority), +]) +``` + +```swift +return SignalProducer({ observer, _ in + observer.sendCompleted() +}).onMainQueue() +``` + +```swift +SomeType(a: [ + 1, 2, 3 +], b: [1, 2]) +``` + ## Triggering Examples ```swift @@ -80,4 +107,11 @@ foo( x: 5, y: 7 )↓) +``` + +```swift +SomeOtherType(↓a: [ + 1, 2, 3 + ], + b: "two"↓) ``` \ No newline at end of file diff --git a/docs/description/multiline_parameters_brackets.md b/docs/description/multiline_parameters_brackets.md index eedf87a..f6dd1e5 100644 --- a/docs/description/multiline_parameters_brackets.md +++ b/docs/description/multiline_parameters_brackets.md @@ -58,6 +58,12 @@ class SomeType { func foo(param1: T, param2: String, param3: String) -> T { /* some code */ } ``` +```swift + func foo(a: [Int] = [ + 1 + ]) +``` + ## Triggering Examples ```swift diff --git a/docs/description/no_space_in_method_call.md b/docs/description/no_space_in_method_call.md index cef56d4..77a36cc 100644 --- a/docs/description/no_space_in_method_call.md +++ b/docs/description/no_space_in_method_call.md @@ -64,4 +64,8 @@ object.foo↓ () {} ```swift object.foo↓ () +``` + +```swift +object.foo↓ (value: 1) { x in print(x) } ``` \ No newline at end of file diff --git a/docs/description/opening_brace.md b/docs/description/opening_brace.md index 4ca1b08..53ae631 100644 --- a/docs/description/opening_brace.md +++ b/docs/description/opening_brace.md @@ -77,10 +77,25 @@ struct Parent { ```swift func f(rect: CGRect) { - { - let centre = CGPoint(x: rect.midX, y: rect.midY) - print(centre) - }() + { + let centre = CGPoint(x: rect.midX, y: rect.midY) + print(centre) + }() +} +``` + +```swift +func f(rect: CGRect) -> () -> Void { + { + let centre = CGPoint(x: rect.midX, y: rect.midY) + print(centre) + } +} +``` + +```swift +func f() -> () -> Void { + {} } ``` diff --git a/docs/description/prefer_zero_over_explicit_init.md b/docs/description/prefer_zero_over_explicit_init.md new file mode 100644 index 0000000..088377d --- /dev/null +++ b/docs/description/prefer_zero_over_explicit_init.md @@ -0,0 +1,55 @@ +# Prefer Zero Over Explicit Init + +Prefer `.zero` over explicit init with zero parameters (e.g. `CGPoint(x: 0, y: 0)`) + +* **Identifier:** prefer_zero_over_explicit_init +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +CGRect(x: 0, y: 0, width: 0, height: 1) +``` + +```swift +CGPoint(x: 0, y: -1 +``` + +```swift +CGSize(width: 2, height: 4) +``` + +```swift +CGVector(dx: -5, dy: 0) +``` + +## Triggering Examples + +```swift +↓CGPoint(x: 0, y: 0) +``` + +```swift +↓CGPoint(x: 0.000000, y: 0) +``` + +```swift +↓CGPoint(x: 0.000000, y: 0.000) +``` + +```swift +↓CGRect(x: 0, y: 0, width: 0, height: 0) +``` + +```swift +↓CGSize(width: 0, height: 0) +``` + +```swift +↓CGVector(dx: 0, dy: 0) +``` \ No newline at end of file diff --git a/docs/description/raw_value_for_camel_cased_codable_enum.md b/docs/description/raw_value_for_camel_cased_codable_enum.md index b891ee2..e3fb554 100644 --- a/docs/description/raw_value_for_camel_cased_codable_enum.md +++ b/docs/description/raw_value_for_camel_cased_codable_enum.md @@ -40,6 +40,19 @@ enum Numbers: String, Codable { } ``` +```swift +enum Status: String, Codable { + case OK, ACCEPTABLE +} +``` + +```swift +enum Status: String, Codable { + case ok + case maybeAcceptable = "maybe_acceptable" +} +``` + ```swift enum Status: String { case ok diff --git a/docs/description/switch_case_on_newline.md b/docs/description/switch_case_on_newline.md index 8865551..6745ec7 100644 --- a/docs/description/switch_case_on_newline.md +++ b/docs/description/switch_case_on_newline.md @@ -118,6 +118,13 @@ switch foo { } ``` +```swift +do { + let loadedToken = try tokenManager.decodeToken(from: response) + return loadedToken +} catch { throw error } +``` + ## Triggering Examples ```swift diff --git a/docs/description/unneeded_notification_center_removal.md b/docs/description/unneeded_notification_center_removal.md new file mode 100644 index 0000000..f295895 --- /dev/null +++ b/docs/description/unneeded_notification_center_removal.md @@ -0,0 +1,56 @@ +# Unneeded NotificationCenter Removal + +Observers are automatically unregistered on dealloc (iOS 9 / macOS 10.11) so you should't call `removeObserver(self)` in the deinit. + +* **Identifier:** unneeded_notification_center_removal +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class Example { + deinit { + NotificationCenter.default.removeObserver(someOtherObserver) + } +} +``` + +```swift +class Example { + func removeObservers() { + NotificationCenter.default.removeObserver(self) + } +} +``` + +```swift +class Example { + deinit { + cleanup() + } +} +``` + +## Triggering Examples + +```swift +class Foo { + deinit { + NotificationCenter.default.removeObserver(↓self) + } +} +``` + +```swift +class Foo { + deinit { + NotificationCenter.default.removeObserver(↓self, + name: UITextView.textDidChangeNotification, object: nil) + } +} +``` \ No newline at end of file diff --git a/docs/patterns.json b/docs/patterns.json index dc3b604..b52a399 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -1,1152 +1,1370 @@ { - "name": "swiftlint", - "version": "0.39.2", - "patterns": [ - { - "patternId": "anyobject_protocol", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "array_init", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "attributes", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "block_based_kvo", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "class_delegate_protocol", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "closing_brace", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "closure_body_length", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "closure_end_indentation", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "closure_parameter_position", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "closure_spacing", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "collection_alignment", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "colon", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "comma", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "compiler_protocol_init", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "conditional_returns_on_newline", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "contains_over_filter_count", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "contains_over_filter_is_empty", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "contains_over_first_not_nil", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "contains_over_range_nil_comparison", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "control_statement", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "convenience_type", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "custom_rules", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "cyclomatic_complexity", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "deployment_target", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "discarded_notification_center_observer", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "discouraged_direct_init", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "discouraged_object_literal", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "discouraged_optional_boolean", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "discouraged_optional_collection", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "duplicate_enum_cases", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "duplicate_imports", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "dynamic_inline", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "empty_collection_literal", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "empty_count", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "empty_enum_arguments", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "empty_parameters", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "empty_parentheses_with_trailing_closure", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "empty_string", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "empty_xctest_method", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "enum_case_associated_values_count", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "expiring_todo", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "explicit_acl", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "explicit_enum_raw_value", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "explicit_init", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "explicit_self", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "explicit_top_level_acl", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "explicit_type_interface", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "extension_access_modifier", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "fallthrough", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "fatal_error_message", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "file_header", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "file_length", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "file_name", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "file_name_no_space", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "file_types_order", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "first_where", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "flatmap_over_map_reduce", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "for_where", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "force_cast", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "force_try", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "force_unwrapping", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "function_body_length", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "function_default_parameter_at_end", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "function_parameter_count", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "generic_type_name", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "identical_operands", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "identifier_name", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "implicit_getter", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "implicit_return", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "implicitly_unwrapped_optional", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "indentation_width", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "inert_defer", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "is_disjoint", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "joined_default_parameter", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "large_tuple", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "last_where", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "leading_whitespace", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "legacy_cggeometry_functions", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "legacy_constant", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "legacy_constructor", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "legacy_hashing", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "legacy_multiple", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "legacy_nsgeometry_functions", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "legacy_random", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "let_var_whitespace", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "line_length", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "literal_expression_end_indentation", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "lower_acl_than_parent", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "mark", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "missing_docs", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "modifier_order", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "multiline_arguments", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "multiline_arguments_brackets", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "multiline_function_chains", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "multiline_literal_brackets", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "multiline_parameters", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "multiline_parameters_brackets", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "multiple_closures_with_trailing_closure", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "nesting", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "nimble_operator", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "no_extension_access_modifier", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "no_fallthrough_only", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "no_grouping_extension", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "no_space_in_method_call", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "notification_center_detachment", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "nslocalizedstring_key", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "nslocalizedstring_require_bundle", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "nsobject_prefer_isequal", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "number_separator", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "object_literal", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "opening_brace", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "operator_usage_whitespace", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "operator_whitespace", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "optional_enum_case_matching", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "orphaned_doc_comment", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "overridden_super_call", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "override_in_extension", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "pattern_matching_keywords", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "prefer_self_type_over_type_of_self", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "prefixed_toplevel_constant", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "private_action", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "private_outlet", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "private_over_fileprivate", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "private_unit_test", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "prohibited_interface_builder", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "prohibited_super_call", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "protocol_property_accessors_order", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "quick_discouraged_call", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "quick_discouraged_focused_test", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "quick_discouraged_pending_test", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "raw_value_for_camel_cased_codable_enum", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "reduce_boolean", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "reduce_into", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "redundant_discardable_let", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "redundant_nil_coalescing", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "redundant_objc_attribute", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "redundant_optional_initialization", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "redundant_set_access_control", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "redundant_string_enum_value", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "redundant_type_annotation", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "redundant_void_return", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "required_deinit", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "required_enum_case", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "return_arrow_whitespace", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "shorthand_operator", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "single_test_class", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "sorted_first_last", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "sorted_imports", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "statement_position", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "static_operator", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "strict_fileprivate", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "strong_iboutlet", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "superfluous_disable_command", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "switch_case_alignment", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "switch_case_on_newline", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "syntactic_sugar", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "todo", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "toggle_bool", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "trailing_closure", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "trailing_comma", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "trailing_newline", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "trailing_semicolon", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "trailing_whitespace", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "type_body_length", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "type_contents_order", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "type_name", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "unavailable_function", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "unneeded_break_in_switch", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "unneeded_parentheses_in_closure_argument", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "unowned_variable_capture", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "untyped_error_in_catch", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "unused_capture_list", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "unused_closure_parameter", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "unused_control_flow_label", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "unused_declaration", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "unused_enumerated", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "unused_import", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "unused_optional_binding", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "unused_setter_value", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "valid_ibinspectable", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "vertical_parameter_alignment", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "vertical_parameter_alignment_on_call", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "vertical_whitespace", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "vertical_whitespace_between_cases", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "vertical_whitespace_closing_braces", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "vertical_whitespace_opening_braces", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "void_return", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "weak_delegate", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "xct_specific_matcher", - "level": "Info", - "category": "CodeStyle", - "enabled": false - }, - { - "patternId": "xctfail_message", - "level": "Info", - "category": "CodeStyle", - "enabled": true - }, - { - "patternId": "yoda_condition", - "level": "Info", - "category": "CodeStyle", - "enabled": false - } - ] + "name" : "swiftlint", + "version" : "0.40.0", + "patterns" : [ { + "patternId" : "anyobject_protocol", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "array_init", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "attributes", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "block_based_kvo", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "class_delegate_protocol", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "closing_brace", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "closure_body_length", + "level" : "Info", + "category" : "Complexity", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "closure_end_indentation", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "closure_parameter_position", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "closure_spacing", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "collection_alignment", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "colon", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "comma", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "compiler_protocol_init", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "computed_accessors_order", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "conditional_returns_on_newline", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "contains_over_filter_count", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "contains_over_filter_is_empty", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "contains_over_first_not_nil", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "contains_over_range_nil_comparison", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "control_statement", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "convenience_type", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "custom_rules", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "cyclomatic_complexity", + "level" : "Info", + "category" : "Complexity", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "deployment_target", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "discarded_notification_center_observer", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "discouraged_direct_init", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "discouraged_object_literal", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "discouraged_optional_boolean", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "discouraged_optional_collection", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "duplicate_enum_cases", + "level" : "Error", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "duplicate_imports", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "dynamic_inline", + "level" : "Error", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "empty_collection_literal", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "empty_count", + "level" : "Info", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "empty_enum_arguments", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "empty_parameters", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "empty_parentheses_with_trailing_closure", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "empty_string", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "empty_xctest_method", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "enum_case_associated_values_count", + "level" : "Info", + "category" : "Complexity", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "expiring_todo", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "explicit_acl", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "explicit_enum_raw_value", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "explicit_init", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "explicit_self", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "explicit_top_level_acl", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "explicit_type_interface", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "extension_access_modifier", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "fallthrough", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "fatal_error_message", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "file_header", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "file_length", + "level" : "Info", + "category" : "Complexity", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "file_name", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "file_name_no_space", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "file_types_order", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "first_where", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "flatmap_over_map_reduce", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "for_where", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "force_cast", + "level" : "Error", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "force_try", + "level" : "Error", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "force_unwrapping", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "function_body_length", + "level" : "Info", + "category" : "Complexity", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "function_default_parameter_at_end", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "function_parameter_count", + "level" : "Info", + "category" : "Complexity", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "generic_type_name", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "ibinspectable_in_extension", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "identical_operands", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "identifier_name", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "implicit_getter", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "implicit_return", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "implicitly_unwrapped_optional", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "indentation_width", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "inert_defer", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "is_disjoint", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "joined_default_parameter", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "large_tuple", + "level" : "Info", + "category" : "Complexity", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "last_where", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "leading_whitespace", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "legacy_cggeometry_functions", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "legacy_constant", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "legacy_constructor", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "legacy_hashing", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "legacy_multiple", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "legacy_nsgeometry_functions", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "legacy_random", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "let_var_whitespace", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "line_length", + "level" : "Info", + "category" : "Complexity", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "literal_expression_end_indentation", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "lower_acl_than_parent", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "mark", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "missing_docs", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "modifier_order", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "multiline_arguments", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "multiline_arguments_brackets", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "multiline_function_chains", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "multiline_literal_brackets", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "multiline_parameters", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "multiline_parameters_brackets", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "multiple_closures_with_trailing_closure", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "nesting", + "level" : "Info", + "category" : "Complexity", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "nimble_operator", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "no_extension_access_modifier", + "level" : "Error", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "no_fallthrough_only", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "no_grouping_extension", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "no_space_in_method_call", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "notification_center_detachment", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "nslocalizedstring_key", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "nslocalizedstring_require_bundle", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "nsobject_prefer_isequal", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "number_separator", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "object_literal", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "opening_brace", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "operator_usage_whitespace", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "operator_whitespace", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "optional_enum_case_matching", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "orphaned_doc_comment", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "overridden_super_call", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "override_in_extension", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "pattern_matching_keywords", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "prefer_self_type_over_type_of_self", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "prefer_zero_over_explicit_init", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "prefixed_toplevel_constant", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "private_action", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "private_outlet", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "private_over_fileprivate", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "private_unit_test", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "prohibited_interface_builder", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "prohibited_super_call", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "protocol_property_accessors_order", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "quick_discouraged_call", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "quick_discouraged_focused_test", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "quick_discouraged_pending_test", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "raw_value_for_camel_cased_codable_enum", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "reduce_boolean", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "reduce_into", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "redundant_discardable_let", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "redundant_nil_coalescing", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "redundant_objc_attribute", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "redundant_optional_initialization", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "redundant_set_access_control", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "redundant_string_enum_value", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "redundant_type_annotation", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "redundant_void_return", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "required_deinit", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "required_enum_case", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "return_arrow_whitespace", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "shorthand_operator", + "level" : "Error", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "single_test_class", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "sorted_first_last", + "level" : "Warning", + "category" : "Performance", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "sorted_imports", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "statement_position", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "static_operator", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "strict_fileprivate", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "strong_iboutlet", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "superfluous_disable_command", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "switch_case_alignment", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "switch_case_on_newline", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "syntactic_sugar", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "todo", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "toggle_bool", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "trailing_closure", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "trailing_comma", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "trailing_newline", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "trailing_semicolon", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "trailing_whitespace", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "type_body_length", + "level" : "Info", + "category" : "Complexity", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "type_contents_order", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "type_name", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "unavailable_function", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "unneeded_break_in_switch", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "unneeded_notification_center_removal", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "unneeded_parentheses_in_closure_argument", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "unowned_variable_capture", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "untyped_error_in_catch", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "unused_capture_list", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "unused_closure_parameter", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "unused_control_flow_label", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "unused_declaration", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "unused_enumerated", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "unused_import", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "unused_optional_binding", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "unused_setter_value", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "valid_ibinspectable", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "vertical_parameter_alignment", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "vertical_parameter_alignment_on_call", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "vertical_whitespace", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "vertical_whitespace_between_cases", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "vertical_whitespace_closing_braces", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "vertical_whitespace_opening_braces", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "void_return", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "weak_delegate", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "xct_specific_matcher", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "xctfail_message", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true + }, { + "patternId" : "yoda_condition", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + } ] } From 23d26c187fd0a4efe2989bb5c0f1257527ddf0ce Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 31 Mar 2021 11:37:02 +0200 Subject: [PATCH 044/119] test: Fix tests to align with the new severity levels --- docs/multiple-tests/filter-files/results.xml | 4 +- .../multiple-tests/multiple-files/results.xml | 14 +- .../use-codacy-conf/results.xml | 10 +- docs/multiple-tests/with-config/results.xml | 4 +- docs/tests/array_init.swift | 16 +- docs/tests/block_based_kvo.swift | 4 +- docs/tests/class_delegate_protocol.swift | 4 +- docs/tests/closing_brace.swift | 4 +- docs/tests/closure_end_indentation.swift | 6 +- docs/tests/closure_parameter_position.swift | 56 ------ docs/tests/closure_spacing.swift | 8 +- docs/tests/comma.swift | 10 +- docs/tests/compiler_protocol_init.swift | 4 +- docs/tests/contains_over_first_not_nil.swift | 12 +- docs/tests/control_statement.swift | 32 ++-- ...scarded_notification_center_observer.swift | 6 +- docs/tests/discouraged_optional_boolean.swift | 164 +++++++++--------- docs/tests/dynamic_inline.swift | 10 +- docs/tests/empty_enum_arguments.swift | 8 +- docs/tests/empty_parameters.swift | 8 +- ...ty_parentheses_with_trailing_closure.swift | 8 +- docs/tests/explicit_acl.swift | 12 +- docs/tests/explicit_enum_raw_value.swift | 10 +- docs/tests/explicit_init.swift | 4 +- docs/tests/explicit_top_level_acl.swift | 10 +- docs/tests/extension_access_modifier.swift | 8 +- docs/tests/fallthrough.swift | 2 +- docs/tests/fatal_error_message.swift | 4 +- docs/tests/first_where.swift | 12 +- docs/tests/for_where.swift | 2 +- docs/tests/force_cast.swift | 2 +- docs/tests/force_try.swift | 2 +- docs/tests/force_unwrapping.swift | 26 +-- docs/tests/implicit_getter.swift | 10 +- docs/tests/is_disjoint.swift | 4 +- docs/tests/joined_default_parameter.swift | 4 +- docs/tests/legacy_cggeometry_functions.swift | 40 ++--- docs/tests/legacy_constant.swift | 20 +-- docs/tests/legacy_constructor.swift | 40 ++--- docs/tests/legacy_nsgeometry_functions.swift | 42 ++--- docs/tests/let_var_whitespace.swift | 12 +- .../literal_expression_end_indentation.swift | 6 +- docs/tests/mark.swift | 40 ++--- docs/tests/multiline_parameters.swift | 38 ++-- ...tiple_closures_with_trailing_closure.swift | 4 +- docs/tests/nimble_operator.swift | 18 +- docs/tests/no_extension_access_modifier.swift | 10 +- docs/tests/no_grouping_extension.swift | 8 +- .../notification_center_detachment.swift | 2 +- docs/tests/opening_brace.swift | 28 +-- docs/tests/operator_usage_whitespace.swift | 30 ++-- docs/tests/operator_whitespace.swift | 12 +- docs/tests/override_in_extension.swift | 4 +- docs/tests/pattern_matching_keywords.swift | 12 +- docs/tests/private_action.swift | 22 +-- .../protocol_property_accessors_order.swift | 2 +- docs/tests/quick_discouraged_call.swift | 30 ++-- .../quick_discouraged_focused_test.swift | 14 +- .../quick_discouraged_pending_test.swift | 81 --------- docs/tests/redundant_discardable_let.swift | 4 +- docs/tests/redundant_nil_coalescing.swift | 4 +- .../redundant_optional_initialization.swift | 8 +- docs/tests/redundant_string_enum_value.swift | 8 +- docs/tests/redundant_void_return.swift | 8 +- docs/tests/return_arrow_whitespace.swift | 16 +- docs/tests/shorthand_operator.swift | 44 ++--- docs/tests/single_test_class.swift | 28 +-- docs/tests/sorted_first_last.swift | 26 +-- docs/tests/sorted_imports.swift | 2 +- docs/tests/strict_fileprivate.swift | 14 +- docs/tests/switch_case_on_newline.swift | 18 +- docs/tests/syntactic_sugar.swift | 20 +-- docs/tests/todo.swift | 16 +- docs/tests/trailing_semicolon.swift | 10 +- docs/tests/unneeded_break_in_switch.swift | 8 +- ...eded_parentheses_in_closure_argument.swift | 10 +- docs/tests/unused_closure_parameter.swift | 16 +- docs/tests/unused_enumerated.swift | 8 +- docs/tests/valid_ibinspectable.swift | 18 +- docs/tests/vertical_parameter_alignment.swift | 8 +- ...vertical_parameter_alignment_on_call.swift | 14 +- docs/tests/void_return.swift | 14 +- docs/tests/weak_delegate.swift | 4 +- docs/tests/xctfail_message.swift | 4 +- docs/tests/yoda_condition.swift | 14 +- 85 files changed, 613 insertions(+), 750 deletions(-) delete mode 100644 docs/tests/closure_parameter_position.swift delete mode 100644 docs/tests/quick_discouraged_pending_test.swift diff --git a/docs/multiple-tests/filter-files/results.xml b/docs/multiple-tests/filter-files/results.xml index a764c92..d1f4700 100644 --- a/docs/multiple-tests/filter-files/results.xml +++ b/docs/multiple-tests/filter-files/results.xml @@ -1,7 +1,7 @@ - - + + diff --git a/docs/multiple-tests/multiple-files/results.xml b/docs/multiple-tests/multiple-files/results.xml index 2ed49f4..1eeea34 100644 --- a/docs/multiple-tests/multiple-files/results.xml +++ b/docs/multiple-tests/multiple-files/results.xml @@ -1,14 +1,14 @@ - - + + - - - - - + + + + + diff --git a/docs/multiple-tests/use-codacy-conf/results.xml b/docs/multiple-tests/use-codacy-conf/results.xml index 1f47dbc..7146716 100644 --- a/docs/multiple-tests/use-codacy-conf/results.xml +++ b/docs/multiple-tests/use-codacy-conf/results.xml @@ -2,10 +2,10 @@ - - - - - + + + + + diff --git a/docs/multiple-tests/with-config/results.xml b/docs/multiple-tests/with-config/results.xml index b8ebae9..da8dbec 100644 --- a/docs/multiple-tests/with-config/results.xml +++ b/docs/multiple-tests/with-config/results.xml @@ -1,8 +1,8 @@ - - + + diff --git a/docs/tests/array_init.swift b/docs/tests/array_init.swift index edcb4cf..31471c2 100644 --- a/docs/tests/array_init.swift +++ b/docs/tests/array_init.swift @@ -1,13 +1,13 @@ //#Patterns: array_init -//#Issue: {"severity": "Info", "line": 12, "patternId": "array_init"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "array_init"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "array_init"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "array_init"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "array_init"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "array_init"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "array_init"} -//#Issue: {"severity": "Info", "line": 48, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 48, "patternId": "array_init"} foo.map({ $0 }) diff --git a/docs/tests/block_based_kvo.swift b/docs/tests/block_based_kvo.swift index 364719b..3f0a797 100644 --- a/docs/tests/block_based_kvo.swift +++ b/docs/tests/block_based_kvo.swift @@ -1,7 +1,7 @@ //#Patterns: block_based_kvo -//#Issue: {"severity": "Info", "line": 9, "patternId": "block_based_kvo"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "block_based_kvo"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "block_based_kvo"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "block_based_kvo"} diff --git a/docs/tests/class_delegate_protocol.swift b/docs/tests/class_delegate_protocol.swift index aa0957c..33ac6c4 100644 --- a/docs/tests/class_delegate_protocol.swift +++ b/docs/tests/class_delegate_protocol.swift @@ -1,7 +1,7 @@ //#Patterns: class_delegate_protocol -//#Issue: {"severity": "Info", "line": 6, "patternId": "class_delegate_protocol"} -//#Issue: {"severity": "Info", "line": 9, "patternId": "class_delegate_protocol"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "class_delegate_protocol"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "class_delegate_protocol"} protocol FooDelegate {} diff --git a/docs/tests/closing_brace.swift b/docs/tests/closing_brace.swift index 78c9abe..9196728 100644 --- a/docs/tests/closing_brace.swift +++ b/docs/tests/closing_brace.swift @@ -1,7 +1,7 @@ //#Patterns: closing_brace -//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} [].map({ } ) diff --git a/docs/tests/closure_end_indentation.swift b/docs/tests/closure_end_indentation.swift index 96401cf..27dea1b 100644 --- a/docs/tests/closure_end_indentation.swift +++ b/docs/tests/closure_end_indentation.swift @@ -1,8 +1,8 @@ //#Patterns: closure_end_indentation -//#Issue: {"severity": "Info", "line": 10, "patternId": "closure_end_indentation"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "closure_end_indentation"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "closure_end_indentation"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "closure_end_indentation"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "closure_end_indentation"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "closure_end_indentation"} SignalProducer(values: [1, 2, 3]) .startWithNext { number in diff --git a/docs/tests/closure_parameter_position.swift b/docs/tests/closure_parameter_position.swift deleted file mode 100644 index 6e91100..0000000 --- a/docs/tests/closure_parameter_position.swift +++ /dev/null @@ -1,56 +0,0 @@ -//#Patterns: closure_parameter_position - -//#Issue: {"severity": "Info", "line": 12, "patternId": "closure_parameter_position"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "closure_parameter_position"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "closure_parameter_position"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "closure_parameter_position"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "closure_parameter_position"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "closure_parameter_position"} -//#Issue: {"severity": "Info", "line": 48, "patternId": "closure_parameter_position"} - - [1, 2].map { - number in - number + 1 - } - - - [1, 2].map { - number -> Int in - number + 1 - } - - - [1, 2].map { - (number: Int) -> Int in - number + 1 - } - - - [1, 2].map { - [weak self] number in - number + 1 - } - - - [1, 2].map { [weak self] - number in - number + 1 - } - - - [1, 2].map({ - number in - number + 1 - }) - - - [1, 2].something(closure: { - number in - number + 1 - }) - - - [1, 2].reduce(0) { - sum, ↓number in - number + sum - } diff --git a/docs/tests/closure_spacing.swift b/docs/tests/closure_spacing.swift index 8fb5cd8..fe4510e 100644 --- a/docs/tests/closure_spacing.swift +++ b/docs/tests/closure_spacing.swift @@ -1,9 +1,9 @@ //#Patterns: closure_spacing -//#Issue: {"severity": "Info", "line": 8, "patternId": "closure_spacing"} -//#Issue: {"severity": "Info", "line": 10, "patternId": "closure_spacing"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "closure_spacing"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "closure_spacing"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "closure_spacing"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "closure_spacing"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "closure_spacing"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "closure_spacing"} [].filter({$0.contains(location)}) diff --git a/docs/tests/comma.swift b/docs/tests/comma.swift index 8ad431a..018cc6f 100644 --- a/docs/tests/comma.swift +++ b/docs/tests/comma.swift @@ -1,10 +1,10 @@ //#Patterns: comma -//#Issue: {"severity": "Info", "line": 9, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "comma"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "comma"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "comma"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "comma"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "comma"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "comma"} func abc(a: String ,b: String) { } diff --git a/docs/tests/compiler_protocol_init.swift b/docs/tests/compiler_protocol_init.swift index 0acb9a1..532ece5 100644 --- a/docs/tests/compiler_protocol_init.swift +++ b/docs/tests/compiler_protocol_init.swift @@ -1,7 +1,7 @@ //#Patterns: compiler_protocol_init -//#Issue: {"severity": "Info", "line": 6, "patternId": "compiler_protocol_init"} -//#Issue: {"severity": "Info", "line": 9, "patternId": "compiler_protocol_init"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "compiler_protocol_init"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "compiler_protocol_init"} let set = Set(arrayLiteral: 1, 2) diff --git a/docs/tests/contains_over_first_not_nil.swift b/docs/tests/contains_over_first_not_nil.swift index d5532b5..471d68d 100644 --- a/docs/tests/contains_over_first_not_nil.swift +++ b/docs/tests/contains_over_first_not_nil.swift @@ -1,11 +1,11 @@ //#Patterns: contains_over_first_not_nil -//#Issue: {"severity": "Info", "line": 12, "patternId": "contains_over_first_not_nil"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "contains_over_first_not_nil"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "contains_over_first_not_nil"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "contains_over_first_not_nil"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "contains_over_first_not_nil"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "contains_over_first_not_nil"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "contains_over_first_not_nil"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "contains_over_first_not_nil"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "contains_over_first_not_nil"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "contains_over_first_not_nil"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "contains_over_first_not_nil"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "contains_over_first_not_nil"} diff --git a/docs/tests/control_statement.swift b/docs/tests/control_statement.swift index 7e04643..fe8680e 100644 --- a/docs/tests/control_statement.swift +++ b/docs/tests/control_statement.swift @@ -1,21 +1,21 @@ //#Patterns: control_statement -//#Issue: {"severity": "Info", "line": 20, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 53, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 41, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 47, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 53, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 56, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 59, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 62, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 65, "patternId": "control_statement"} if (condition) { diff --git a/docs/tests/discarded_notification_center_observer.swift b/docs/tests/discarded_notification_center_observer.swift index 7c390b1..7a963dc 100644 --- a/docs/tests/discarded_notification_center_observer.swift +++ b/docs/tests/discarded_notification_center_observer.swift @@ -1,8 +1,8 @@ //#Patterns: discarded_notification_center_observer -//#Issue: {"severity": "Info", "line": 7, "patternId": "discarded_notification_center_observer"} -//#Issue: {"severity": "Info", "line": 10, "patternId": "discarded_notification_center_observer"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "discarded_notification_center_observer"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "discarded_notification_center_observer"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "discarded_notification_center_observer"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "discarded_notification_center_observer"} nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { } diff --git a/docs/tests/discouraged_optional_boolean.swift b/docs/tests/discouraged_optional_boolean.swift index 445e69c..e3617a6 100644 --- a/docs/tests/discouraged_optional_boolean.swift +++ b/docs/tests/discouraged_optional_boolean.swift @@ -1,87 +1,87 @@ //#Patterns: discouraged_optional_boolean -//#Issue: {"severity": "Info", "line": 86, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 89, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 92, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 95, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 98, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 101, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 104, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 107, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 110, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 113, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 116, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 119, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 122, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 125, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 128, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 131, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 134, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 137, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 140, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 143, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 146, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 149, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 152, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 155, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 159, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 164, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 169, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 174, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 179, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 184, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 189, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 194, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 199, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 204, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 209, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 214, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 219, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 224, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 229, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 234, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 239, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 244, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 249, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 254, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 259, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 264, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 269, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 274, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 279, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 284, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 289, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 294, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 299, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 304, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 309, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 314, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 319, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 324, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 329, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 334, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 339, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 344, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 349, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 354, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 359, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 364, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 369, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 374, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 379, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 384, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 389, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 394, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 399, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 404, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 409, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 414, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 419, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 424, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 429, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 434, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 439, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Info", "line": 444, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 86, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 89, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 92, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 95, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 98, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 101, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 104, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 107, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 110, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 113, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 116, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 119, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 122, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 125, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 128, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 131, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 134, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 137, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 140, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 143, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 146, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 149, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 152, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 155, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 159, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 164, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 169, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 174, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 179, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 184, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 189, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 194, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 199, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 204, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 209, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 214, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 219, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 224, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 229, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 234, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 239, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 244, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 249, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 254, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 259, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 264, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 269, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 274, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 279, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 284, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 289, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 294, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 299, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 304, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 309, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 314, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 319, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 324, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 329, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 334, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 339, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 344, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 349, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 354, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 359, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 364, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 369, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 374, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 379, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 384, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 389, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 394, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 399, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 404, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 409, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 414, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 419, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 424, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 429, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 434, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 439, "patternId": "discouraged_optional_boolean"} +//#Issue: {"severity": "Warning", "line": 444, "patternId": "discouraged_optional_boolean"} var foo: Bool? diff --git a/docs/tests/dynamic_inline.swift b/docs/tests/dynamic_inline.swift index a173305..7a0c61f 100644 --- a/docs/tests/dynamic_inline.swift +++ b/docs/tests/dynamic_inline.swift @@ -1,10 +1,10 @@ //#Patterns: dynamic_inline -//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Error", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Error", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Error", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Error", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Error", "line": 29, "patternId": "dynamic_inline"} class C { @inline(__always) dynamic func f() {} diff --git a/docs/tests/empty_enum_arguments.swift b/docs/tests/empty_enum_arguments.swift index cba20ee..39ecc7d 100644 --- a/docs/tests/empty_enum_arguments.swift +++ b/docs/tests/empty_enum_arguments.swift @@ -1,9 +1,9 @@ //#Patterns: empty_enum_arguments -//#Issue: {"severity": "Info", "line": 9, "patternId": "empty_enum_arguments"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "empty_enum_arguments"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "empty_enum_arguments"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "empty_enum_arguments"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "empty_enum_arguments"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "empty_enum_arguments"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "empty_enum_arguments"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "empty_enum_arguments"} switch foo { case .bar(_): break diff --git a/docs/tests/empty_parameters.swift b/docs/tests/empty_parameters.swift index b51bec5..1827bdc 100644 --- a/docs/tests/empty_parameters.swift +++ b/docs/tests/empty_parameters.swift @@ -1,9 +1,9 @@ //#Patterns: empty_parameters -//#Issue: {"severity": "Info", "line": 8, "patternId": "empty_parameters"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "empty_parameters"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "empty_parameters"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "empty_parameters"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "empty_parameters"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "empty_parameters"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "empty_parameters"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "empty_parameters"} let abc: (Void) -> Void = {} diff --git a/docs/tests/empty_parentheses_with_trailing_closure.swift b/docs/tests/empty_parentheses_with_trailing_closure.swift index 2b3c2c6..c2550f9 100644 --- a/docs/tests/empty_parentheses_with_trailing_closure.swift +++ b/docs/tests/empty_parentheses_with_trailing_closure.swift @@ -1,9 +1,9 @@ //#Patterns: empty_parentheses_with_trailing_closure -//#Issue: {"severity": "Info", "line": 8, "patternId": "empty_parentheses_with_trailing_closure"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "empty_parentheses_with_trailing_closure"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "empty_parentheses_with_trailing_closure"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "empty_parentheses_with_trailing_closure"} [1, 2].map() { $0 + 1 } diff --git a/docs/tests/explicit_acl.swift b/docs/tests/explicit_acl.swift index 741ff35..d52b98c 100644 --- a/docs/tests/explicit_acl.swift +++ b/docs/tests/explicit_acl.swift @@ -1,11 +1,11 @@ //#Patterns: explicit_acl -//#Issue: {"severity": "Info", "line": 11, "patternId": "explicit_acl"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "explicit_acl"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "explicit_acl"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "explicit_acl"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "explicit_acl"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "explicit_acl"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "explicit_acl"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "explicit_acl"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "explicit_acl"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "explicit_acl"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "explicit_acl"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "explicit_acl"} enum A {} diff --git a/docs/tests/explicit_enum_raw_value.swift b/docs/tests/explicit_enum_raw_value.swift index a380c2f..4eea36b 100644 --- a/docs/tests/explicit_enum_raw_value.swift +++ b/docs/tests/explicit_enum_raw_value.swift @@ -1,10 +1,10 @@ //#Patterns: explicit_enum_raw_value -//#Issue: {"severity": "Info", "line": 12, "patternId": "explicit_enum_raw_value"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "explicit_enum_raw_value"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "explicit_enum_raw_value"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "explicit_enum_raw_value"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "explicit_enum_raw_value"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "explicit_enum_raw_value"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "explicit_enum_raw_value"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "explicit_enum_raw_value"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "explicit_enum_raw_value"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "explicit_enum_raw_value"} diff --git a/docs/tests/explicit_init.swift b/docs/tests/explicit_init.swift index 1d1ceb5..4774993 100644 --- a/docs/tests/explicit_init.swift +++ b/docs/tests/explicit_init.swift @@ -1,7 +1,7 @@ //#Patterns: explicit_init -//#Issue: {"severity": "Info", "line": 6, "patternId": "explicit_init"} -//#Issue: {"severity": "Info", "line": 8, "patternId": "explicit_init"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "explicit_init"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "explicit_init"} [1].flatMap{String.init($0)} diff --git a/docs/tests/explicit_top_level_acl.swift b/docs/tests/explicit_top_level_acl.swift index 203e709..9d36057 100644 --- a/docs/tests/explicit_top_level_acl.swift +++ b/docs/tests/explicit_top_level_acl.swift @@ -1,10 +1,10 @@ //#Patterns: explicit_top_level_acl -//#Issue: {"severity": "Info", "line": 9, "patternId": "explicit_top_level_acl"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "explicit_top_level_acl"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "explicit_top_level_acl"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "explicit_top_level_acl"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "explicit_top_level_acl"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "explicit_top_level_acl"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "explicit_top_level_acl"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "explicit_top_level_acl"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "explicit_top_level_acl"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "explicit_top_level_acl"} enum A {} diff --git a/docs/tests/extension_access_modifier.swift b/docs/tests/extension_access_modifier.swift index 1f765d5..2964c9f 100644 --- a/docs/tests/extension_access_modifier.swift +++ b/docs/tests/extension_access_modifier.swift @@ -1,9 +1,9 @@ //#Patterns: extension_access_modifier -//#Issue: {"severity": "Info", "line": 8, "patternId": "extension_access_modifier"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "extension_access_modifier"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "extension_access_modifier"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "extension_access_modifier"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "extension_access_modifier"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "extension_access_modifier"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "extension_access_modifier"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "extension_access_modifier"} extension Foo { public var bar: Int { return 1 } diff --git a/docs/tests/fallthrough.swift b/docs/tests/fallthrough.swift index 22d38c4..301fe9c 100644 --- a/docs/tests/fallthrough.swift +++ b/docs/tests/fallthrough.swift @@ -1,6 +1,6 @@ //#Patterns: fallthrough -//#Issue: {"severity": "Info", "line": 9, "patternId": "fallthrough"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "fallthrough"} diff --git a/docs/tests/fatal_error_message.swift b/docs/tests/fatal_error_message.swift index 3820dec..1a678e9 100644 --- a/docs/tests/fatal_error_message.swift +++ b/docs/tests/fatal_error_message.swift @@ -1,7 +1,7 @@ //#Patterns: fatal_error_message -//#Issue: {"severity": "Info", "line": 7, "patternId": "fatal_error_message"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "fatal_error_message"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "fatal_error_message"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "fatal_error_message"} func foo() { fatalError("") diff --git a/docs/tests/first_where.swift b/docs/tests/first_where.swift index 7b948d1..cd6b6a4 100644 --- a/docs/tests/first_where.swift +++ b/docs/tests/first_where.swift @@ -1,11 +1,11 @@ //#Patterns: first_where -//#Issue: {"severity": "Info", "line": 10, "patternId": "first_where"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "first_where"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "first_where"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "first_where"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "first_where"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "first_where"} myList.filter { $0 % 2 == 0 }.first diff --git a/docs/tests/for_where.swift b/docs/tests/for_where.swift index 12b76e4..f7fdfae 100644 --- a/docs/tests/for_where.swift +++ b/docs/tests/for_where.swift @@ -1,6 +1,6 @@ //#Patterns: for_where -//#Issue: {"severity": "Info", "line": 6, "patternId": "for_where"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "for_where"} for user in users { if user.id == 1 { return true } diff --git a/docs/tests/force_cast.swift b/docs/tests/force_cast.swift index c31ff9a..c304f04 100644 --- a/docs/tests/force_cast.swift +++ b/docs/tests/force_cast.swift @@ -1,5 +1,5 @@ //#Patterns: force_cast -//#Issue: {"severity": "Info", "line": 5, "patternId": "force_cast"} +//#Issue: {"severity": "Error", "line": 5, "patternId": "force_cast"} NSNumber() as! Int diff --git a/docs/tests/force_try.swift b/docs/tests/force_try.swift index 48f1357..7da7517 100644 --- a/docs/tests/force_try.swift +++ b/docs/tests/force_try.swift @@ -1,5 +1,5 @@ //#Patterns: force_try -//#Issue: {"severity": "Info", "line": 5, "patternId": "force_try"} +//#Issue: {"severity": "Error", "line": 5, "patternId": "force_try"} func a() throws {}; try! a() diff --git a/docs/tests/force_unwrapping.swift b/docs/tests/force_unwrapping.swift index 64f9622..9010072 100644 --- a/docs/tests/force_unwrapping.swift +++ b/docs/tests/force_unwrapping.swift @@ -1,18 +1,18 @@ //#Patterns: force_unwrapping -//#Issue: {"severity": "Info", "line": 17, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "force_unwrapping"} -//#Issue: {"severity": "Info", "line": 43, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 37, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "force_unwrapping"} +//#Issue: {"severity": "Warning", "line": 43, "patternId": "force_unwrapping"} let url = NSURL(string: query)! diff --git a/docs/tests/implicit_getter.swift b/docs/tests/implicit_getter.swift index 00e8c0c..4a1354c 100644 --- a/docs/tests/implicit_getter.swift +++ b/docs/tests/implicit_getter.swift @@ -1,10 +1,10 @@ //#Patterns: implicit_getter -//#Issue: {"severity": "Info", "line": 11, "patternId": "implicit_getter"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "implicit_getter"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "implicit_getter"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "implicit_getter"} -//#Issue: {"severity": "Info", "line": 49, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 49, "patternId": "implicit_getter"} class Foo { var foo: Int { diff --git a/docs/tests/is_disjoint.swift b/docs/tests/is_disjoint.swift index 12befab..7c7a22b 100644 --- a/docs/tests/is_disjoint.swift +++ b/docs/tests/is_disjoint.swift @@ -1,7 +1,7 @@ //#Patterns: is_disjoint -//#Issue: {"severity": "Info", "line": 8, "patternId": "is_disjoint"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "is_disjoint"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "is_disjoint"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "is_disjoint"} diff --git a/docs/tests/joined_default_parameter.swift b/docs/tests/joined_default_parameter.swift index ddb0690..e45748f 100644 --- a/docs/tests/joined_default_parameter.swift +++ b/docs/tests/joined_default_parameter.swift @@ -1,7 +1,7 @@ //#Patterns: joined_default_parameter -//#Issue: {"severity": "Info", "line": 8, "patternId": "joined_default_parameter"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "joined_default_parameter"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "joined_default_parameter"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "joined_default_parameter"} diff --git a/docs/tests/legacy_cggeometry_functions.swift b/docs/tests/legacy_cggeometry_functions.swift index 13805dc..a8a2b85 100644 --- a/docs/tests/legacy_cggeometry_functions.swift +++ b/docs/tests/legacy_cggeometry_functions.swift @@ -1,25 +1,25 @@ //#Patterns: legacy_cggeometry_functions -//#Issue: {"severity": "Info", "line": 24, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 48, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 52, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 58, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 60, "patternId": "legacy_cggeometry_functions"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 46, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 48, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 52, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 56, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 58, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 60, "patternId": "legacy_cggeometry_functions"} +//#Issue: {"severity": "Warning", "line": 62, "patternId": "legacy_cggeometry_functions"} CGRectGetWidth(rect) diff --git a/docs/tests/legacy_constant.swift b/docs/tests/legacy_constant.swift index ce1de6e..cd0727e 100644 --- a/docs/tests/legacy_constant.swift +++ b/docs/tests/legacy_constant.swift @@ -1,15 +1,15 @@ //#Patterns: legacy_constant -//#Issue: {"severity": "Info", "line": 14, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "legacy_constant"} CGRectInfinite diff --git a/docs/tests/legacy_constructor.swift b/docs/tests/legacy_constructor.swift index ed5af78..3ce126c 100644 --- a/docs/tests/legacy_constructor.swift +++ b/docs/tests/legacy_constructor.swift @@ -1,25 +1,25 @@ //#Patterns: legacy_constructor -//#Issue: {"severity": "Info", "line": 24, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 48, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 52, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 58, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 60, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 46, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 48, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 52, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 56, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 58, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 60, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 62, "patternId": "legacy_constructor"} CGPointMake(10, 10) diff --git a/docs/tests/legacy_nsgeometry_functions.swift b/docs/tests/legacy_nsgeometry_functions.swift index 0e72904..83d57e1 100644 --- a/docs/tests/legacy_nsgeometry_functions.swift +++ b/docs/tests/legacy_nsgeometry_functions.swift @@ -1,26 +1,26 @@ //#Patterns: legacy_nsgeometry_functions -//#Issue: {"severity": "Info", "line": 25, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 39, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 43, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 45, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 49, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 51, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 53, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 55, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 57, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 61, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 63, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 37, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 39, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 41, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 43, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 45, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 47, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 49, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 51, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 53, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 55, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 57, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 59, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 61, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 63, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 65, "patternId": "legacy_nsgeometry_functions"} NSWidth(rect) diff --git a/docs/tests/let_var_whitespace.swift b/docs/tests/let_var_whitespace.swift index 72b93f7..ffe7a46 100644 --- a/docs/tests/let_var_whitespace.swift +++ b/docs/tests/let_var_whitespace.swift @@ -1,11 +1,11 @@ //#Patterns: let_var_whitespace -//#Issue: {"severity": "Info", "line": 12, "patternId": "let_var_whitespace"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "let_var_whitespace"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "let_var_whitespace"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "let_var_whitespace"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "let_var_whitespace"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "let_var_whitespace"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "let_var_whitespace"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "let_var_whitespace"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "let_var_whitespace"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "let_var_whitespace"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "let_var_whitespace"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "let_var_whitespace"} var x = 1 diff --git a/docs/tests/literal_expression_end_indentation.swift b/docs/tests/literal_expression_end_indentation.swift index 03b2e21..dd09645 100644 --- a/docs/tests/literal_expression_end_indentation.swift +++ b/docs/tests/literal_expression_end_indentation.swift @@ -1,8 +1,8 @@ //#Patterns: literal_expression_end_indentation -//#Issue: {"severity": "Info", "line": 12, "patternId": "literal_expression_end_indentation"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "literal_expression_end_indentation"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "literal_expression_end_indentation"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "literal_expression_end_indentation"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "literal_expression_end_indentation"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "literal_expression_end_indentation"} diff --git a/docs/tests/mark.swift b/docs/tests/mark.swift index 1301746..146ba6b 100644 --- a/docs/tests/mark.swift +++ b/docs/tests/mark.swift @@ -1,25 +1,25 @@ //#Patterns: mark -//#Issue: {"severity": "Info", "line": 24, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 48, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 52, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 58, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 61, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 46, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 48, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 52, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 56, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 58, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 59, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 61, "patternId": "mark"} //MARK: bad diff --git a/docs/tests/multiline_parameters.swift b/docs/tests/multiline_parameters.swift index 9ec4694..68c22a5 100644 --- a/docs/tests/multiline_parameters.swift +++ b/docs/tests/multiline_parameters.swift @@ -1,24 +1,24 @@ //#Patterns: multiline_parameters -//#Issue: {"severity": "Info", "line": 23, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 39, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 49, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 64, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 69, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 74, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 79, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 84, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 89, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 94, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 99, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 104, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 109, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Info", "line": 114, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 39, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 49, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 59, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 64, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 69, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 74, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 79, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 84, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 89, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 94, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 99, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 104, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 109, "patternId": "multiline_parameters"} +//#Issue: {"severity": "Warning", "line": 114, "patternId": "multiline_parameters"} func foo(_ param1: Int, param2: Int, param3: Int) -> (Int) -> Int { diff --git a/docs/tests/multiple_closures_with_trailing_closure.swift b/docs/tests/multiple_closures_with_trailing_closure.swift index 679d852..563a950 100644 --- a/docs/tests/multiple_closures_with_trailing_closure.swift +++ b/docs/tests/multiple_closures_with_trailing_closure.swift @@ -1,7 +1,7 @@ //#Patterns: multiple_closures_with_trailing_closure -//#Issue: {"severity": "Info", "line": 8, "patternId": "multiple_closures_with_trailing_closure"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "multiple_closures_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "multiple_closures_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "multiple_closures_with_trailing_closure"} diff --git a/docs/tests/nimble_operator.swift b/docs/tests/nimble_operator.swift index 5261baf..cd51956 100644 --- a/docs/tests/nimble_operator.swift +++ b/docs/tests/nimble_operator.swift @@ -1,14 +1,14 @@ //#Patterns: nimble_operator -//#Issue: {"severity": "Info", "line": 13, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "nimble_operator"} expect(seagull.squawk).toNot(equal("Hi")) diff --git a/docs/tests/no_extension_access_modifier.swift b/docs/tests/no_extension_access_modifier.swift index b601dff..dd17e4c 100644 --- a/docs/tests/no_extension_access_modifier.swift +++ b/docs/tests/no_extension_access_modifier.swift @@ -1,10 +1,10 @@ //#Patterns: no_extension_access_modifier -//#Issue: {"severity": "Info", "line": 9, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Error", "line": 9, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Error", "line": 11, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Error", "line": 14, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Error", "line": 16, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Error", "line": 18, "patternId": "no_extension_access_modifier"} private extension String {} diff --git a/docs/tests/no_grouping_extension.swift b/docs/tests/no_grouping_extension.swift index cb5845d..ec71e66 100644 --- a/docs/tests/no_grouping_extension.swift +++ b/docs/tests/no_grouping_extension.swift @@ -1,9 +1,9 @@ //#Patterns: no_grouping_extension -//#Issue: {"severity": "Info", "line": 11, "patternId": "no_grouping_extension"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "no_grouping_extension"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "no_grouping_extension"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "no_grouping_extension"} diff --git a/docs/tests/notification_center_detachment.swift b/docs/tests/notification_center_detachment.swift index 14a4779..a0964c8 100644 --- a/docs/tests/notification_center_detachment.swift +++ b/docs/tests/notification_center_detachment.swift @@ -1,6 +1,6 @@ //#Patterns: notification_center_detachment -//#Issue: {"severity": "Info", "line": 7, "patternId": "notification_center_detachment"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "notification_center_detachment"} class Foo { func bar() { diff --git a/docs/tests/opening_brace.swift b/docs/tests/opening_brace.swift index 8586cec..b0c2be8 100644 --- a/docs/tests/opening_brace.swift +++ b/docs/tests/opening_brace.swift @@ -1,19 +1,19 @@ //#Patterns: opening_brace -//#Issue: {"severity": "Info", "line": 18, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 49, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 53, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "opening_brace"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 37, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 47, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 49, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 53, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 59, "patternId": "opening_brace"} +//#Issue: {"severity": "Warning", "line": 65, "patternId": "opening_brace"} func abc(){ } diff --git a/docs/tests/operator_usage_whitespace.swift b/docs/tests/operator_usage_whitespace.swift index 0fc02a8..a02b675 100644 --- a/docs/tests/operator_usage_whitespace.swift +++ b/docs/tests/operator_usage_whitespace.swift @@ -1,20 +1,20 @@ //#Patterns: operator_usage_whitespace -//#Issue: {"severity": "Info", "line": 19, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 43, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 49, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 52, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 55, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 58, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Info", "line": 61, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 37, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 43, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 46, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 49, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 52, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 55, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 58, "patternId": "operator_usage_whitespace"} +//#Issue: {"severity": "Warning", "line": 61, "patternId": "operator_usage_whitespace"} let foo = 1+2 diff --git a/docs/tests/operator_whitespace.swift b/docs/tests/operator_whitespace.swift index b3aacdb..f9fefa1 100644 --- a/docs/tests/operator_whitespace.swift +++ b/docs/tests/operator_whitespace.swift @@ -1,11 +1,11 @@ //#Patterns: operator_whitespace -//#Issue: {"severity": "Info", "line": 10, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "operator_whitespace"} func <|(lhs: Int, rhs: Int) -> Int {} diff --git a/docs/tests/override_in_extension.swift b/docs/tests/override_in_extension.swift index c28a1c3..23c84aa 100644 --- a/docs/tests/override_in_extension.swift +++ b/docs/tests/override_in_extension.swift @@ -1,7 +1,7 @@ //#Patterns: override_in_extension -//#Issue: {"severity": "Info", "line": 9, "patternId": "override_in_extension"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "override_in_extension"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "override_in_extension"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "override_in_extension"} diff --git a/docs/tests/pattern_matching_keywords.swift b/docs/tests/pattern_matching_keywords.swift index 6a6ed1a..c6676d5 100644 --- a/docs/tests/pattern_matching_keywords.swift +++ b/docs/tests/pattern_matching_keywords.swift @@ -1,11 +1,11 @@ //#Patterns: pattern_matching_keywords -//#Issue: {"severity": "Info", "line": 11, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "pattern_matching_keywords"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "pattern_matching_keywords"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "pattern_matching_keywords"} switch foo { case (let x, let y): break diff --git a/docs/tests/private_action.swift b/docs/tests/private_action.swift index 4e3c771..a8caaaa 100644 --- a/docs/tests/private_action.swift +++ b/docs/tests/private_action.swift @@ -1,16 +1,16 @@ //#Patterns: private_action -//#Issue: {"severity": "Info", "line": 17, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 53, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 71, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 77, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 41, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 47, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 53, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 59, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 65, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 71, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 77, "patternId": "private_action"} class Foo { diff --git a/docs/tests/protocol_property_accessors_order.swift b/docs/tests/protocol_property_accessors_order.swift index 6836af9..1dec6da 100644 --- a/docs/tests/protocol_property_accessors_order.swift +++ b/docs/tests/protocol_property_accessors_order.swift @@ -1,6 +1,6 @@ //#Patterns: protocol_property_accessors_order -//#Issue: {"severity": "Info", "line": 6, "patternId": "protocol_property_accessors_order"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "protocol_property_accessors_order"} protocol Foo { var bar: String { set get } diff --git a/docs/tests/quick_discouraged_call.swift b/docs/tests/quick_discouraged_call.swift index 135c69a..3963cc2 100644 --- a/docs/tests/quick_discouraged_call.swift +++ b/docs/tests/quick_discouraged_call.swift @@ -1,20 +1,20 @@ //#Patterns: quick_discouraged_call -//#Issue: {"severity": "Info", "line": 30, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 51, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 55, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 79, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 92, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 102, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 112, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 122, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 132, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 142, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 145, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 155, "patternId": "quick_discouraged_call"} -//#Issue: {"severity": "Info", "line": 158, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 51, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 55, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 79, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 92, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 102, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 112, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 122, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 132, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 142, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 145, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 155, "patternId": "quick_discouraged_call"} +//#Issue: {"severity": "Warning", "line": 158, "patternId": "quick_discouraged_call"} class TotoTests { diff --git a/docs/tests/quick_discouraged_focused_test.swift b/docs/tests/quick_discouraged_focused_test.swift index c6a3c2b..5746c17 100644 --- a/docs/tests/quick_discouraged_focused_test.swift +++ b/docs/tests/quick_discouraged_focused_test.swift @@ -1,12 +1,12 @@ //#Patterns: quick_discouraged_focused_test -//#Issue: {"severity": "Info", "line": 13, "patternId": "quick_discouraged_focused_test"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "quick_discouraged_focused_test"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "quick_discouraged_focused_test"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "quick_discouraged_focused_test"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "quick_discouraged_focused_test"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "quick_discouraged_focused_test"} -//#Issue: {"severity": "Info", "line": 63, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "quick_discouraged_focused_test"} +//#Issue: {"severity": "Warning", "line": 63, "patternId": "quick_discouraged_focused_test"} class TotoTests: QuickSpec { override func spec() { diff --git a/docs/tests/quick_discouraged_pending_test.swift b/docs/tests/quick_discouraged_pending_test.swift deleted file mode 100644 index e604557..0000000 --- a/docs/tests/quick_discouraged_pending_test.swift +++ /dev/null @@ -1,81 +0,0 @@ -//#Patterns: quick_discouraged_pending_test - -//#Issue: {"severity": "Info", "line": 15, "patternId": "quick_discouraged_pending_test"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "quick_discouraged_pending_test"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "quick_discouraged_pending_test"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "quick_discouraged_pending_test"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "quick_discouraged_pending_test"} -//#Issue: {"severity": "Info", "line": 61, "patternId": "quick_discouraged_pending_test"} -//#Issue: {"severity": "Info", "line": 71, "patternId": "quick_discouraged_pending_test"} -//#Issue: {"severity": "Info", "line": 79, "patternId": "quick_discouraged_pending_test"} - - -class TotoTests: QuickSpec { - override func spec() { - xdescribe("foo") { } - } -} - - - -class TotoTests: QuickSpec { - override func spec() { - xcontext("foo") { } - } -} - - - -class TotoTests: QuickSpec { - override func spec() { - xit("foo") { } - } -} - - - -class TotoTests: QuickSpec { - override func spec() { - describe("foo") { - xit("bar") { } - } - } -} - - - -class TotoTests: QuickSpec { - override func spec() { - context("foo") { - xit("bar") { } - } - } -} - - - -class TotoTests: QuickSpec { - override func spec() { - describe("foo") { - context("bar") { - xit("toto") { } - } - } - } -} - - - -class TotoTests: QuickSpec { - override func spec() { - pending("foo") - } -} - - - -class TotoTests: QuickSpec { - override func spec() { - xitBehavesLike("foo") - } -} diff --git a/docs/tests/redundant_discardable_let.swift b/docs/tests/redundant_discardable_let.swift index 9cd24f8..dd9bc51 100644 --- a/docs/tests/redundant_discardable_let.swift +++ b/docs/tests/redundant_discardable_let.swift @@ -1,7 +1,7 @@ //#Patterns: redundant_discardable_let -//#Issue: {"severity": "Info", "line": 6, "patternId": "redundant_discardable_let"} -//#Issue: {"severity": "Info", "line": 9, "patternId": "redundant_discardable_let"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "redundant_discardable_let"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "redundant_discardable_let"} let _ = foo() diff --git a/docs/tests/redundant_nil_coalescing.swift b/docs/tests/redundant_nil_coalescing.swift index abfa14c..c04d03b 100644 --- a/docs/tests/redundant_nil_coalescing.swift +++ b/docs/tests/redundant_nil_coalescing.swift @@ -1,7 +1,7 @@ //#Patterns: redundant_nil_coalescing -//#Issue: {"severity": "Info", "line": 6, "patternId": "redundant_nil_coalescing"} -//#Issue: {"severity": "Info", "line": 9, "patternId": "redundant_nil_coalescing"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "redundant_nil_coalescing"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "redundant_nil_coalescing"} var myVar: Int? = nil; myVar ?? nil diff --git a/docs/tests/redundant_optional_initialization.swift b/docs/tests/redundant_optional_initialization.swift index 8477089..69c122f 100644 --- a/docs/tests/redundant_optional_initialization.swift +++ b/docs/tests/redundant_optional_initialization.swift @@ -1,9 +1,9 @@ //#Patterns: redundant_optional_initialization -//#Issue: {"severity": "Info", "line": 8, "patternId": "redundant_optional_initialization"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "redundant_optional_initialization"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "redundant_optional_initialization"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "redundant_optional_initialization"} var myVar: Int? = nil diff --git a/docs/tests/redundant_string_enum_value.swift b/docs/tests/redundant_string_enum_value.swift index 7485a78..07e0c3d 100644 --- a/docs/tests/redundant_string_enum_value.swift +++ b/docs/tests/redundant_string_enum_value.swift @@ -1,9 +1,9 @@ //#Patterns: redundant_string_enum_value -//#Issue: {"severity": "Info", "line": 9, "patternId": "redundant_string_enum_value"} -//#Issue: {"severity": "Info", "line": 10, "patternId": "redundant_string_enum_value"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "redundant_string_enum_value"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "redundant_string_enum_value"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "redundant_string_enum_value"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "redundant_string_enum_value"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "redundant_string_enum_value"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "redundant_string_enum_value"} enum Numbers: String { case one = "one" diff --git a/docs/tests/redundant_void_return.swift b/docs/tests/redundant_void_return.swift index ead3abd..f5e239f 100644 --- a/docs/tests/redundant_void_return.swift +++ b/docs/tests/redundant_void_return.swift @@ -1,9 +1,9 @@ //#Patterns: redundant_void_return -//#Issue: {"severity": "Info", "line": 8, "patternId": "redundant_void_return"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "redundant_void_return"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "redundant_void_return"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "redundant_void_return"} func foo() -> Void {} diff --git a/docs/tests/return_arrow_whitespace.swift b/docs/tests/return_arrow_whitespace.swift index c62b57f..2c4b840 100644 --- a/docs/tests/return_arrow_whitespace.swift +++ b/docs/tests/return_arrow_whitespace.swift @@ -1,13 +1,13 @@ //#Patterns: return_arrow_whitespace -//#Issue: {"severity": "Info", "line": 12, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "return_arrow_whitespace"} func abc()->Int {} diff --git a/docs/tests/shorthand_operator.swift b/docs/tests/shorthand_operator.swift index cd3d248..87e1d73 100644 --- a/docs/tests/shorthand_operator.swift +++ b/docs/tests/shorthand_operator.swift @@ -1,27 +1,27 @@ //#Patterns: shorthand_operator -//#Issue: {"severity": "Info", "line": 26, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 53, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 68, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 71, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 74, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 77, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 80, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 83, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 86, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 88, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 26, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 29, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 32, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 35, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 38, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 41, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 44, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 47, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 50, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 53, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 56, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 59, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 62, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 65, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 68, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 71, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 74, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 77, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 80, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 83, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 86, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 88, "patternId": "shorthand_operator"} foo = foo - 1 diff --git a/docs/tests/single_test_class.swift b/docs/tests/single_test_class.swift index 8b07b87..a7f607b 100644 --- a/docs/tests/single_test_class.swift +++ b/docs/tests/single_test_class.swift @@ -1,19 +1,19 @@ //#Patterns: single_test_class -//#Issue: {"severity": "Info", "line": 19, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "single_test_class"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 37, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 41, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 46, "patternId": "single_test_class"} +//#Issue: {"severity": "Warning", "line": 47, "patternId": "single_test_class"} class FooTests: QuickSpec { } diff --git a/docs/tests/sorted_first_last.swift b/docs/tests/sorted_first_last.swift index fc2178c..47dddad 100644 --- a/docs/tests/sorted_first_last.swift +++ b/docs/tests/sorted_first_last.swift @@ -1,18 +1,18 @@ //#Patterns: sorted_first_last -//#Issue: {"severity": "Info", "line": 18, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 58, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 66, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 46, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 58, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 62, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 66, "patternId": "sorted_first_last"} myList.sorted().first diff --git a/docs/tests/sorted_imports.swift b/docs/tests/sorted_imports.swift index fc3e85e..b57199a 100644 --- a/docs/tests/sorted_imports.swift +++ b/docs/tests/sorted_imports.swift @@ -1,6 +1,6 @@ //#Patterns: sorted_imports -//#Issue: {"severity": "Info", "line": 7, "patternId": "sorted_imports"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "sorted_imports"} import AAA import ZZZ diff --git a/docs/tests/strict_fileprivate.swift b/docs/tests/strict_fileprivate.swift index 322f5b0..ab55faf 100644 --- a/docs/tests/strict_fileprivate.swift +++ b/docs/tests/strict_fileprivate.swift @@ -1,12 +1,12 @@ //#Patterns: strict_fileprivate -//#Issue: {"severity": "Info", "line": 12, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "strict_fileprivate"} fileprivate extension String {} diff --git a/docs/tests/switch_case_on_newline.swift b/docs/tests/switch_case_on_newline.swift index 7094614..070f7ae 100644 --- a/docs/tests/switch_case_on_newline.swift +++ b/docs/tests/switch_case_on_newline.swift @@ -1,14 +1,14 @@ //#Patterns: switch_case_on_newline -//#Issue: {"severity": "Info", "line": 14, "patternId": "switch_case_on_newline"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "switch_case_on_newline"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "switch_case_on_newline"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "switch_case_on_newline"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "switch_case_on_newline"} -//#Issue: {"severity": "Info", "line": 39, "patternId": "switch_case_on_newline"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "switch_case_on_newline"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "switch_case_on_newline"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "switch_case_on_newline"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "switch_case_on_newline"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "switch_case_on_newline"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "switch_case_on_newline"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "switch_case_on_newline"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "switch_case_on_newline"} +//#Issue: {"severity": "Warning", "line": 39, "patternId": "switch_case_on_newline"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "switch_case_on_newline"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "switch_case_on_newline"} +//#Issue: {"severity": "Warning", "line": 56, "patternId": "switch_case_on_newline"} switch foo { case 1: return true diff --git a/docs/tests/syntactic_sugar.swift b/docs/tests/syntactic_sugar.swift index 8fb6bde..b9e2a02 100644 --- a/docs/tests/syntactic_sugar.swift +++ b/docs/tests/syntactic_sugar.swift @@ -1,15 +1,15 @@ //#Patterns: syntactic_sugar -//#Issue: {"severity": "Info", "line": 14, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "syntactic_sugar"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "syntactic_sugar"} let x: Array diff --git a/docs/tests/todo.swift b/docs/tests/todo.swift index 7463db7..380b461 100644 --- a/docs/tests/todo.swift +++ b/docs/tests/todo.swift @@ -1,13 +1,13 @@ //#Patterns: todo -//#Issue: {"severity": "Info", "line": 12, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "todo"} // TODO: diff --git a/docs/tests/trailing_semicolon.swift b/docs/tests/trailing_semicolon.swift index d08f4b2..0d562f9 100644 --- a/docs/tests/trailing_semicolon.swift +++ b/docs/tests/trailing_semicolon.swift @@ -1,10 +1,10 @@ //#Patterns: trailing_semicolon -//#Issue: {"severity": "Info", "line": 9, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "trailing_semicolon"} let a = 0; diff --git a/docs/tests/unneeded_break_in_switch.swift b/docs/tests/unneeded_break_in_switch.swift index 4f83a52..5f2c26a 100644 --- a/docs/tests/unneeded_break_in_switch.swift +++ b/docs/tests/unneeded_break_in_switch.swift @@ -1,9 +1,9 @@ //#Patterns: unneeded_break_in_switch -//#Issue: {"severity": "Info", "line": 12, "patternId": "unneeded_break_in_switch"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "unneeded_break_in_switch"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "unneeded_break_in_switch"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "unneeded_break_in_switch"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "unneeded_break_in_switch"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "unneeded_break_in_switch"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "unneeded_break_in_switch"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "unneeded_break_in_switch"} switch foo { diff --git a/docs/tests/unneeded_parentheses_in_closure_argument.swift b/docs/tests/unneeded_parentheses_in_closure_argument.swift index 7167226..6fbc13b 100644 --- a/docs/tests/unneeded_parentheses_in_closure_argument.swift +++ b/docs/tests/unneeded_parentheses_in_closure_argument.swift @@ -1,10 +1,10 @@ //#Patterns: unneeded_parentheses_in_closure_argument -//#Issue: {"severity": "Info", "line": 10, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "unneeded_parentheses_in_closure_argument"} call(arg: { (bar) in }) diff --git a/docs/tests/unused_closure_parameter.swift b/docs/tests/unused_closure_parameter.swift index 46c93c0..c0e0f5f 100644 --- a/docs/tests/unused_closure_parameter.swift +++ b/docs/tests/unused_closure_parameter.swift @@ -1,13 +1,13 @@ //#Patterns: unused_closure_parameter -//#Issue: {"severity": "Info", "line": 12, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 45, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 37, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 41, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 45, "patternId": "unused_closure_parameter"} [1, 2].map { number in return 3 diff --git a/docs/tests/unused_enumerated.swift b/docs/tests/unused_enumerated.swift index 53932a9..fefbb13 100644 --- a/docs/tests/unused_enumerated.swift +++ b/docs/tests/unused_enumerated.swift @@ -1,9 +1,9 @@ //#Patterns: unused_enumerated -//#Issue: {"severity": "Info", "line": 8, "patternId": "unused_enumerated"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "unused_enumerated"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "unused_enumerated"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "unused_enumerated"} for (_, foo) in bar.enumerated() { } diff --git a/docs/tests/valid_ibinspectable.swift b/docs/tests/valid_ibinspectable.swift index 98448c5..e7cc66b 100644 --- a/docs/tests/valid_ibinspectable.swift +++ b/docs/tests/valid_ibinspectable.swift @@ -1,14 +1,14 @@ //#Patterns: valid_ibinspectable -//#Issue: {"severity": "Info", "line": 14, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 39, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 49, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 39, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 49, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "valid_ibinspectable"} class Foo { @IBInspectable private let count: Int diff --git a/docs/tests/vertical_parameter_alignment.swift b/docs/tests/vertical_parameter_alignment.swift index cabd4f8..eca126f 100644 --- a/docs/tests/vertical_parameter_alignment.swift +++ b/docs/tests/vertical_parameter_alignment.swift @@ -1,9 +1,9 @@ //#Patterns: vertical_parameter_alignment -//#Issue: {"severity": "Info", "line": 9, "patternId": "vertical_parameter_alignment"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "vertical_parameter_alignment"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "vertical_parameter_alignment"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "vertical_parameter_alignment"} func validateFunction(_ file: File, kind: SwiftDeclarationKind, dictionary: [String: SourceKitRepresentable]) { } diff --git a/docs/tests/vertical_parameter_alignment_on_call.swift b/docs/tests/vertical_parameter_alignment_on_call.swift index 628e18d..d9a51b8 100644 --- a/docs/tests/vertical_parameter_alignment_on_call.swift +++ b/docs/tests/vertical_parameter_alignment_on_call.swift @@ -1,12 +1,12 @@ //#Patterns: vertical_parameter_alignment_on_call -//#Issue: {"severity": "Info", "line": 12, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "vertical_parameter_alignment_on_call"} foo(param1: 1, param2: bar param3: false, param4: true) diff --git a/docs/tests/void_return.swift b/docs/tests/void_return.swift index 586b837..e0a4ac7 100644 --- a/docs/tests/void_return.swift +++ b/docs/tests/void_return.swift @@ -1,12 +1,12 @@ //#Patterns: void_return -//#Issue: {"severity": "Info", "line": 11, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "void_return"} let abc: () -> () = {} diff --git a/docs/tests/weak_delegate.swift b/docs/tests/weak_delegate.swift index a35ec81..e815b99 100644 --- a/docs/tests/weak_delegate.swift +++ b/docs/tests/weak_delegate.swift @@ -1,7 +1,7 @@ //#Patterns: weak_delegate -//#Issue: {"severity": "Info", "line": 7, "patternId": "weak_delegate"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "weak_delegate"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "weak_delegate"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "weak_delegate"} class Foo { var delegate: SomeProtocol? diff --git a/docs/tests/xctfail_message.swift b/docs/tests/xctfail_message.swift index 61ae9a0..7ab9607 100644 --- a/docs/tests/xctfail_message.swift +++ b/docs/tests/xctfail_message.swift @@ -1,7 +1,7 @@ //#Patterns: xctfail_message -//#Issue: {"severity": "Info", "line": 8, "patternId": "xctfail_message"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "xctfail_message"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "xctfail_message"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "xctfail_message"} func testFoo() { diff --git a/docs/tests/yoda_condition.swift b/docs/tests/yoda_condition.swift index 09c4bee..55c302b 100644 --- a/docs/tests/yoda_condition.swift +++ b/docs/tests/yoda_condition.swift @@ -1,12 +1,12 @@ //#Patterns: yoda_condition -//#Issue: {"severity": "Info", "line": 12, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "yoda_condition"} if 42 == foo {} From 41a51630ba3ea586720dfc683842935ecb88b4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20=20Melo?= Date: Tue, 8 Jun 2021 12:10:05 +0100 Subject: [PATCH 045/119] bump: Bump circleci plugins test orb CY-4462 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 50ab245..4f59284 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 orbs: codacy: codacy/base@4.2.7 - codacy_plugins_test: codacy/plugins-test@0.14.5 + codacy_plugins_test: codacy/plugins-test@0.15.4 workflows: version: 2 From 0c73909bf2ba6ed9752198bb247c1243afc56b32 Mon Sep 17 00:00:00 2001 From: Joao Machado Date: Wed, 20 Oct 2021 12:17:04 +0100 Subject: [PATCH 046/119] bump: Update base image CY-5141 --- Dockerfile | 4 ++-- Dockerfile.dev | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7bee871..4352631 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM norionomura/swiftlint:0.40.0 as builder +FROM norionomura/swiftlint:0.43.1_swift-5.4.0 as builder -FROM swift:5.2.4-xenial-slim +FROM swift:5.5.0-xenial-slim COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so diff --git a/Dockerfile.dev b/Dockerfile.dev index f8a1f95..1e169dd 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,6 +1,6 @@ -FROM norionomura/swiftlint:0.40.0 as builder +FROM norionomura/swiftlint:0.43.1_swift-5.4.0 as builder -FROM swift:5.2.4-xenial-slim +FROM swift:5.5.0-xenial-slim RUN apt-get update && apt-get install -y openjdk-8-jre From f98ca4c93d3205a5aa5ca569f58b59fcf1dfc2a4 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 27 Oct 2021 11:54:17 +0200 Subject: [PATCH 047/119] fix: Update tests to new output and delete some tests --- .circleci/config.yml | 1 + docs/tests/attributes.swift | 131 --------------------- docs/tests/empty_enum_arguments.swift | 5 +- docs/tests/explicit_enum_raw_value.swift | 2 +- docs/tests/implicit_return.swift | 12 -- docs/tests/nesting.swift | 8 +- docs/tests/redundant_discardable_let.swift | 9 -- docs/tests/unneeded_break_in_switch.swift | 34 ------ 8 files changed, 8 insertions(+), 194 deletions(-) delete mode 100644 docs/tests/attributes.swift delete mode 100644 docs/tests/implicit_return.swift delete mode 100644 docs/tests/redundant_discardable_let.swift delete mode 100644 docs/tests/unneeded_break_in_switch.swift diff --git a/.circleci/config.yml b/.circleci/config.yml index 4f59284..875a6b9 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,6 +26,7 @@ workflows: docker build -t $CIRCLE_PROJECT_REPONAME:latest . docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest persist_to_workspace: true + cache_prefix: sbt-cache-27102021 requires: - codacy/checkout_and_version - codacy_plugins_test/run: diff --git a/docs/tests/attributes.swift b/docs/tests/attributes.swift deleted file mode 100644 index 4891581..0000000 --- a/docs/tests/attributes.swift +++ /dev/null @@ -1,131 +0,0 @@ -//#Patterns: attributes - -//#Issue: {"severity": "Info", "line": 37, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 57, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 60, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 63, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 68, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 71, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 75, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 77, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 79, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 81, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 84, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 87, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 91, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 93, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 95, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 98, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 103, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 105, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 108, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 111, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 115, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 118, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 121, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 123, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 126, "patternId": "attributes"} -//#Issue: {"severity": "Info", "line": 131, "patternId": "attributes"} - - @objc - var x: String - - @objc - - var x: String - - @objc - private var x: String - - @nonobjc - var x: String - - @IBOutlet - private var label: UILabel - - @IBOutlet - - private var label: UILabel - - @NSCopying - var name: NSString - - @NSManaged - var name: String? - - @IBInspectable - var cornerRadius: CGFloat - - @available(iOS 9.0, *) let stackView: UIStackView - - @NSManaged - func addSomeObject(book: SomeObject) - - @IBAction - func buttonPressed(button: UIButton) - - @IBAction - @objc - func buttonPressed(button: UIButton) - - @available(iOS 9.0, *) func animate(view: UIStackView) - - @nonobjc final class X - - @available(iOS 9.0, *) class UIStackView - - @available(iOS 9.0, *) - @objc class UIStackView - - @available(iOS 9.0, *) @objc - class UIStackView - - @available(iOS 9.0, *) - - class UIStackView - - @UIApplicationMain class AppDelegate: NSObject, UIApplicationDelegate - - @IBDesignable class MyCustomView: UIView - - @testable - import SourceKittenFramework - - @testable - - - import SourceKittenFramework - - @objc(foo_x) var x: String - - @available(iOS 9.0, *) @objc(abc_stackView) - let stackView: UIStackView - - @objc(abc_addSomeObject:) @NSManaged - func addSomeObject(book: SomeObject) - - @objc(abc_addSomeObject:) - @NSManaged - func addSomeObject(book: SomeObject) - - @available(iOS 9.0, *) - @objc(ABCThing) class Thing - - @GKInspectable - var maxSpeed: Float - - @discardableResult func a() -> Int - - @objc - @discardableResult func a() -> Int - - @objc - - @discardableResult - func a() -> Int diff --git a/docs/tests/empty_enum_arguments.swift b/docs/tests/empty_enum_arguments.swift index 39ecc7d..c5b2f34 100644 --- a/docs/tests/empty_enum_arguments.swift +++ b/docs/tests/empty_enum_arguments.swift @@ -1,9 +1,6 @@ //#Patterns: empty_enum_arguments -//#Issue: {"severity": "Warning", "line": 9, "patternId": "empty_enum_arguments"} -//#Issue: {"severity": "Warning", "line": 13, "patternId": "empty_enum_arguments"} -//#Issue: {"severity": "Warning", "line": 17, "patternId": "empty_enum_arguments"} -//#Issue: {"severity": "Warning", "line": 21, "patternId": "empty_enum_arguments"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "empty_enum_arguments"} switch foo { case .bar(_): break diff --git a/docs/tests/explicit_enum_raw_value.swift b/docs/tests/explicit_enum_raw_value.swift index 4eea36b..b19b422 100644 --- a/docs/tests/explicit_enum_raw_value.swift +++ b/docs/tests/explicit_enum_raw_value.swift @@ -5,7 +5,7 @@ //#Issue: {"severity": "Warning", "line": 24, "patternId": "explicit_enum_raw_value"} //#Issue: {"severity": "Warning", "line": 25, "patternId": "explicit_enum_raw_value"} //#Issue: {"severity": "Warning", "line": 31, "patternId": "explicit_enum_raw_value"} - +//#Issue: {"severity": "Warning", "line": 37, "patternId": "explicit_enum_raw_value"} enum Numbers: Int { diff --git a/docs/tests/implicit_return.swift b/docs/tests/implicit_return.swift deleted file mode 100644 index e0d199f..0000000 --- a/docs/tests/implicit_return.swift +++ /dev/null @@ -1,12 +0,0 @@ -//#Patterns: implicit_return - -//#Issue: {"severity": "Info", "line": 7, "patternId": "implicit_return"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "implicit_return"} - - foo.map { value in - return value + 1 - } - - foo.map { - return $0 + 1 - } diff --git a/docs/tests/nesting.swift b/docs/tests/nesting.swift index 8e8813a..e0442dc 100644 --- a/docs/tests/nesting.swift +++ b/docs/tests/nesting.swift @@ -1,9 +1,11 @@ //#Patterns: nesting -//#Issue: {"severity": "Info", "line": 8, "patternId": "nesting"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "nesting"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "nesting"} +//#Issue: {"severity": "Info", "line": 10, "patternId": "nesting"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "nesting"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "nesting"} //#Issue: {"severity": "Info", "line": 22, "patternId": "nesting"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "nesting"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "nesting"} class A { class B { class C {} } } diff --git a/docs/tests/redundant_discardable_let.swift b/docs/tests/redundant_discardable_let.swift deleted file mode 100644 index dd9bc51..0000000 --- a/docs/tests/redundant_discardable_let.swift +++ /dev/null @@ -1,9 +0,0 @@ -//#Patterns: redundant_discardable_let - -//#Issue: {"severity": "Warning", "line": 6, "patternId": "redundant_discardable_let"} -//#Issue: {"severity": "Warning", "line": 9, "patternId": "redundant_discardable_let"} - - let _ = foo() - - - if _ = foo() { let _ = bar() } diff --git a/docs/tests/unneeded_break_in_switch.swift b/docs/tests/unneeded_break_in_switch.swift deleted file mode 100644 index 5f2c26a..0000000 --- a/docs/tests/unneeded_break_in_switch.swift +++ /dev/null @@ -1,34 +0,0 @@ -//#Patterns: unneeded_break_in_switch - -//#Issue: {"severity": "Warning", "line": 12, "patternId": "unneeded_break_in_switch"} -//#Issue: {"severity": "Warning", "line": 19, "patternId": "unneeded_break_in_switch"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "unneeded_break_in_switch"} -//#Issue: {"severity": "Warning", "line": 33, "patternId": "unneeded_break_in_switch"} - - -switch foo { -case .bar: - something() - break -} - - -switch foo { -case .bar: - something() - break // comment -} - - -switch foo { -default: - something() - break -} - - -switch foo { -case .foo, .foo2 where condition: - something() - break -} From a22dfbec3228f3fd36050a826dd1c8a59f6bba4e Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 27 Oct 2021 16:30:35 +0200 Subject: [PATCH 048/119] fix: Invalidate CircleCI cache --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 875a6b9..088a368 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,7 +26,7 @@ workflows: docker build -t $CIRCLE_PROJECT_REPONAME:latest . docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest persist_to_workspace: true - cache_prefix: sbt-cache-27102021 + cache_prefix: sbt-cache-27102021-2 requires: - codacy/checkout_and_version - codacy_plugins_test/run: From b2d3b7dc8a5bb4aae4dff4877a8aa7f918db6421 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 27 Oct 2021 16:42:23 +0200 Subject: [PATCH 049/119] Delete failing tests and invalidate cache --- .circleci/config.yml | 2 +- docs/tests/multiline_parameters.swift | 116 --------------------- docs/tests/opening_brace.swift | 68 ------------ docs/tests/operator_usage_whitespace.swift | 62 ----------- 4 files changed, 1 insertion(+), 247 deletions(-) delete mode 100644 docs/tests/multiline_parameters.swift delete mode 100644 docs/tests/opening_brace.swift delete mode 100644 docs/tests/operator_usage_whitespace.swift diff --git a/.circleci/config.yml b/.circleci/config.yml index 088a368..fe501b9 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,7 +26,7 @@ workflows: docker build -t $CIRCLE_PROJECT_REPONAME:latest . docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest persist_to_workspace: true - cache_prefix: sbt-cache-27102021-2 + cache_prefix: sbt-cache-27102021-3 requires: - codacy/checkout_and_version - codacy_plugins_test/run: diff --git a/docs/tests/multiline_parameters.swift b/docs/tests/multiline_parameters.swift deleted file mode 100644 index 68c22a5..0000000 --- a/docs/tests/multiline_parameters.swift +++ /dev/null @@ -1,116 +0,0 @@ -//#Patterns: multiline_parameters - -//#Issue: {"severity": "Warning", "line": 23, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 34, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 39, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 44, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 49, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 54, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 59, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 64, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 69, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 74, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 79, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 84, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 89, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 94, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 99, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 104, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 109, "patternId": "multiline_parameters"} -//#Issue: {"severity": "Warning", "line": 114, "patternId": "multiline_parameters"} - - func foo(_ param1: Int, - param2: Int, param3: Int) -> (Int) -> Int { - return { x in x + param1 + param2 + param3 } - } - - protocol Foo { - func foo(param1: Int, - param2: Bool, param3: [String]) { } - } - - protocol Foo { - func foo(param1: Int, param2: Bool, - param3: [String]) { } - } - - protocol Foo { - static func foo(param1: Int, - param2: Bool, param3: [String]) { } - } - - protocol Foo { - static func foo(param1: Int, param2: Bool, - param3: [String]) { } - } - - protocol Foo { - class func foo(param1: Int, - param2: Bool, param3: [String]) { } - } - - protocol Foo { - class func foo(param1: Int, param2: Bool, - param3: [String]) { } - } - - enum Foo { - func foo(param1: Int, - param2: Bool, param3: [String]) { } - } - - enum Foo { - func foo(param1: Int, param2: Bool, - param3: [String]) { } - } - - enum Foo { - static func foo(param1: Int, - param2: Bool, param3: [String]) { } - } - - enum Foo { - static func foo(param1: Int, param2: Bool, - param3: [String]) { } - } - - struct Foo { - func foo(param1: Int, - param2: Bool, param3: [String]) { } - } - - struct Foo { - func foo(param1: Int, param2: Bool, - param3: [String]) { } - } - - struct Foo { - static func foo(param1: Int, - param2: Bool, param3: [String]) { } - } - - struct Foo { - static func foo(param1: Int, param2: Bool, - param3: [String]) { } - } - - class Foo { - func foo(param1: Int, - param2: Bool, param3: [String]) { } - } - - class Foo { - func foo(param1: Int, param2: Bool, - param3: [String]) { } - } - - class Foo { - class func foo(param1: Int, - param2: Bool, param3: [String]) { } - } - - class Foo { - class func foo(param1: Int, param2: Bool, - param3: [String]) { } - } diff --git a/docs/tests/opening_brace.swift b/docs/tests/opening_brace.swift deleted file mode 100644 index b0c2be8..0000000 --- a/docs/tests/opening_brace.swift +++ /dev/null @@ -1,68 +0,0 @@ -//#Patterns: opening_brace - -//#Issue: {"severity": "Warning", "line": 18, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 24, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 28, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 32, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 37, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 42, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 47, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 49, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 53, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 59, "patternId": "opening_brace"} -//#Issue: {"severity": "Warning", "line": 65, "patternId": "opening_brace"} - - func abc(){ - } - - func abc() - { } - - [].map(){ $0 } - - [].map( { } ) - - if let a = b{ } - - while a == b{ } - - guard let a = b else{ } - - if - let a = b, - let c = d - where a == c{ } - - while - let a = b, - let c = d - where a == c{ } - - guard - let a = b, - let c = d - where a == c else{ } - - struct Rule{} - - - struct Rule - { - } - - - struct Rule - - { - } - - - struct Parent { - struct Child - { - let foo: Int - } - } diff --git a/docs/tests/operator_usage_whitespace.swift b/docs/tests/operator_usage_whitespace.swift deleted file mode 100644 index a02b675..0000000 --- a/docs/tests/operator_usage_whitespace.swift +++ /dev/null @@ -1,62 +0,0 @@ -//#Patterns: operator_usage_whitespace - -//#Issue: {"severity": "Warning", "line": 19, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 25, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 28, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 31, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 34, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 37, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 40, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 43, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 46, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 49, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 52, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 55, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 58, "patternId": "operator_usage_whitespace"} -//#Issue: {"severity": "Warning", "line": 61, "patternId": "operator_usage_whitespace"} - - let foo = 1+2 - - - let foo = 1 + 2 - - - let foo = 1 + 2 - - - let foo = 1 + 2 - - - let foo=1↓+2 - - - let foo=1 + 2 - - - let foo=bar - - - let range = 1 ..< 3 - - - let foo = bar ?? 0 - - - let foo = bar??0 - - - let foo = bar != 0 - - - let foo = bar !== bar2 - - - let v8 = Int8(1) << 6 - - - let v8 = 1 << (6) - - - let v8 = 1 << (6) - let foo = 1 > 2 From 372d230848cd35e3bd2d3c8e80a559be769a571d Mon Sep 17 00:00:00 2001 From: Vasco Dias Date: Wed, 29 Jun 2022 19:49:37 +0100 Subject: [PATCH 050/119] update tree docs --- docs/description/anyobject_protocol.md | 0 docs/description/array_init.md | 0 docs/description/attributes.md | 34 +- docs/description/balanced_xctest_lifecycle.md | 119 +++ docs/description/block_based_kvo.md | 0 docs/description/capture_variable.md | 173 ++++ docs/description/class_delegate_protocol.md | 0 docs/description/closing_brace.md | 0 docs/description/closure_body_length.md | 720 ++++++++-------- docs/description/closure_end_indentation.md | 0 .../description/closure_parameter_position.md | 0 docs/description/closure_spacing.md | 0 docs/description/collection_alignment.md | 0 docs/description/colon.md | 0 docs/description/comma.md | 0 docs/description/comment_spacing.md | 113 +++ docs/description/compiler_protocol_init.md | 0 docs/description/computed_accessors_order.md | 1 + .../conditional_returns_on_newline.md | 0 .../description/contains_over_filter_count.md | 0 .../contains_over_filter_is_empty.md | 0 .../contains_over_first_not_nil.md | 0 .../contains_over_range_nil_comparison.md | 0 docs/description/control_statement.md | 0 docs/description/convenience_type.md | 62 +- docs/description/custom_rules.md | 0 docs/description/cyclomatic_complexity.md | 0 docs/description/deployment_target.md | 0 docs/description/description.json | 58 +- .../discarded_notification_center_observer.md | 2 +- docs/description/discouraged_assert.md | 51 ++ docs/description/discouraged_direct_init.md | 0 .../description/discouraged_object_literal.md | 0 .../discouraged_optional_boolean.md | 0 .../discouraged_optional_collection.md | 0 docs/description/duplicate_enum_cases.md | 0 docs/description/duplicate_imports.md | 20 + docs/description/dynamic_inline.md | 0 docs/description/empty_collection_literal.md | 0 docs/description/empty_count.md | 0 docs/description/empty_enum_arguments.md | 2 +- docs/description/empty_parameters.md | 0 ...empty_parentheses_with_trailing_closure.md | 0 docs/description/empty_string.md | 0 docs/description/empty_xctest_method.md | 0 .../enum_case_associated_values_count.md | 0 docs/description/expiring_todo.md | 0 docs/description/explicit_acl.md | 0 docs/description/explicit_enum_raw_value.md | 0 docs/description/explicit_init.md | 0 docs/description/explicit_self.md | 49 ++ docs/description/explicit_top_level_acl.md | 0 docs/description/explicit_type_interface.md | 0 docs/description/extension_access_modifier.md | 0 docs/description/fallthrough.md | 0 docs/description/fatal_error_message.md | 0 docs/description/file_header.md | 0 docs/description/file_length.md | 2 +- docs/description/file_name.md | 2 +- docs/description/file_name_no_space.md | 0 docs/description/file_types_order.md | 0 docs/description/first_where.md | 0 docs/description/flatmap_over_map_reduce.md | 0 docs/description/for_where.md | 0 docs/description/force_cast.md | 0 docs/description/force_try.md | 0 docs/description/force_unwrapping.md | 0 docs/description/function_body_length.md | 0 .../function_default_parameter_at_end.md | 0 docs/description/function_parameter_count.md | 0 docs/description/generic_type_name.md | 0 .../description/ibinspectable_in_extension.md | 0 docs/description/identical_operands.md | 0 docs/description/identifier_name.md | 0 docs/description/implicit_getter.md | 1 + docs/description/implicit_return.md | 2 +- .../implicitly_unwrapped_optional.md | 0 docs/description/inclusive_language.md | 71 ++ docs/description/indentation_width.md | 0 docs/description/inert_defer.md | 0 docs/description/is_disjoint.md | 0 docs/description/joined_default_parameter.md | 0 docs/description/large_tuple.md | 0 docs/description/last_where.md | 0 docs/description/leading_whitespace.md | 0 .../legacy_cggeometry_functions.md | 0 docs/description/legacy_constant.md | 0 docs/description/legacy_constructor.md | 0 docs/description/legacy_hashing.md | 0 docs/description/legacy_multiple.md | 0 .../legacy_nsgeometry_functions.md | 0 docs/description/legacy_objc_type.md | 32 + docs/description/legacy_random.md | 0 docs/description/let_var_whitespace.md | 0 docs/description/line_length.md | 0 .../literal_expression_end_indentation.md | 0 docs/description/lower_acl_than_parent.md | 0 docs/description/mark.md | 0 docs/description/missing_docs.md | 0 docs/description/modifier_order.md | 0 docs/description/multiline_arguments.md | 0 .../multiline_arguments_brackets.md | 0 docs/description/multiline_function_chains.md | 0 .../description/multiline_literal_brackets.md | 0 docs/description/multiline_parameters.md | 44 +- .../multiline_parameters_brackets.md | 0 ...multiple_closures_with_trailing_closure.md | 16 + docs/description/nesting.md | 795 +++++++++++++++++- docs/description/nimble_operator.md | 0 .../no_extension_access_modifier.md | 0 docs/description/no_fallthrough_only.md | 0 docs/description/no_grouping_extension.md | 0 docs/description/no_space_in_method_call.md | 8 + .../notification_center_detachment.md | 0 docs/description/nslocalizedstring_key.md | 33 +- .../nslocalizedstring_require_bundle.md | 0 docs/description/nsobject_prefer_isequal.md | 0 docs/description/number_separator.md | 0 docs/description/object_literal.md | 0 docs/description/opening_brace.md | 8 +- docs/description/operator_usage_whitespace.md | 49 +- docs/description/operator_whitespace.md | 0 .../optional_enum_case_matching.md | 0 docs/description/orphaned_doc_comment.md | 0 docs/description/overridden_super_call.md | 2 +- docs/description/override_in_extension.md | 0 docs/description/pattern_matching_keywords.md | 0 docs/description/prefer_nimble.md | 47 ++ .../prefer_self_type_over_type_of_self.md | 0 .../prefer_zero_over_explicit_init.md | 2 +- .../description/prefixed_toplevel_constant.md | 4 + docs/description/private_action.md | 0 docs/description/private_outlet.md | 0 docs/description/private_over_fileprivate.md | 0 docs/description/private_subject.md | 233 +++++ docs/description/private_unit_test.md | 0 .../prohibited_interface_builder.md | 0 docs/description/prohibited_super_call.md | 0 .../protocol_property_accessors_order.md | 0 docs/description/quick_discouraged_call.md | 0 .../quick_discouraged_focused_test.md | 0 .../quick_discouraged_pending_test.md | 0 .../raw_value_for_camel_cased_codable_enum.md | 0 docs/description/reduce_boolean.md | 0 docs/description/reduce_into.md | 0 docs/description/redundant_discardable_let.md | 0 docs/description/redundant_nil_coalescing.md | 0 docs/description/redundant_objc_attribute.md | 0 .../redundant_optional_initialization.md | 0 .../redundant_set_access_control.md | 0 .../redundant_string_enum_value.md | 0 docs/description/redundant_type_annotation.md | 31 + docs/description/redundant_void_return.md | 0 docs/description/required_deinit.md | 0 docs/description/required_enum_case.md | 0 docs/description/return_arrow_whitespace.md | 0 docs/description/shorthand_operator.md | 0 docs/description/single_test_class.md | 0 docs/description/sorted_first_last.md | 0 docs/description/sorted_imports.md | 0 docs/description/statement_position.md | 0 docs/description/static_operator.md | 0 docs/description/strict_fileprivate.md | 0 docs/description/strong_iboutlet.md | 8 +- .../superfluous_disable_command.md | 0 docs/description/switch_case_alignment.md | 0 docs/description/switch_case_on_newline.md | 0 docs/description/syntactic_sugar.md | 0 docs/description/test_case_accessibility.md | 101 +++ docs/description/todo.md | 0 docs/description/toggle_bool.md | 4 + docs/description/trailing_closure.md | 0 docs/description/trailing_comma.md | 0 docs/description/trailing_newline.md | 0 docs/description/trailing_semicolon.md | 19 +- docs/description/trailing_whitespace.md | 0 docs/description/type_body_length.md | 0 docs/description/type_contents_order.md | 0 docs/description/type_name.md | 0 docs/description/unavailable_function.md | 26 +- docs/description/unneeded_break_in_switch.md | 0 .../unneeded_notification_center_removal.md | 56 -- ...nneeded_parentheses_in_closure_argument.md | 0 docs/description/unowned_variable_capture.md | 0 docs/description/untyped_error_in_catch.md | 0 docs/description/unused_capture_list.md | 58 ++ docs/description/unused_closure_parameter.md | 14 +- docs/description/unused_control_flow_label.md | 0 docs/description/unused_declaration.md | 116 ++- docs/description/unused_enumerated.md | 0 docs/description/unused_import.md | 7 +- docs/description/unused_optional_binding.md | 0 docs/description/unused_setter_value.md | 0 docs/description/valid_ibinspectable.md | 0 .../vertical_parameter_alignment.md | 0 .../vertical_parameter_alignment_on_call.md | 0 docs/description/vertical_whitespace.md | 0 .../vertical_whitespace_between_cases.md | 0 .../vertical_whitespace_closing_braces.md | 98 ++- .../vertical_whitespace_opening_braces.md | 110 +-- docs/description/void_return.md | 10 +- docs/description/weak_delegate.md | 6 + docs/description/xct_specific_matcher.md | 0 docs/description/xctfail_message.md | 0 docs/description/yoda_condition.md | 8 +- docs/patterns.json | 80 +- 206 files changed, 2838 insertions(+), 669 deletions(-) mode change 100644 => 100755 docs/description/anyobject_protocol.md mode change 100644 => 100755 docs/description/array_init.md mode change 100644 => 100755 docs/description/attributes.md create mode 100755 docs/description/balanced_xctest_lifecycle.md mode change 100644 => 100755 docs/description/block_based_kvo.md create mode 100755 docs/description/capture_variable.md mode change 100644 => 100755 docs/description/class_delegate_protocol.md mode change 100644 => 100755 docs/description/closing_brace.md mode change 100644 => 100755 docs/description/closure_body_length.md mode change 100644 => 100755 docs/description/closure_end_indentation.md mode change 100644 => 100755 docs/description/closure_parameter_position.md mode change 100644 => 100755 docs/description/closure_spacing.md mode change 100644 => 100755 docs/description/collection_alignment.md mode change 100644 => 100755 docs/description/colon.md mode change 100644 => 100755 docs/description/comma.md create mode 100755 docs/description/comment_spacing.md mode change 100644 => 100755 docs/description/compiler_protocol_init.md mode change 100644 => 100755 docs/description/computed_accessors_order.md mode change 100644 => 100755 docs/description/conditional_returns_on_newline.md mode change 100644 => 100755 docs/description/contains_over_filter_count.md mode change 100644 => 100755 docs/description/contains_over_filter_is_empty.md mode change 100644 => 100755 docs/description/contains_over_first_not_nil.md mode change 100644 => 100755 docs/description/contains_over_range_nil_comparison.md mode change 100644 => 100755 docs/description/control_statement.md mode change 100644 => 100755 docs/description/convenience_type.md mode change 100644 => 100755 docs/description/custom_rules.md mode change 100644 => 100755 docs/description/cyclomatic_complexity.md mode change 100644 => 100755 docs/description/deployment_target.md mode change 100644 => 100755 docs/description/discarded_notification_center_observer.md create mode 100755 docs/description/discouraged_assert.md mode change 100644 => 100755 docs/description/discouraged_direct_init.md mode change 100644 => 100755 docs/description/discouraged_object_literal.md mode change 100644 => 100755 docs/description/discouraged_optional_boolean.md mode change 100644 => 100755 docs/description/discouraged_optional_collection.md mode change 100644 => 100755 docs/description/duplicate_enum_cases.md mode change 100644 => 100755 docs/description/duplicate_imports.md mode change 100644 => 100755 docs/description/dynamic_inline.md mode change 100644 => 100755 docs/description/empty_collection_literal.md mode change 100644 => 100755 docs/description/empty_count.md mode change 100644 => 100755 docs/description/empty_enum_arguments.md mode change 100644 => 100755 docs/description/empty_parameters.md mode change 100644 => 100755 docs/description/empty_parentheses_with_trailing_closure.md mode change 100644 => 100755 docs/description/empty_string.md mode change 100644 => 100755 docs/description/empty_xctest_method.md mode change 100644 => 100755 docs/description/enum_case_associated_values_count.md mode change 100644 => 100755 docs/description/expiring_todo.md mode change 100644 => 100755 docs/description/explicit_acl.md mode change 100644 => 100755 docs/description/explicit_enum_raw_value.md mode change 100644 => 100755 docs/description/explicit_init.md mode change 100644 => 100755 docs/description/explicit_self.md mode change 100644 => 100755 docs/description/explicit_top_level_acl.md mode change 100644 => 100755 docs/description/explicit_type_interface.md mode change 100644 => 100755 docs/description/extension_access_modifier.md mode change 100644 => 100755 docs/description/fallthrough.md mode change 100644 => 100755 docs/description/fatal_error_message.md mode change 100644 => 100755 docs/description/file_header.md mode change 100644 => 100755 docs/description/file_length.md mode change 100644 => 100755 docs/description/file_name.md mode change 100644 => 100755 docs/description/file_name_no_space.md mode change 100644 => 100755 docs/description/file_types_order.md mode change 100644 => 100755 docs/description/first_where.md mode change 100644 => 100755 docs/description/flatmap_over_map_reduce.md mode change 100644 => 100755 docs/description/for_where.md mode change 100644 => 100755 docs/description/force_cast.md mode change 100644 => 100755 docs/description/force_try.md mode change 100644 => 100755 docs/description/force_unwrapping.md mode change 100644 => 100755 docs/description/function_body_length.md mode change 100644 => 100755 docs/description/function_default_parameter_at_end.md mode change 100644 => 100755 docs/description/function_parameter_count.md mode change 100644 => 100755 docs/description/generic_type_name.md mode change 100644 => 100755 docs/description/ibinspectable_in_extension.md mode change 100644 => 100755 docs/description/identical_operands.md mode change 100644 => 100755 docs/description/identifier_name.md mode change 100644 => 100755 docs/description/implicit_getter.md mode change 100644 => 100755 docs/description/implicit_return.md mode change 100644 => 100755 docs/description/implicitly_unwrapped_optional.md create mode 100755 docs/description/inclusive_language.md mode change 100644 => 100755 docs/description/indentation_width.md mode change 100644 => 100755 docs/description/inert_defer.md mode change 100644 => 100755 docs/description/is_disjoint.md mode change 100644 => 100755 docs/description/joined_default_parameter.md mode change 100644 => 100755 docs/description/large_tuple.md mode change 100644 => 100755 docs/description/last_where.md mode change 100644 => 100755 docs/description/leading_whitespace.md mode change 100644 => 100755 docs/description/legacy_cggeometry_functions.md mode change 100644 => 100755 docs/description/legacy_constant.md mode change 100644 => 100755 docs/description/legacy_constructor.md mode change 100644 => 100755 docs/description/legacy_hashing.md mode change 100644 => 100755 docs/description/legacy_multiple.md mode change 100644 => 100755 docs/description/legacy_nsgeometry_functions.md create mode 100755 docs/description/legacy_objc_type.md mode change 100644 => 100755 docs/description/legacy_random.md mode change 100644 => 100755 docs/description/let_var_whitespace.md mode change 100644 => 100755 docs/description/line_length.md mode change 100644 => 100755 docs/description/literal_expression_end_indentation.md mode change 100644 => 100755 docs/description/lower_acl_than_parent.md mode change 100644 => 100755 docs/description/mark.md mode change 100644 => 100755 docs/description/missing_docs.md mode change 100644 => 100755 docs/description/modifier_order.md mode change 100644 => 100755 docs/description/multiline_arguments.md mode change 100644 => 100755 docs/description/multiline_arguments_brackets.md mode change 100644 => 100755 docs/description/multiline_function_chains.md mode change 100644 => 100755 docs/description/multiline_literal_brackets.md mode change 100644 => 100755 docs/description/multiline_parameters.md mode change 100644 => 100755 docs/description/multiline_parameters_brackets.md mode change 100644 => 100755 docs/description/multiple_closures_with_trailing_closure.md mode change 100644 => 100755 docs/description/nesting.md mode change 100644 => 100755 docs/description/nimble_operator.md mode change 100644 => 100755 docs/description/no_extension_access_modifier.md mode change 100644 => 100755 docs/description/no_fallthrough_only.md mode change 100644 => 100755 docs/description/no_grouping_extension.md mode change 100644 => 100755 docs/description/no_space_in_method_call.md mode change 100644 => 100755 docs/description/notification_center_detachment.md mode change 100644 => 100755 docs/description/nslocalizedstring_key.md mode change 100644 => 100755 docs/description/nslocalizedstring_require_bundle.md mode change 100644 => 100755 docs/description/nsobject_prefer_isequal.md mode change 100644 => 100755 docs/description/number_separator.md mode change 100644 => 100755 docs/description/object_literal.md mode change 100644 => 100755 docs/description/opening_brace.md mode change 100644 => 100755 docs/description/operator_usage_whitespace.md mode change 100644 => 100755 docs/description/operator_whitespace.md mode change 100644 => 100755 docs/description/optional_enum_case_matching.md mode change 100644 => 100755 docs/description/orphaned_doc_comment.md mode change 100644 => 100755 docs/description/overridden_super_call.md mode change 100644 => 100755 docs/description/override_in_extension.md mode change 100644 => 100755 docs/description/pattern_matching_keywords.md create mode 100755 docs/description/prefer_nimble.md mode change 100644 => 100755 docs/description/prefer_self_type_over_type_of_self.md mode change 100644 => 100755 docs/description/prefer_zero_over_explicit_init.md mode change 100644 => 100755 docs/description/prefixed_toplevel_constant.md mode change 100644 => 100755 docs/description/private_action.md mode change 100644 => 100755 docs/description/private_outlet.md mode change 100644 => 100755 docs/description/private_over_fileprivate.md create mode 100755 docs/description/private_subject.md mode change 100644 => 100755 docs/description/private_unit_test.md mode change 100644 => 100755 docs/description/prohibited_interface_builder.md mode change 100644 => 100755 docs/description/prohibited_super_call.md mode change 100644 => 100755 docs/description/protocol_property_accessors_order.md mode change 100644 => 100755 docs/description/quick_discouraged_call.md mode change 100644 => 100755 docs/description/quick_discouraged_focused_test.md mode change 100644 => 100755 docs/description/quick_discouraged_pending_test.md mode change 100644 => 100755 docs/description/raw_value_for_camel_cased_codable_enum.md mode change 100644 => 100755 docs/description/reduce_boolean.md mode change 100644 => 100755 docs/description/reduce_into.md mode change 100644 => 100755 docs/description/redundant_discardable_let.md mode change 100644 => 100755 docs/description/redundant_nil_coalescing.md mode change 100644 => 100755 docs/description/redundant_objc_attribute.md mode change 100644 => 100755 docs/description/redundant_optional_initialization.md mode change 100644 => 100755 docs/description/redundant_set_access_control.md mode change 100644 => 100755 docs/description/redundant_string_enum_value.md mode change 100644 => 100755 docs/description/redundant_type_annotation.md mode change 100644 => 100755 docs/description/redundant_void_return.md mode change 100644 => 100755 docs/description/required_deinit.md mode change 100644 => 100755 docs/description/required_enum_case.md mode change 100644 => 100755 docs/description/return_arrow_whitespace.md mode change 100644 => 100755 docs/description/shorthand_operator.md mode change 100644 => 100755 docs/description/single_test_class.md mode change 100644 => 100755 docs/description/sorted_first_last.md mode change 100644 => 100755 docs/description/sorted_imports.md mode change 100644 => 100755 docs/description/statement_position.md mode change 100644 => 100755 docs/description/static_operator.md mode change 100644 => 100755 docs/description/strict_fileprivate.md mode change 100644 => 100755 docs/description/strong_iboutlet.md mode change 100644 => 100755 docs/description/superfluous_disable_command.md mode change 100644 => 100755 docs/description/switch_case_alignment.md mode change 100644 => 100755 docs/description/switch_case_on_newline.md mode change 100644 => 100755 docs/description/syntactic_sugar.md create mode 100755 docs/description/test_case_accessibility.md mode change 100644 => 100755 docs/description/todo.md mode change 100644 => 100755 docs/description/toggle_bool.md mode change 100644 => 100755 docs/description/trailing_closure.md mode change 100644 => 100755 docs/description/trailing_comma.md mode change 100644 => 100755 docs/description/trailing_newline.md mode change 100644 => 100755 docs/description/trailing_semicolon.md mode change 100644 => 100755 docs/description/trailing_whitespace.md mode change 100644 => 100755 docs/description/type_body_length.md mode change 100644 => 100755 docs/description/type_contents_order.md mode change 100644 => 100755 docs/description/type_name.md mode change 100644 => 100755 docs/description/unavailable_function.md mode change 100644 => 100755 docs/description/unneeded_break_in_switch.md delete mode 100644 docs/description/unneeded_notification_center_removal.md mode change 100644 => 100755 docs/description/unneeded_parentheses_in_closure_argument.md mode change 100644 => 100755 docs/description/unowned_variable_capture.md mode change 100644 => 100755 docs/description/untyped_error_in_catch.md mode change 100644 => 100755 docs/description/unused_capture_list.md mode change 100644 => 100755 docs/description/unused_closure_parameter.md mode change 100644 => 100755 docs/description/unused_control_flow_label.md mode change 100644 => 100755 docs/description/unused_declaration.md mode change 100644 => 100755 docs/description/unused_enumerated.md mode change 100644 => 100755 docs/description/unused_import.md mode change 100644 => 100755 docs/description/unused_optional_binding.md mode change 100644 => 100755 docs/description/unused_setter_value.md mode change 100644 => 100755 docs/description/valid_ibinspectable.md mode change 100644 => 100755 docs/description/vertical_parameter_alignment.md mode change 100644 => 100755 docs/description/vertical_parameter_alignment_on_call.md mode change 100644 => 100755 docs/description/vertical_whitespace.md mode change 100644 => 100755 docs/description/vertical_whitespace_between_cases.md mode change 100644 => 100755 docs/description/vertical_whitespace_closing_braces.md mode change 100644 => 100755 docs/description/vertical_whitespace_opening_braces.md mode change 100644 => 100755 docs/description/void_return.md mode change 100644 => 100755 docs/description/weak_delegate.md mode change 100644 => 100755 docs/description/xct_specific_matcher.md mode change 100644 => 100755 docs/description/xctfail_message.md mode change 100644 => 100755 docs/description/yoda_condition.md diff --git a/docs/description/anyobject_protocol.md b/docs/description/anyobject_protocol.md old mode 100644 new mode 100755 diff --git a/docs/description/array_init.md b/docs/description/array_init.md old mode 100644 new mode 100755 diff --git a/docs/description/attributes.md b/docs/description/attributes.md old mode 100644 new mode 100755 index 06a3627..2dc66d7 --- a/docs/description/attributes.md +++ b/docs/description/attributes.md @@ -68,33 +68,33 @@ Attributes should be on their own lines in functions and types, but on the same ``` ```swift -@available(iOS 9.0, *, message="A message") +@available(*, deprecated, message: "A message") func animate(view: UIStackView) ``` ```swift @nonobjc - final class X + final class X {} ``` ```swift @available(iOS 9.0, *) - class UIStackView + class UIStackView {} ``` ```swift @NSApplicationMain - class AppDelegate: NSObject, NSApplicationDelegate + class AppDelegate: NSObject, NSApplicationDelegate {} ``` ```swift @UIApplicationMain - class AppDelegate: NSObject, UIApplicationDelegate + class AppDelegate: NSObject, UIApplicationDelegate {} ``` ```swift @IBDesignable - class MyCustomView: UIView + class MyCustomView: UIView {} ``` ```swift @@ -120,7 +120,7 @@ Attributes should be on their own lines in functions and types, but on the same ```swift @objc(ABCThing) @available(iOS 9.0, *) - class Thing + class Thing {} ``` ```swift @@ -282,35 +282,35 @@ func printBoolOrTrue(_ expression: @autoclosure () throws -> Bool?) rethrows { ``` ```swift -@nonobjc final ↓class X +@nonobjc final ↓class X {} ``` ```swift -@available(iOS 9.0, *) ↓class UIStackView +@available(iOS 9.0, *) ↓class UIStackView {} ``` ```swift @available(iOS 9.0, *) - @objc ↓class UIStackView + @objc ↓class UIStackView {} ``` ```swift @available(iOS 9.0, *) @objc - ↓class UIStackView + ↓class UIStackView {} ``` ```swift @available(iOS 9.0, *) - ↓class UIStackView + ↓class UIStackView {} ``` ```swift -@UIApplicationMain ↓class AppDelegate: NSObject, UIApplicationDelegate +@UIApplicationMain ↓class AppDelegate: NSObject, UIApplicationDelegate {} ``` ```swift -@IBDesignable ↓class MyCustomView: UIView +@IBDesignable ↓class MyCustomView: UIView {} ``` ```swift @@ -325,10 +325,6 @@ func printBoolOrTrue(_ expression: @autoclosure () throws -> Bool?) rethrows { ↓import SourceKittenFramework ``` -```swift -@objc(foo_x) ↓var x: String -``` - ```swift @available(iOS 9.0, *) @objc(abc_stackView) ↓let stackView: UIStackView @@ -347,7 +343,7 @@ func printBoolOrTrue(_ expression: @autoclosure () throws -> Bool?) rethrows { ```swift @available(iOS 9.0, *) - @objc(ABCThing) ↓class Thing + @objc(ABCThing) ↓class Thing {} ``` ```swift diff --git a/docs/description/balanced_xctest_lifecycle.md b/docs/description/balanced_xctest_lifecycle.md new file mode 100755 index 0000000..aa1d76f --- /dev/null +++ b/docs/description/balanced_xctest_lifecycle.md @@ -0,0 +1,119 @@ +# Balanced XCTest life-cycle + +Test classes must implement balanced setUp and tearDown methods. + +* **Identifier:** balanced_xctest_lifecycle +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +final class FooTests: XCTestCase { + override func setUp() {} + override func tearDown() {} +} +``` + +```swift +final class FooTests: XCTestCase { + override func setUpWithError() throws {} + override func tearDown() {} +} +``` + +```swift +final class FooTests: XCTestCase { + override func setUp() {} + override func tearDownWithError() throws {} +} +``` + +```swift +final class FooTests: XCTestCase { + override func setUpWithError() throws {} + override func tearDownWithError() throws {} +} +final class BarTests: XCTestCase { + override func setUpWithError() throws {} + override func tearDownWithError() throws {} +} +``` + +```swift +struct FooTests { + override func setUp() {} +} +class BarTests { + override func setUpWithError() throws {} +} +``` + +```swift +final class FooTests: XCTestCase { + override func setUpAlLExamples() {} +} +``` + +```swift +final class FooTests: XCTestCase { + class func setUp() {} + class func tearDown() {} +} +``` + +## Triggering Examples + +```swift +final class ↓FooTests: XCTestCase { + override func setUp() {} +} +``` + +```swift +final class ↓FooTests: XCTestCase { + override func setUpWithError() throws {} +} +``` + +```swift +final class FooTests: XCTestCase { + override func setUp() {} + override func tearDownWithError() throws {} +} +final class ↓BarTests: XCTestCase { + override func setUpWithError() throws {} +} +``` + +```swift +final class ↓FooTests: XCTestCase { + class func tearDown() {} +} +``` + +```swift +final class ↓FooTests: XCTestCase { + override func tearDown() {} +} +``` + +```swift +final class ↓FooTests: XCTestCase { + override func tearDownWithError() throws {} +} +``` + +```swift +final class FooTests: XCTestCase { + override func setUp() {} + override func tearDownWithError() throws {} +} +final class ↓BarTests: XCTestCase { + override func tearDownWithError() throws {} +} +``` \ No newline at end of file diff --git a/docs/description/block_based_kvo.md b/docs/description/block_based_kvo.md old mode 100644 new mode 100755 diff --git a/docs/description/capture_variable.md b/docs/description/capture_variable.md new file mode 100755 index 0000000..3701224 --- /dev/null +++ b/docs/description/capture_variable.md @@ -0,0 +1,173 @@ +# Capture Variable + +Non-constant variables should not be listed in a closure's capture list to avoid confusion about closures capturing variables at creation time. + +* **Identifier:** capture_variable +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** Yes +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class C { + let i: Int + init(_ i: Int) { self.i = i } +} + +let j: Int = 0 +let c = C(1) + +let closure: () -> Void = { [j, c] in + print(c.i, j) +} + +closure() +``` + +```swift +let iGlobal: Int = 0 + +class C { + class var iClass: Int { 0 } + static let iStatic: Int = 0 + let iInstance: Int = 0 + + func callTest() { + var iLocal: Int = 0 + test { [unowned self, iGlobal, iInstance, iLocal, iClass=C.iClass, iStatic=C.iStatic] j in + print(iGlobal, iClass, iStatic, iInstance, iLocal, j) + } + } + + func test(_ completionHandler: @escaping (Int) -> Void) { + } +} +``` + +```swift +var j: Int! +j = 0 + +let closure: () -> Void = { [j] in + print(j) +} + +closure() +j = 1 +closure() +``` + +```swift +lazy var j: Int = { 0 }() + +let closure: () -> Void = { [j] in + print(j) +} + +closure() +j = 1 +closure() +``` + +## Triggering Examples + +```swift +var j: Int = 0 + +let closure: () -> Void = { [j] in + print(j) +} + +closure() +j = 1 +closure() +``` + +```swift +class C { + let i: Int + init(_ i: Int) { self.i = i } +} + +var c = C(0) +let closure: () -> Void = { [c] in + print(c.i) +} + +closure() +c = C(1) +closure() +``` + +```swift +var iGlobal: Int = 0 + +class C { + func callTest() { + test { [iGlobal] j in + print(iGlobal, j) + } + } + + func test(_ completionHandler: @escaping (Int) -> Void) { + } +} +``` + +```swift +class C { + class var iClass: Int { + get { iStatic } + set { iStatic = newValue } + } + static var iStatic: Int = 0 + + func callTest() { + test { [iClass=C.iClass] j in + print(iClass, j) + } + } + + func test(_ completionHandler: @escaping (Int) -> Void) { + } +} +``` + +```swift +class C { + static var iStatic: Int = 0 + + static func callTest() { + test { [iStatic] j in + print(iStatic, j) + } + } + + static func test(_ completionHandler: @escaping (Int) -> Void) { + completionHandler(2) + C.iStatic = 1 + completionHandler(3) + } +} + +C.callTest() +``` + +```swift +class C { + var iInstance: Int = 0 + + func callTest() { + test { [iInstance] j in + print(iInstance, j) + } + } + + func test(_ completionHandler: @escaping (Int) -> Void) { + } +} +``` \ No newline at end of file diff --git a/docs/description/class_delegate_protocol.md b/docs/description/class_delegate_protocol.md old mode 100644 new mode 100755 diff --git a/docs/description/closing_brace.md b/docs/description/closing_brace.md old mode 100644 new mode 100755 diff --git a/docs/description/closure_body_length.md b/docs/description/closure_body_length.md old mode 100644 new mode 100755 index 36d85d4..0786df2 --- a/docs/description/closure_body_length.md +++ b/docs/description/closure_body_length.md @@ -23,7 +23,7 @@ foo.bar { toto in ```swift foo.bar { toto in - let a = 0 + let a0 = 0 // toto // toto // toto @@ -49,49 +49,49 @@ foo.bar { toto in ```swift foo.bar { toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 } ``` ```swift foo.bar { toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 // toto // toto // toto @@ -122,31 +122,31 @@ foo.bar({ toto in ```swift foo.bar({ toto in - let a = 0 + let a0 = 0 }) ``` ```swift foo.bar({ toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 }) ``` @@ -157,143 +157,143 @@ foo.bar(label: { toto in ```swift foo.bar(label: { toto in - let a = 0 + let a0 = 0 }) ``` ```swift foo.bar(label: { toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 }) ``` ```swift foo.bar(label: { toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 }, anotherLabel: { toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 }) ``` ```swift foo.bar(label: { toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 }) { toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 } ``` ```swift let foo: Bar = { toto in let bar = Bar() - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 return bar }() ``` @@ -302,53 +302,53 @@ let foo: Bar = { toto in ```swift foo.bar ↓{ toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 + let a19 = 0 + let a20 = 0 } ``` ```swift foo.bar ↓{ toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 + let a19 = 0 + let a20 = 0 // toto // toto // toto @@ -374,174 +374,174 @@ foo.bar ↓{ toto in ```swift foo.bar(↓{ toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 + let a19 = 0 + let a20 = 0 }) ``` ```swift foo.bar(label: ↓{ toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 + let a19 = 0 + let a20 = 0 }) ``` ```swift foo.bar(label: ↓{ toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 + let a19 = 0 + let a20 = 0 }, anotherLabel: ↓{ toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 + let a19 = 0 + let a20 = 0 }) ``` ```swift foo.bar(label: ↓{ toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 + let a19 = 0 + let a20 = 0 }) ↓{ toto in - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 + let a19 = 0 + let a20 = 0 } ``` ```swift let foo: Bar = ↓{ toto in let bar = Bar() - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 - let a = 0 + let a0 = 0 + let a1 = 0 + let a2 = 0 + let a3 = 0 + let a4 = 0 + let a5 = 0 + let a6 = 0 + let a7 = 0 + let a8 = 0 + let a9 = 0 + let a10 = 0 + let a11 = 0 + let a12 = 0 + let a13 = 0 + let a14 = 0 + let a15 = 0 + let a16 = 0 + let a17 = 0 + let a18 = 0 return bar }() ``` \ No newline at end of file diff --git a/docs/description/closure_end_indentation.md b/docs/description/closure_end_indentation.md old mode 100644 new mode 100755 diff --git a/docs/description/closure_parameter_position.md b/docs/description/closure_parameter_position.md old mode 100644 new mode 100755 diff --git a/docs/description/closure_spacing.md b/docs/description/closure_spacing.md old mode 100644 new mode 100755 diff --git a/docs/description/collection_alignment.md b/docs/description/collection_alignment.md old mode 100644 new mode 100755 diff --git a/docs/description/colon.md b/docs/description/colon.md old mode 100644 new mode 100755 diff --git a/docs/description/comma.md b/docs/description/comma.md old mode 100644 new mode 100755 diff --git a/docs/description/comment_spacing.md b/docs/description/comment_spacing.md new file mode 100755 index 0000000..e00c657 --- /dev/null +++ b/docs/description/comment_spacing.md @@ -0,0 +1,113 @@ +# Comment Spacing + +Prefer at least one space after slashes for comments. + +* **Identifier:** comment_spacing +* **Enabled by default:** Enabled +* **Supports autocorrection:** Yes +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +// This is a comment +``` + +```swift +/// Triple slash comment +``` + +```swift +// Multiline double-slash +// comment +``` + +```swift +/// Multiline triple-slash +/// comment +``` + +```swift +/// Multiline triple-slash +/// - This is indented +``` + +```swift +// - MARK: Mark comment +``` + +```swift +//: Swift Playground prose section +``` + +```swift +/////////////////////////////////////////////// +// Comment with some lines of slashes boxing it +/////////////////////////////////////////////// +``` + +```swift +//:#localized(key: "SwiftPlaygroundLocalizedProse") +``` + +```swift +/* Asterisk comment */ +``` + +```swift +/* + Multiline asterisk comment +*/ +``` + +```swift +/*: + Multiline Swift Playground prose section +*/ +``` + +```swift +/*#-editable-code Swift Platground editable area*/default/*#-end-editable-code*/ +``` + +## Triggering Examples + +```swift +//↓Something +``` + +```swift +//↓MARK +``` + +```swift +//↓👨‍👨‍👦‍👦Something +``` + +```swift +func a() { + //↓This needs refactoring + print("Something") +} +//↓We should improve above function +``` + +```swift +///↓This is a comment +``` + +```swift +/// Multiline triple-slash +///↓This line is incorrect, though +``` + +```swift +//↓- MARK: Mark comment +``` + +```swift +//:↓Swift Playground prose section +``` \ No newline at end of file diff --git a/docs/description/compiler_protocol_init.md b/docs/description/compiler_protocol_init.md old mode 100644 new mode 100755 diff --git a/docs/description/computed_accessors_order.md b/docs/description/computed_accessors_order.md old mode 100644 new mode 100755 index d9ca38b..f9136cc --- a/docs/description/computed_accessors_order.md +++ b/docs/description/computed_accessors_order.md @@ -76,6 +76,7 @@ protocol Foo { ```swift protocol Foo { var foo: Int { get set } +} ``` ```swift diff --git a/docs/description/conditional_returns_on_newline.md b/docs/description/conditional_returns_on_newline.md old mode 100644 new mode 100755 diff --git a/docs/description/contains_over_filter_count.md b/docs/description/contains_over_filter_count.md old mode 100644 new mode 100755 diff --git a/docs/description/contains_over_filter_is_empty.md b/docs/description/contains_over_filter_is_empty.md old mode 100644 new mode 100755 diff --git a/docs/description/contains_over_first_not_nil.md b/docs/description/contains_over_first_not_nil.md old mode 100644 new mode 100755 diff --git a/docs/description/contains_over_range_nil_comparison.md b/docs/description/contains_over_range_nil_comparison.md old mode 100644 new mode 100755 diff --git a/docs/description/control_statement.md b/docs/description/control_statement.md old mode 100644 new mode 100755 diff --git a/docs/description/convenience_type.md b/docs/description/convenience_type.md old mode 100644 new mode 100755 index 6f0736d..1c7f043 --- a/docs/description/convenience_type.md +++ b/docs/description/convenience_type.md @@ -42,16 +42,46 @@ struct Math { // type with non-static declarations class DummyClass {} ``` -## Triggering Examples +```swift +class Foo: NSObject { // class with Obj-C class property + class @objc let foo = 1 +} +``` ```swift -↓struct Math { - public static let pi = 3.14 +class Foo: NSObject { // class with Obj-C static property + static @objc let foo = 1 } ``` ```swift -↓class Math { +class Foo { // @objc class func can't exist on an enum + @objc class func foo() {} +} +``` + +```swift +class Foo { // @objc static func can't exist on an enum + @objc static func foo() {} +} +``` + +```swift +final class Foo { // final class, but @objc class func can't exist on an enum + @objc class func foo() {} +} +``` + +```swift +final class Foo { // final class, but @objc static func can't exist on an enum + @objc static func foo() {} +} +``` + +## Triggering Examples + +```swift +↓struct Math { public static let pi = 3.14 } ``` @@ -61,4 +91,28 @@ class DummyClass {} public static let pi = 3.14 @available(*, unavailable) init() {} } +``` + +```swift +final ↓class Foo { // final class can't be inherited + class let foo = 1 +} +``` + +```swift +↓class Foo { + class let foo = 1 +} +``` + +```swift +↓class Foo { + final class let foo = 1 +} +``` + +```swift +↓class SomeClass { + static func foo() {} +} ``` \ No newline at end of file diff --git a/docs/description/custom_rules.md b/docs/description/custom_rules.md old mode 100644 new mode 100755 diff --git a/docs/description/cyclomatic_complexity.md b/docs/description/cyclomatic_complexity.md old mode 100644 new mode 100755 diff --git a/docs/description/deployment_target.md b/docs/description/deployment_target.md old mode 100644 new mode 100755 diff --git a/docs/description/description.json b/docs/description/description.json index cf7943d..973444e 100644 --- a/docs/description/description.json +++ b/docs/description/description.json @@ -13,11 +13,21 @@ "title" : "Attributes", "description" : "Attributes should be on their own lines in functions and types, but on the same line as variables and imports.", "parameters" : [ ] +}, { + "patternId" : "balanced_xctest_lifecycle", + "title" : "Balanced XCTest life-cycle", + "description" : "Test classes must implement balanced setUp and tearDown methods.", + "parameters" : [ ] }, { "patternId" : "block_based_kvo", "title" : "Block Based KVO", "description" : "Prefer the new block based KVO API with keypaths when using Swift 3.2 or later.", "parameters" : [ ] +}, { + "patternId" : "capture_variable", + "title" : "Capture Variable", + "description" : "Non-constant variables should not be listed in a closure's capture list to avoid confusion about closures capturing variables at creation time.", + "parameters" : [ ] }, { "patternId" : "class_delegate_protocol", "title" : "Class Delegate Protocol", @@ -63,6 +73,11 @@ "title" : "Comma Spacing", "description" : "There should be no space before and one after any comma.", "parameters" : [ ] +}, { + "patternId" : "comment_spacing", + "title" : "Comment Spacing", + "description" : "Prefer at least one space after slashes for comments.", + "parameters" : [ ] }, { "patternId" : "compiler_protocol_init", "title" : "Compiler Protocol Init", @@ -128,6 +143,11 @@ "title" : "Discarded Notification Center Observer", "description" : "When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later.", "parameters" : [ ] +}, { + "patternId" : "discouraged_assert", + "title" : "Discouraged Assert", + "description" : "Prefer `assertionFailure()` and/or `preconditionFailure()` over `assert(false)`", + "parameters" : [ ] }, { "patternId" : "discouraged_direct_init", "title" : "Discouraged Direct Initialization", @@ -176,7 +196,7 @@ }, { "patternId" : "empty_enum_arguments", "title" : "Empty Enum Arguments", - "description" : "Arguments can be omitted when matching enums with associated types if they are not used.", + "description" : "Arguments can be omitted when matching enums with associated values if they are not used.", "parameters" : [ ] }, { "patternId" : "empty_parameters", @@ -260,7 +280,7 @@ "parameters" : [ ] }, { "patternId" : "file_length", - "title" : "File Line Length", + "title" : "File Length", "description" : "Files should not span too many lines.", "parameters" : [ ] }, { @@ -358,6 +378,11 @@ "title" : "Implicitly Unwrapped Optional", "description" : "Implicitly unwrapped optionals should be avoided when possible.", "parameters" : [ ] +}, { + "patternId" : "inclusive_language", + "title" : "Inclusive Language", + "description" : " Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status", + "parameters" : [ ] }, { "patternId" : "indentation_width", "title" : "Indentation Width", @@ -423,6 +448,11 @@ "title" : "Legacy NSGeometry Functions", "description" : "Struct extension properties and methods are preferred over legacy functions", "parameters" : [ ] +}, { + "patternId" : "legacy_objc_type", + "title" : "Legacy Objective-C Reference Type", + "description" : "Prefer Swift value types to bridged Objective-C reference types", + "parameters" : [ ] }, { "patternId" : "legacy_random", "title" : "Legacy Random", @@ -501,7 +531,7 @@ }, { "patternId" : "nesting", "title" : "Nesting", - "description" : "Types should be nested at most 1 level deep, and statements should be nested at most 5 levels deep.", + "description" : "Types should be nested at most 1 level deep, and functions should be nested at most 2 levels deep.", "parameters" : [ ] }, { "patternId" : "nimble_operator", @@ -536,7 +566,7 @@ }, { "patternId" : "nslocalizedstring_key", "title" : "NSLocalizedString Key", - "description" : "Static strings should be used as key in NSLocalizedString in order to genstrings work.", + "description" : "Static strings should be used as key/comment in NSLocalizedString in order for genstrings to work.", "parameters" : [ ] }, { "patternId" : "nslocalizedstring_require_bundle", @@ -598,6 +628,11 @@ "title" : "Pattern Matching Keywords", "description" : "Combine multiple pattern matching bindings by moving keywords out of tuples.", "parameters" : [ ] +}, { + "patternId" : "prefer_nimble", + "title" : "Prefer Nimble", + "description" : "Prefer Nimble matchers over XCTAssert functions.", + "parameters" : [ ] }, { "patternId" : "prefer_self_type_over_type_of_self", "title" : "Prefer Self Type Over Type of Self", @@ -628,6 +663,11 @@ "title" : "Private over fileprivate", "description" : "Prefer `private` over `fileprivate` declarations.", "parameters" : [ ] +}, { + "patternId" : "private_subject", + "title" : "Private Combine Subject", + "description" : "Combine Subject should be private.", + "parameters" : [ ] }, { "patternId" : "private_unit_test", "title" : "Private Unit Test", @@ -793,6 +833,11 @@ "title" : "Syntactic Sugar", "description" : "Shorthand syntactic sugar should be used, i.e. [Int] instead of Array.", "parameters" : [ ] +}, { + "patternId" : "test_case_accessibility", + "title" : "Test case accessibility", + "description" : "Test cases should only contain private non-test members.", + "parameters" : [ ] }, { "patternId" : "todo", "title" : "Todo", @@ -853,11 +898,6 @@ "title" : "Unneeded Break in Switch", "description" : "Avoid using unneeded break statements.", "parameters" : [ ] -}, { - "patternId" : "unneeded_notification_center_removal", - "title" : "Unneeded NotificationCenter Removal", - "description" : "Observers are automatically unregistered on dealloc (iOS 9 / macOS 10.11) so you should't call `removeObserver(self)` in the deinit.", - "parameters" : [ ] }, { "patternId" : "unneeded_parentheses_in_closure_argument", "title" : "Unneeded Parentheses in Closure Argument", diff --git a/docs/description/discarded_notification_center_observer.md b/docs/description/discarded_notification_center_observer.md old mode 100644 new mode 100755 index 2b677db..e2161f0 --- a/docs/description/discarded_notification_center_observer.md +++ b/docs/description/discarded_notification_center_observer.md @@ -3,7 +3,7 @@ When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later. * **Identifier:** discarded_notification_center_observer -* **Enabled by default:** Enabled +* **Enabled by default:** Disabled * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No diff --git a/docs/description/discouraged_assert.md b/docs/description/discouraged_assert.md new file mode 100755 index 0000000..5a3fbb2 --- /dev/null +++ b/docs/description/discouraged_assert.md @@ -0,0 +1,51 @@ +# Discouraged Assert + +Prefer `assertionFailure()` and/or `preconditionFailure()` over `assert(false)` + +* **Identifier:** discouraged_assert +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +assert(true) +``` + +```swift +assert(true, "foobar") +``` + +```swift +assert(true, "foobar", file: "toto", line: 42) +``` + +```swift +assert(false || true) +``` + +```swift +XCTAssert(false) +``` + +## Triggering Examples + +```swift +↓assert(false) +``` + +```swift +↓assert(false, "foobar") +``` + +```swift +↓assert(false, "foobar", file: "toto", line: 42) +``` + +```swift +↓assert( false , "foobar") +``` \ No newline at end of file diff --git a/docs/description/discouraged_direct_init.md b/docs/description/discouraged_direct_init.md old mode 100644 new mode 100755 diff --git a/docs/description/discouraged_object_literal.md b/docs/description/discouraged_object_literal.md old mode 100644 new mode 100755 diff --git a/docs/description/discouraged_optional_boolean.md b/docs/description/discouraged_optional_boolean.md old mode 100644 new mode 100755 diff --git a/docs/description/discouraged_optional_collection.md b/docs/description/discouraged_optional_collection.md old mode 100644 new mode 100755 diff --git a/docs/description/duplicate_enum_cases.md b/docs/description/duplicate_enum_cases.md old mode 100644 new mode 100755 diff --git a/docs/description/duplicate_imports.md b/docs/description/duplicate_imports.md old mode 100644 new mode 100755 index 9fe9228..ea8b2c3 --- a/docs/description/duplicate_imports.md +++ b/docs/description/duplicate_imports.md @@ -23,6 +23,16 @@ import A.B import A.C ``` +```swift +@_implementationOnly import A +@_implementationOnly import B +``` + +```swift +@testable import A +@testable import B +``` + ```swift #if DEBUG @testable import KsApi @@ -55,6 +65,16 @@ import Foundation ↓import Foundation.NSString ``` +```swift +@_implementationOnly import A +@_implementationOnly import A +``` + +```swift +@testable import A +@testable import A +``` + ```swift ↓import Foundation.NSString import Foundation diff --git a/docs/description/dynamic_inline.md b/docs/description/dynamic_inline.md old mode 100644 new mode 100755 diff --git a/docs/description/empty_collection_literal.md b/docs/description/empty_collection_literal.md old mode 100644 new mode 100755 diff --git a/docs/description/empty_count.md b/docs/description/empty_count.md old mode 100644 new mode 100755 diff --git a/docs/description/empty_enum_arguments.md b/docs/description/empty_enum_arguments.md old mode 100644 new mode 100755 index df8cf3e..e6a00d3 --- a/docs/description/empty_enum_arguments.md +++ b/docs/description/empty_enum_arguments.md @@ -1,6 +1,6 @@ # Empty Enum Arguments -Arguments can be omitted when matching enums with associated types if they are not used. +Arguments can be omitted when matching enums with associated values if they are not used. * **Identifier:** empty_enum_arguments * **Enabled by default:** Enabled diff --git a/docs/description/empty_parameters.md b/docs/description/empty_parameters.md old mode 100644 new mode 100755 diff --git a/docs/description/empty_parentheses_with_trailing_closure.md b/docs/description/empty_parentheses_with_trailing_closure.md old mode 100644 new mode 100755 diff --git a/docs/description/empty_string.md b/docs/description/empty_string.md old mode 100644 new mode 100755 diff --git a/docs/description/empty_xctest_method.md b/docs/description/empty_xctest_method.md old mode 100644 new mode 100755 diff --git a/docs/description/enum_case_associated_values_count.md b/docs/description/enum_case_associated_values_count.md old mode 100644 new mode 100755 diff --git a/docs/description/expiring_todo.md b/docs/description/expiring_todo.md old mode 100644 new mode 100755 diff --git a/docs/description/explicit_acl.md b/docs/description/explicit_acl.md old mode 100644 new mode 100755 diff --git a/docs/description/explicit_enum_raw_value.md b/docs/description/explicit_enum_raw_value.md old mode 100644 new mode 100755 diff --git a/docs/description/explicit_init.md b/docs/description/explicit_init.md old mode 100644 new mode 100755 diff --git a/docs/description/explicit_self.md b/docs/description/explicit_self.md old mode 100644 new mode 100755 index b4e97ef..d8ecef9 --- a/docs/description/explicit_self.md +++ b/docs/description/explicit_self.md @@ -30,6 +30,26 @@ struct A { } ``` +```swift +@propertyWrapper +struct Wrapper { + let wrappedValue: Value + var projectedValue: [Value] { + [self.wrappedValue] + } +} +struct A { + @Wrapper var p1: Int + func f1() { + self.$p1 + self._p1 + } +} +func f1() { + A(p1: 10).$p1 +} +``` + ## Triggering Examples ```swift @@ -48,4 +68,33 @@ struct A { _ = ↓p1 } } +``` + +```swift +struct A { + func f1(a b: Int) {} + func f2() { + ↓f1(a: 0) + } +} +``` + +```swift +@propertyWrapper +struct Wrapper { + let wrappedValue: Value + var projectedValue: [Value] { + [self.wrappedValue] + } +} +struct A { + @Wrapper var p1: Int + func f1() { + ↓$p1 + ↓_p1 + } +} +func f1() { + A(p1: 10).$p1 +} ``` \ No newline at end of file diff --git a/docs/description/explicit_top_level_acl.md b/docs/description/explicit_top_level_acl.md old mode 100644 new mode 100755 diff --git a/docs/description/explicit_type_interface.md b/docs/description/explicit_type_interface.md old mode 100644 new mode 100755 diff --git a/docs/description/extension_access_modifier.md b/docs/description/extension_access_modifier.md old mode 100644 new mode 100755 diff --git a/docs/description/fallthrough.md b/docs/description/fallthrough.md old mode 100644 new mode 100755 diff --git a/docs/description/fatal_error_message.md b/docs/description/fatal_error_message.md old mode 100644 new mode 100755 diff --git a/docs/description/file_header.md b/docs/description/file_header.md old mode 100644 new mode 100755 diff --git a/docs/description/file_length.md b/docs/description/file_length.md old mode 100644 new mode 100755 index 805601e..99f397d --- a/docs/description/file_length.md +++ b/docs/description/file_length.md @@ -1,4 +1,4 @@ -# File Line Length +# File Length Files should not span too many lines. diff --git a/docs/description/file_name.md b/docs/description/file_name.md old mode 100644 new mode 100755 index 72938d3..17702a3 --- a/docs/description/file_name.md +++ b/docs/description/file_name.md @@ -8,4 +8,4 @@ File name should match a type or extension declared in the file (if any). * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** (severity) warning, excluded: ["LinuxMain.swift", "main.swift"], prefixPattern: , suffixPattern: \+.*, nestedTypeSeparator: . \ No newline at end of file +* **Default configuration:** (severity) warning, excluded: ["LinuxMain.swift", "main.swift"], prefix_pattern: , suffix_pattern: \+.*, nested_type_separator: . \ No newline at end of file diff --git a/docs/description/file_name_no_space.md b/docs/description/file_name_no_space.md old mode 100644 new mode 100755 diff --git a/docs/description/file_types_order.md b/docs/description/file_types_order.md old mode 100644 new mode 100755 diff --git a/docs/description/first_where.md b/docs/description/first_where.md old mode 100644 new mode 100755 diff --git a/docs/description/flatmap_over_map_reduce.md b/docs/description/flatmap_over_map_reduce.md old mode 100644 new mode 100755 diff --git a/docs/description/for_where.md b/docs/description/for_where.md old mode 100644 new mode 100755 diff --git a/docs/description/force_cast.md b/docs/description/force_cast.md old mode 100644 new mode 100755 diff --git a/docs/description/force_try.md b/docs/description/force_try.md old mode 100644 new mode 100755 diff --git a/docs/description/force_unwrapping.md b/docs/description/force_unwrapping.md old mode 100644 new mode 100755 diff --git a/docs/description/function_body_length.md b/docs/description/function_body_length.md old mode 100644 new mode 100755 diff --git a/docs/description/function_default_parameter_at_end.md b/docs/description/function_default_parameter_at_end.md old mode 100644 new mode 100755 diff --git a/docs/description/function_parameter_count.md b/docs/description/function_parameter_count.md old mode 100644 new mode 100755 diff --git a/docs/description/generic_type_name.md b/docs/description/generic_type_name.md old mode 100644 new mode 100755 diff --git a/docs/description/ibinspectable_in_extension.md b/docs/description/ibinspectable_in_extension.md old mode 100644 new mode 100755 diff --git a/docs/description/identical_operands.md b/docs/description/identical_operands.md old mode 100644 new mode 100755 diff --git a/docs/description/identifier_name.md b/docs/description/identifier_name.md old mode 100644 new mode 100755 diff --git a/docs/description/implicit_getter.md b/docs/description/implicit_getter.md old mode 100644 new mode 100755 index 0baf504..2ed9bc3 --- a/docs/description/implicit_getter.md +++ b/docs/description/implicit_getter.md @@ -76,6 +76,7 @@ protocol Foo { ```swift protocol Foo { var foo: Int { get set } +} ``` ```swift diff --git a/docs/description/implicit_return.md b/docs/description/implicit_return.md old mode 100644 new mode 100755 index f31ca38..d378797 --- a/docs/description/implicit_return.md +++ b/docs/description/implicit_return.md @@ -8,7 +8,7 @@ Prefer implicit returns in closures, functions and getters. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning, included: [function, closure, getter] +* **Default configuration:** warning, included: [getter, function, closure] ## Non Triggering Examples diff --git a/docs/description/implicitly_unwrapped_optional.md b/docs/description/implicitly_unwrapped_optional.md old mode 100644 new mode 100755 diff --git a/docs/description/inclusive_language.md b/docs/description/inclusive_language.md new file mode 100755 index 0000000..ab3d922 --- /dev/null +++ b/docs/description/inclusive_language.md @@ -0,0 +1,71 @@ +# Inclusive Language + + Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status + +* **Identifier:** inclusive_language +* **Enabled by default:** Enabled +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, additional_terms: [], override_terms: [], override_allowed_terms: [] + +## Non Triggering Examples + +```swift +let foo = "abc" +``` + +```swift +enum AllowList { + case foo, bar +} +``` + +```swift +func updateAllowList(add: String) {} +``` + +```swift +enum WalletItemType { + case visa + case mastercard +} +``` + +```swift +func chargeMasterCard(_ card: Card) {} +``` + +## Triggering Examples + +```swift +let ↓slave = "abc" +``` + +```swift +enum ↓BlackList { + case foo, bar +} +``` + +```swift +func ↓updateWhiteList(add: String) {} +``` + +```swift +enum ListType { + case ↓whitelist + case ↓blacklist +} +``` + +```swift +↓init(master: String, slave: String) {} +``` + +```swift +final class FooBar { + func register<↓Master, ↓Slave>(one: Master, two: Slave) {} +} +``` \ No newline at end of file diff --git a/docs/description/indentation_width.md b/docs/description/indentation_width.md old mode 100644 new mode 100755 diff --git a/docs/description/inert_defer.md b/docs/description/inert_defer.md old mode 100644 new mode 100755 diff --git a/docs/description/is_disjoint.md b/docs/description/is_disjoint.md old mode 100644 new mode 100755 diff --git a/docs/description/joined_default_parameter.md b/docs/description/joined_default_parameter.md old mode 100644 new mode 100755 diff --git a/docs/description/large_tuple.md b/docs/description/large_tuple.md old mode 100644 new mode 100755 diff --git a/docs/description/last_where.md b/docs/description/last_where.md old mode 100644 new mode 100755 diff --git a/docs/description/leading_whitespace.md b/docs/description/leading_whitespace.md old mode 100644 new mode 100755 diff --git a/docs/description/legacy_cggeometry_functions.md b/docs/description/legacy_cggeometry_functions.md old mode 100644 new mode 100755 diff --git a/docs/description/legacy_constant.md b/docs/description/legacy_constant.md old mode 100644 new mode 100755 diff --git a/docs/description/legacy_constructor.md b/docs/description/legacy_constructor.md old mode 100644 new mode 100755 diff --git a/docs/description/legacy_hashing.md b/docs/description/legacy_hashing.md old mode 100644 new mode 100755 diff --git a/docs/description/legacy_multiple.md b/docs/description/legacy_multiple.md old mode 100644 new mode 100755 diff --git a/docs/description/legacy_nsgeometry_functions.md b/docs/description/legacy_nsgeometry_functions.md old mode 100644 new mode 100755 diff --git a/docs/description/legacy_objc_type.md b/docs/description/legacy_objc_type.md new file mode 100755 index 0000000..707b6d7 --- /dev/null +++ b/docs/description/legacy_objc_type.md @@ -0,0 +1,32 @@ +# Legacy Objective-C Reference Type + +Prefer Swift value types to bridged Objective-C reference types + +* **Identifier:** legacy_objc_type +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +var array = Array() + +``` + +```swift +var calendar: Calendar? = nil +``` + +## Triggering Examples + +```swift +var array = NSArray() +``` + +```swift +var calendar: NSCalendar? = nil +``` \ No newline at end of file diff --git a/docs/description/legacy_random.md b/docs/description/legacy_random.md old mode 100644 new mode 100755 diff --git a/docs/description/let_var_whitespace.md b/docs/description/let_var_whitespace.md old mode 100644 new mode 100755 diff --git a/docs/description/line_length.md b/docs/description/line_length.md old mode 100644 new mode 100755 diff --git a/docs/description/literal_expression_end_indentation.md b/docs/description/literal_expression_end_indentation.md old mode 100644 new mode 100755 diff --git a/docs/description/lower_acl_than_parent.md b/docs/description/lower_acl_than_parent.md old mode 100644 new mode 100755 diff --git a/docs/description/mark.md b/docs/description/mark.md old mode 100644 new mode 100755 diff --git a/docs/description/missing_docs.md b/docs/description/missing_docs.md old mode 100644 new mode 100755 diff --git a/docs/description/modifier_order.md b/docs/description/modifier_order.md old mode 100644 new mode 100755 diff --git a/docs/description/multiline_arguments.md b/docs/description/multiline_arguments.md old mode 100644 new mode 100755 diff --git a/docs/description/multiline_arguments_brackets.md b/docs/description/multiline_arguments_brackets.md old mode 100644 new mode 100755 diff --git a/docs/description/multiline_function_chains.md b/docs/description/multiline_function_chains.md old mode 100644 new mode 100755 diff --git a/docs/description/multiline_literal_brackets.md b/docs/description/multiline_literal_brackets.md old mode 100644 new mode 100755 diff --git a/docs/description/multiline_parameters.md b/docs/description/multiline_parameters.md old mode 100644 new mode 100755 index 2312b87..16530f9 --- a/docs/description/multiline_parameters.md +++ b/docs/description/multiline_parameters.md @@ -8,7 +8,7 @@ Functions and methods parameters should be either on the same line, or one per l * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning +* **Default configuration:** warning, allowsSingleLine: true ## Non Triggering Examples @@ -324,6 +324,40 @@ class Foo { } ``` +```swift +func foo() { } +``` + +```swift +func foo(param1: Int) { } +``` + +```swift +protocol Foo { + func foo(param1: Int, + param2: Bool, + param3: [String]) { } +} +``` + +```swift +protocol Foo { + func foo( + param1: Int + ) { } +} +``` + +```swift +protocol Foo { + func foo( + param1: Int, + param2: Bool, + param3: [String] + ) { } +} +``` + ## Triggering Examples ```swift @@ -471,4 +505,12 @@ class Foo { class func ↓foo(param1: Int, param2: Bool, param3: @escaping (Int) -> Void = { (x: Int) in }) { } } +``` + +```swift +func ↓foo(param1: Int, param2: Bool) { } +``` + +```swift +func ↓foo(param1: Int, param2: Bool, param3: [String]) { } ``` \ No newline at end of file diff --git a/docs/description/multiline_parameters_brackets.md b/docs/description/multiline_parameters_brackets.md old mode 100644 new mode 100755 diff --git a/docs/description/multiple_closures_with_trailing_closure.md b/docs/description/multiple_closures_with_trailing_closure.md old mode 100644 new mode 100755 index f43f031..e603738 --- a/docs/description/multiple_closures_with_trailing_closure.md +++ b/docs/description/multiple_closures_with_trailing_closure.md @@ -40,6 +40,14 @@ UIView.animate(withDuration: 1.0) { } ``` +```swift +foo.method { print(0) } arg2: { print(1) } +``` + +```swift +foo.methodWithParenArgs((0, 1), arg2: (0, 1, 2)) { $0 } arg4: { $0 } +``` + ## Triggering Examples ```swift @@ -52,4 +60,12 @@ UIView.animate(withDuration: 1.0, animations: { }) ↓{ _ in someView.removeFromSuperview() } +``` + +```swift +foo.multipleTrailing(arg1: { $0 }) { $0 } arg3: { $0 } +``` + +```swift +foo.methodWithParenArgs(param1: { $0 }, param2: (0, 1), (0, 1)) { $0 } ``` \ No newline at end of file diff --git a/docs/description/nesting.md b/docs/description/nesting.md old mode 100644 new mode 100755 index 3ada1cc..3b8039a --- a/docs/description/nesting.md +++ b/docs/description/nesting.md @@ -1,6 +1,6 @@ # Nesting -Types should be nested at most 1 level deep, and statements should be nested at most 5 levels deep. +Types should be nested at most 1 level deep, and functions should be nested at most 2 levels deep. * **Identifier:** nesting * **Enabled by default:** Enabled @@ -8,104 +8,821 @@ Types should be nested at most 1 level deep, and statements should be nested at * **Kind:** metrics * **Analyzer rule:** No * **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** (type_level) w: 1, (statement_level) w: 5 +* **Default configuration:** (type_level) w: 1, (function_level) w: 2, (check_nesting_in_closures_and_statements) true, (always_allow_one_type_in_functions) false ## Non Triggering Examples ```swift -class Class0 { class Class1 {} } + class Example_0 { + class Example_1 {} + } +``` + +```swift + var example: Int { + class Example_0 { + class Example_1 {} + } + return 5 + } +``` + +```swift + var example: Int = 5 { + didSet { + class Example_0 { + class Example_1 {} + } + } + } +``` + +```swift + extension Example_0 { + class Example_1 {} + } +``` + +```swift + struct Example_0 { + struct Example_1 {} + } +``` + +```swift + var example: Int { + struct Example_0 { + struct Example_1 {} + } + return 5 + } +``` + +```swift + var example: Int = 5 { + didSet { + struct Example_0 { + struct Example_1 {} + } + } + } +``` + +```swift + extension Example_0 { + struct Example_1 {} + } +``` + +```swift + enum Example_0 { + enum Example_1 {} + } +``` + +```swift + var example: Int { + enum Example_0 { + enum Example_1 {} + } + return 5 + } +``` + +```swift + var example: Int = 5 { + didSet { + enum Example_0 { + enum Example_1 {} + } + } + } +``` + +```swift + extension Example_0 { + enum Example_1 {} + } +``` + +```swift + func f_0() { + func f_1() { + func f_2() {} + } + } +``` + +```swift + var example: Int { + func f_0() { + func f_1() { + func f_2() {} + } + } + return 5 + } +``` + +```swift + var example: Int = 5 { + didSet { + func f_0() { + func f_1() { + func f_2() {} + } + } + } + } +``` + +```swift + extension Example_0 { + func f_0() { + func f_1() { + func f_2() {} + } + } + } +``` + +```swift + switch example { + case .exampleCase: + class Example_0 { + class Example_1 {} + } + default: + func f_0() { + func f_1() { + func f_2() {} + } + } + } +``` + +```swift + var exampleClosure: () -> Void = { + class Example_0 { + class Example_1 {} + } + func f_0() { + func f_1() { + func f_2() {} + } + } + } +``` + +```swift + exampleFunc(closure: { + class Example_0 { + class Example_1 {} + } + func f_0() { + func f_1() { + func f_2() {} + } + } + }) +``` + +```swift + switch example { + case .exampleCase: + struct Example_0 { + struct Example_1 {} + } + default: + func f_0() { + func f_1() { + func f_2() {} + } + } + } +``` + +```swift + var exampleClosure: () -> Void = { + struct Example_0 { + struct Example_1 {} + } + func f_0() { + func f_1() { + func f_2() {} + } + } + } +``` + +```swift + exampleFunc(closure: { + struct Example_0 { + struct Example_1 {} + } + func f_0() { + func f_1() { + func f_2() {} + } + } + }) +``` + +```swift + switch example { + case .exampleCase: + enum Example_0 { + enum Example_1 {} + } + default: + func f_0() { + func f_1() { + func f_2() {} + } + } + } +``` +```swift + var exampleClosure: () -> Void = { + enum Example_0 { + enum Example_1 {} + } + func f_0() { + func f_1() { + func f_2() {} + } + } + } +``` + +```swift + exampleFunc(closure: { + enum Example_0 { + enum Example_1 {} + } + func f_0() { + func f_1() { + func f_2() {} + } + } + }) ``` ```swift -func func0() { - func func1() { - func func2() { - func func3() { - func func4() { - func func5() { + class Example_0 { + func f_0() { + class Example_1 { + func f_1() { + func f_2() {} + } + } + } + } +``` + +```swift + class Example_0 { + func f_0() { + switch example { + case .exampleCase: + class Example_1 { + func f_1() { + func f_2() {} } } + default: + exampleFunc(closure: { + class Example_1 { + func f_1() { + func f_2() {} + } + } + }) } } } -} ``` ```swift -struct Class0 { struct Class1 {} } + struct Example_0 { + func f_0() { + struct Example_1 { + func f_1() { + func f_2() {} + } + } + } + } +``` +```swift + struct Example_0 { + func f_0() { + switch example { + case .exampleCase: + struct Example_1 { + func f_1() { + func f_2() {} + } + } + default: + exampleFunc(closure: { + struct Example_1 { + func f_1() { + func f_2() {} + } + } + }) + } + } + } ``` ```swift -func func0() { - func func1() { - func func2() { - func func3() { - func func4() { - func func5() { + enum Example_0 { + func f_0() { + enum Example_1 { + func f_1() { + func f_2() {} + } + } + } + } +``` + +```swift + enum Example_0 { + func f_0() { + switch example { + case .exampleCase: + enum Example_1 { + func f_1() { + func f_2() {} } } + default: + exampleFunc(closure: { + enum Example_1 { + func f_1() { + func f_2() {} + } + } + }) } } } -} ``` +## Triggering Examples + ```swift -enum Class0 { enum Class1 {} } + class Example_0 { + class Example_1 { + ↓class Example_2 {} + } + } +``` +```swift + var example: Int { + class Example_0 { + class Example_1 { + ↓class Example_2 {} + } + } + return 5 + } ``` ```swift -func func0() { - func func1() { - func func2() { - func func3() { - func func4() { - func func5() { + var example: Int = 5 { + didSet { + class Example_0 { + class Example_1 { + ↓class Example_2 {} + } + } + } + } +``` + +```swift + extension Example_0 { + class Example_1 { + ↓class Example_2 {} + } + } +``` + +```swift + struct Example_0 { + struct Example_1 { + ↓struct Example_2 {} + } + } +``` + +```swift + var example: Int { + struct Example_0 { + struct Example_1 { + ↓struct Example_2 {} + } + } + return 5 + } +``` + +```swift + var example: Int = 5 { + didSet { + struct Example_0 { + struct Example_1 { + ↓struct Example_2 {} + } + } + } + } +``` + +```swift + extension Example_0 { + struct Example_1 { + ↓struct Example_2 {} + } + } +``` + +```swift + enum Example_0 { + enum Example_1 { + ↓enum Example_2 {} + } + } +``` + +```swift + var example: Int { + enum Example_0 { + enum Example_1 { + ↓enum Example_2 {} + } + } + return 5 + } +``` + +```swift + var example: Int = 5 { + didSet { + enum Example_0 { + enum Example_1 { + ↓enum Example_2 {} + } + } + } + } +``` + +```swift + extension Example_0 { + enum Example_1 { + ↓enum Example_2 {} + } + } +``` + +```swift + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } +``` + +```swift + var example: Int { + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } + return 5 + } +``` + +```swift + var example: Int = 5 { + didSet { + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} } } } } } -} ``` ```swift -enum Enum0 { enum Enum1 { case Case } } + extension Example_0 { + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } + } ``` -## Triggering Examples +```swift + switch example { + case .exampleCase: + class Example_0 { + class Example_1 { + ↓class Example_2 {} + } + } + default: + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } + } +``` ```swift -class A { class B { ↓class C {} } } + var exampleClosure: () -> Void = { + class Example_0 { + class Example_1 { + ↓class Example_2 {} + } + } + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } + } +``` +```swift + exampleFunc(closure: { + class Example_0 { + class Example_1 {} + } + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } + }) ``` ```swift -struct A { struct B { ↓struct C {} } } + switch example { + case .exampleCase: + struct Example_0 { + struct Example_1 { + ↓struct Example_2 {} + } + } + default: + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } + } +``` + +```swift + var exampleClosure: () -> Void = { + struct Example_0 { + struct Example_1 { + ↓struct Example_2 {} + } + } + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } + } +``` + +```swift + exampleFunc(closure: { + struct Example_0 { + struct Example_1 {} + } + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } + }) +``` + +```swift + switch example { + case .exampleCase: + enum Example_0 { + enum Example_1 { + ↓enum Example_2 {} + } + } + default: + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } + } +``` + +```swift + var exampleClosure: () -> Void = { + enum Example_0 { + enum Example_1 { + ↓enum Example_2 {} + } + } + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } + } +``` + +```swift + exampleFunc(closure: { + enum Example_0 { + enum Example_1 {} + } + func f_0() { + func f_1() { + func f_2() { + ↓func f_3() {} + } + } + } + }) +``` +```swift + class Example_0 { + func f_0() { + class Example_1 { + func f_1() { + func f_2() { + ↓class Example_2 {} + ↓func f_3() {} + } + } + } + } + } ``` ```swift -enum A { enum B { ↓enum C {} } } + class Example_0 { + func f_0() { + switch example { + case .exampleCase: + class Example_1 { + func f_1() { + func f_2() { + ↓class Example_2 {} + ↓func f_3() {} + } + } + } + default: + exampleFunc(closure: { + class Example_1 { + func f_1() { + func f_2() { + ↓class Example_2 {} + ↓func f_3() {} + } + } + } + }) + } + } + } +``` +```swift + struct Example_0 { + func f_0() { + struct Example_1 { + func f_1() { + func f_2() { + ↓struct Example_2 {} + ↓func f_3() {} + } + } + } + } + } +``` + +```swift + struct Example_0 { + func f_0() { + switch example { + case .exampleCase: + struct Example_1 { + func f_1() { + func f_2() { + ↓struct Example_2 {} + ↓func f_3() {} + } + } + } + default: + exampleFunc(closure: { + struct Example_1 { + func f_1() { + func f_2() { + ↓struct Example_2 {} + ↓func f_3() {} + } + } + } + }) + } + } + } ``` ```swift -func func0() { - func func1() { - func func2() { - func func3() { - func func4() { - func func5() { - ↓func func6() { + enum Example_0 { + func f_0() { + enum Example_1 { + func f_1() { + func f_2() { + ↓enum Example_2 {} + ↓func f_3() {} + } + } + } + } + } +``` + +```swift + enum Example_0 { + func f_0() { + switch example { + case .exampleCase: + enum Example_1 { + func f_1() { + func f_2() { + ↓enum Example_2 {} + ↓func f_3() {} } } } + default: + exampleFunc(closure: { + enum Example_1 { + func f_1() { + func f_2() { + ↓enum Example_2 {} + ↓func f_3() {} + } + } + } + }) } } } -} ``` \ No newline at end of file diff --git a/docs/description/nimble_operator.md b/docs/description/nimble_operator.md old mode 100644 new mode 100755 diff --git a/docs/description/no_extension_access_modifier.md b/docs/description/no_extension_access_modifier.md old mode 100644 new mode 100755 diff --git a/docs/description/no_fallthrough_only.md b/docs/description/no_fallthrough_only.md old mode 100644 new mode 100755 diff --git a/docs/description/no_grouping_extension.md b/docs/description/no_grouping_extension.md old mode 100644 new mode 100755 diff --git a/docs/description/no_space_in_method_call.md b/docs/description/no_space_in_method_call.md old mode 100644 new mode 100755 index 77a36cc..23f82cd --- a/docs/description/no_space_in_method_call.md +++ b/docs/description/no_space_in_method_call.md @@ -40,6 +40,14 @@ list.sorted { $0.0 < $1.0 }.map { $0.value } self.init(rgb: (Int) (colorInt)) ``` +```swift +Button { + print("Button tapped") +} label: { + Text("Button") +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/notification_center_detachment.md b/docs/description/notification_center_detachment.md old mode 100644 new mode 100755 diff --git a/docs/description/nslocalizedstring_key.md b/docs/description/nslocalizedstring_key.md old mode 100644 new mode 100755 index e8b64e0..11c482b --- a/docs/description/nslocalizedstring_key.md +++ b/docs/description/nslocalizedstring_key.md @@ -1,6 +1,6 @@ # NSLocalizedString Key -Static strings should be used as key in NSLocalizedString in order to genstrings work. +Static strings should be used as key/comment in NSLocalizedString in order for genstrings to work. * **Identifier:** nslocalizedstring_key * **Enabled by default:** Disabled @@ -13,19 +13,42 @@ Static strings should be used as key in NSLocalizedString in order to genstrings ## Non Triggering Examples ```swift -NSLocalizedString("key", comment: nil) +NSLocalizedString("key", comment: "") ``` ```swift -NSLocalizedString("key" + "2", comment: nil) +NSLocalizedString("key" + "2", comment: "") +``` + +```swift +NSLocalizedString("key", comment: "comment") +``` + +```swift +NSLocalizedString("This is a multi-" + + "line string", comment: "") +``` + +```swift +let format = NSLocalizedString("%@, %@.", comment: "Accessibility label for a post in the post list." + +" The parameters are the title, and date respectively." + +" For example, "Let it Go, 1 hour ago."") ``` ## Triggering Examples ```swift -NSLocalizedString(↓method(), comment: nil) +NSLocalizedString(↓method(), comment: "") +``` + +```swift +NSLocalizedString(↓"key_\(param)", comment: "") +``` + +```swift +NSLocalizedString("key", comment: ↓"comment with \(param)") ``` ```swift -NSLocalizedString(↓"key_\(param)", comment: nil) +NSLocalizedString(↓"key_\(param)", comment: ↓method()) ``` \ No newline at end of file diff --git a/docs/description/nslocalizedstring_require_bundle.md b/docs/description/nslocalizedstring_require_bundle.md old mode 100644 new mode 100755 diff --git a/docs/description/nsobject_prefer_isequal.md b/docs/description/nsobject_prefer_isequal.md old mode 100644 new mode 100755 diff --git a/docs/description/number_separator.md b/docs/description/number_separator.md old mode 100644 new mode 100755 diff --git a/docs/description/object_literal.md b/docs/description/object_literal.md old mode 100644 new mode 100755 diff --git a/docs/description/opening_brace.md b/docs/description/opening_brace.md old mode 100644 new mode 100755 index 53ae631..cb9d1e4 --- a/docs/description/opening_brace.md +++ b/docs/description/opening_brace.md @@ -8,7 +8,7 @@ Opening braces should be preceded by a single space and on the same line as the * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning +* **Default configuration:** warning, allowMultilineFunc: false ## Non Triggering Examples @@ -111,6 +111,12 @@ func abc() ↓{ } ``` +```swift +func abc(a: A + b: B) +↓{ +``` + ```swift [].map()↓{ $0 } ``` diff --git a/docs/description/operator_usage_whitespace.md b/docs/description/operator_usage_whitespace.md old mode 100644 new mode 100755 index 00120ed..6b76f81 --- a/docs/description/operator_usage_whitespace.md +++ b/docs/description/operator_usage_whitespace.md @@ -8,7 +8,7 @@ Operators should be surrounded by a single whitespace when they are being used. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning +* **Default configuration:** warning, lines_look_around: 2, skip_aligned_constants: true ## Non Triggering Examples @@ -110,6 +110,17 @@ let foo = SignalProducer, Error>([ self.signal, next ]).fla ``` +```swift +"let foo = 1" +``` + +```swift + enum Enum { + case hello = 1 + case hello2 = 1 + } +``` + ## Triggering Examples ```swift @@ -186,4 +197,40 @@ let v8 = 1↓ << (6) let v8 = 1↓ << (6) let foo = 1 > 2 +``` + +```swift +let foo↓ = [1] + +``` + +```swift +let foo↓ = "1" + +``` + +```swift +let foo↓ = "1" + +``` + +```swift + enum Enum { + case one↓ = 1 + case two = 1 + } +``` + +```swift + enum Enum { + case one = 1 + case two↓ = 1 + } +``` + +```swift + enum Enum { + case one↓ = 1 + case two↓ = 1 + } ``` \ No newline at end of file diff --git a/docs/description/operator_whitespace.md b/docs/description/operator_whitespace.md old mode 100644 new mode 100755 diff --git a/docs/description/optional_enum_case_matching.md b/docs/description/optional_enum_case_matching.md old mode 100644 new mode 100755 diff --git a/docs/description/orphaned_doc_comment.md b/docs/description/orphaned_doc_comment.md old mode 100644 new mode 100755 diff --git a/docs/description/overridden_super_call.md b/docs/description/overridden_super_call.md old mode 100644 new mode 100755 index 09b9781..2aa4702 --- a/docs/description/overridden_super_call.md +++ b/docs/description/overridden_super_call.md @@ -8,7 +8,7 @@ Some overridden methods should always call super * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning, excluded: [[]], included: [["*"]] +* **Default configuration:** warning, excluded: [], included: ["*"] ## Non Triggering Examples diff --git a/docs/description/override_in_extension.md b/docs/description/override_in_extension.md old mode 100644 new mode 100755 diff --git a/docs/description/pattern_matching_keywords.md b/docs/description/pattern_matching_keywords.md old mode 100644 new mode 100755 diff --git a/docs/description/prefer_nimble.md b/docs/description/prefer_nimble.md new file mode 100755 index 0000000..3b66fd5 --- /dev/null +++ b/docs/description/prefer_nimble.md @@ -0,0 +1,47 @@ +# Prefer Nimble + +Prefer Nimble matchers over XCTAssert functions. + +* **Identifier:** prefer_nimble +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +expect(foo) == 1 +``` + +```swift +expect(foo).to(equal(1)) +``` + +## Triggering Examples + +```swift +↓XCTAssertTrue(foo) +``` + +```swift +↓XCTAssertEqual(foo, 2) +``` + +```swift +↓XCTAssertNotEqual(foo, 2) +``` + +```swift +↓XCTAssertNil(foo) +``` + +```swift +↓XCTAssert(foo) +``` + +```swift +↓XCTAssertGreaterThan(foo, 10) +``` \ No newline at end of file diff --git a/docs/description/prefer_self_type_over_type_of_self.md b/docs/description/prefer_self_type_over_type_of_self.md old mode 100644 new mode 100755 diff --git a/docs/description/prefer_zero_over_explicit_init.md b/docs/description/prefer_zero_over_explicit_init.md old mode 100644 new mode 100755 index 088377d..ef46a31 --- a/docs/description/prefer_zero_over_explicit_init.md +++ b/docs/description/prefer_zero_over_explicit_init.md @@ -17,7 +17,7 @@ CGRect(x: 0, y: 0, width: 0, height: 1) ``` ```swift -CGPoint(x: 0, y: -1 +CGPoint(x: 0, y: -1) ``` ```swift diff --git a/docs/description/prefixed_toplevel_constant.md b/docs/description/prefixed_toplevel_constant.md old mode 100644 new mode 100755 index 07dc0f9..70b5bc0 --- a/docs/description/prefixed_toplevel_constant.md +++ b/docs/description/prefixed_toplevel_constant.md @@ -28,6 +28,10 @@ internal let kFoo = "Foo" let kFoo = true ``` +```swift +let Foo = true +``` + ```swift struct Foo { let bar = 20.0 diff --git a/docs/description/private_action.md b/docs/description/private_action.md old mode 100644 new mode 100755 diff --git a/docs/description/private_outlet.md b/docs/description/private_outlet.md old mode 100644 new mode 100755 diff --git a/docs/description/private_over_fileprivate.md b/docs/description/private_over_fileprivate.md old mode 100644 new mode 100755 diff --git a/docs/description/private_subject.md b/docs/description/private_subject.md new file mode 100755 index 0000000..163f2af --- /dev/null +++ b/docs/description/private_subject.md @@ -0,0 +1,233 @@ +# Private Combine Subject + +Combine Subject should be private. + +* **Identifier:** private_subject +* **Enabled by default:** Disabled +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +final class Foobar { + private let goodSubject = PassthroughSubject() +} +``` + +```swift +final class Foobar { + private let goodSubject: PassthroughSubject +} +``` + +```swift +final class Foobar { + fileprivate let goodSubject: PassthroughSubject +} +``` + +```swift +final class Foobar { + private let goodSubject: PassthroughSubject = .ini() +} +``` + +```swift +final class Foobar { + private let goodSubject = CurrentValueSubject(false) +} +``` + +```swift +final class Foobar { + private let goodSubject: CurrentValueSubject +} +``` + +```swift +final class Foobar { + fileprivate let goodSubject: CurrentValueSubject +} +``` + +```swift +final class Foobar { + private let goodSubject: CurrentValueSubject = .ini("toto") +} +``` + +```swift +final class Foobar { + private let goodSubject = PassthroughSubject, Never>() +} +``` + +```swift +final class Foobar { + private let goodSubject: PassthroughSubject, Never> = .init() +} +``` + +```swift +final class Foobar { + private let goodSubject: CurrentValueSubject, Never> = .init([]) +} +``` + +```swift +final class Foobar { + private let goodSubject = + PassthroughSubject() +} +``` + +```swift +final class Foobar { + private let goodSubject: + PassthroughSubject = .ini() +} +``` + +```swift +final class Foobar { + private let goodSubject = + CurrentValueSubject(true) +} +``` + +## Triggering Examples + +```swift +final class Foobar { + let ↓badSubject = PassthroughSubject() +} +``` + +```swift +final class Foobar { + let ↓badSubject: PassthroughSubject +} +``` + +```swift +final class Foobar { + private(set) let ↓badSubject: PassthroughSubject +} +``` + +```swift +final class Foobar { + private(set) let ↓badSubject = PassthroughSubject() +} +``` + +```swift +final class Foobar { + let goodSubject: PassthroughSubject = .ini() +} +``` + +```swift +final class Foobar { + private let goodSubject: PassthroughSubject + private(set) let ↓badSubject = PassthroughSubject() + private(set) let ↓anotherBadSubject = PassthroughSubject() +} +``` + +```swift +final class Foobar { + private(set) let ↓badSubject = PassthroughSubject() + private let goodSubject: PassthroughSubject + private(set) let ↓anotherBadSubject = PassthroughSubject() +} +``` + +```swift +final class Foobar { + let ↓badSubject = CurrentValueSubject(true) +} +``` + +```swift +final class Foobar { + let ↓badSubject: CurrentValueSubject +} +``` + +```swift +final class Foobar { + private(set) let ↓badSubject: CurrentValueSubject +} +``` + +```swift +final class Foobar { + private(set) let ↓badSubject = CurrentValueSubject(false) +} +``` + +```swift +final class Foobar { + let goodSubject: CurrentValueSubject = .ini("toto") +} +``` + +```swift +final class Foobar { + private let goodSubject: CurrentValueSubject + private(set) let ↓badSubject = CurrentValueSubject(false) + private(set) let ↓anotherBadSubject = CurrentValueSubject(false) +} +``` + +```swift +final class Foobar { + private(set) let ↓badSubject = CurrentValueSubject(false) + private let goodSubject: CurrentValueSubject + private(set) let ↓anotherBadSubject = CurrentValueSubject(true) +} +``` + +```swift +final class Foobar { + let ↓badSubject = PassthroughSubject, Never>() +} +``` + +```swift +final class Foobar { + let ↓badSubject: PassthroughSubject, Never> = .init() +} +``` + +```swift +final class Foobar { + let ↓badSubject: CurrentValueSubject, Never> = .init([]) +} +``` + +```swift +final class Foobar { + let ↓badSubject = + PassthroughSubject() +} +``` + +```swift +final class Foobar { + let ↓badSubject: + PassthroughSubject = .ini() +} +``` + +```swift +final class Foobar { + let ↓badSubject = + CurrentValueSubject(true) +} +``` \ No newline at end of file diff --git a/docs/description/private_unit_test.md b/docs/description/private_unit_test.md old mode 100644 new mode 100755 diff --git a/docs/description/prohibited_interface_builder.md b/docs/description/prohibited_interface_builder.md old mode 100644 new mode 100755 diff --git a/docs/description/prohibited_super_call.md b/docs/description/prohibited_super_call.md old mode 100644 new mode 100755 diff --git a/docs/description/protocol_property_accessors_order.md b/docs/description/protocol_property_accessors_order.md old mode 100644 new mode 100755 diff --git a/docs/description/quick_discouraged_call.md b/docs/description/quick_discouraged_call.md old mode 100644 new mode 100755 diff --git a/docs/description/quick_discouraged_focused_test.md b/docs/description/quick_discouraged_focused_test.md old mode 100644 new mode 100755 diff --git a/docs/description/quick_discouraged_pending_test.md b/docs/description/quick_discouraged_pending_test.md old mode 100644 new mode 100755 diff --git a/docs/description/raw_value_for_camel_cased_codable_enum.md b/docs/description/raw_value_for_camel_cased_codable_enum.md old mode 100644 new mode 100755 diff --git a/docs/description/reduce_boolean.md b/docs/description/reduce_boolean.md old mode 100644 new mode 100755 diff --git a/docs/description/reduce_into.md b/docs/description/reduce_into.md old mode 100644 new mode 100755 diff --git a/docs/description/redundant_discardable_let.md b/docs/description/redundant_discardable_let.md old mode 100644 new mode 100755 diff --git a/docs/description/redundant_nil_coalescing.md b/docs/description/redundant_nil_coalescing.md old mode 100644 new mode 100755 diff --git a/docs/description/redundant_objc_attribute.md b/docs/description/redundant_objc_attribute.md old mode 100644 new mode 100755 diff --git a/docs/description/redundant_optional_initialization.md b/docs/description/redundant_optional_initialization.md old mode 100644 new mode 100755 diff --git a/docs/description/redundant_set_access_control.md b/docs/description/redundant_set_access_control.md old mode 100644 new mode 100755 diff --git a/docs/description/redundant_string_enum_value.md b/docs/description/redundant_string_enum_value.md old mode 100644 new mode 100755 diff --git a/docs/description/redundant_type_annotation.md b/docs/description/redundant_type_annotation.md old mode 100644 new mode 100755 index a498fcd..92ee155 --- a/docs/description/redundant_type_annotation.md +++ b/docs/description/redundant_type_annotation.md @@ -24,6 +24,24 @@ var url: CustomStringConvertible = URL() @IBInspectable var color: UIColor = UIColor.white ``` +```swift +enum Direction { + case up + case down +} + +var direction: Direction = .up +``` + +```swift +enum Direction { + case up + case down +} + +var direction = Direction.up +``` + ## Triggering Examples ```swift @@ -56,4 +74,17 @@ class ViewController: UIViewController { let myVar↓: Int = Int(5) } } +``` + +```swift +var isEnabled↓: Bool = true +``` + +```swift +enum Direction { + case up + case down +} + +var direction↓: Direction = Direction.up ``` \ No newline at end of file diff --git a/docs/description/redundant_void_return.md b/docs/description/redundant_void_return.md old mode 100644 new mode 100755 diff --git a/docs/description/required_deinit.md b/docs/description/required_deinit.md old mode 100644 new mode 100755 diff --git a/docs/description/required_enum_case.md b/docs/description/required_enum_case.md old mode 100644 new mode 100755 diff --git a/docs/description/return_arrow_whitespace.md b/docs/description/return_arrow_whitespace.md old mode 100644 new mode 100755 diff --git a/docs/description/shorthand_operator.md b/docs/description/shorthand_operator.md old mode 100644 new mode 100755 diff --git a/docs/description/single_test_class.md b/docs/description/single_test_class.md old mode 100644 new mode 100755 diff --git a/docs/description/sorted_first_last.md b/docs/description/sorted_first_last.md old mode 100644 new mode 100755 diff --git a/docs/description/sorted_imports.md b/docs/description/sorted_imports.md old mode 100644 new mode 100755 diff --git a/docs/description/statement_position.md b/docs/description/statement_position.md old mode 100644 new mode 100755 diff --git a/docs/description/static_operator.md b/docs/description/static_operator.md old mode 100644 new mode 100755 diff --git a/docs/description/strict_fileprivate.md b/docs/description/strict_fileprivate.md old mode 100644 new mode 100755 diff --git a/docs/description/strong_iboutlet.md b/docs/description/strong_iboutlet.md old mode 100644 new mode 100755 index ccfad1a..9f5d577 --- a/docs/description/strong_iboutlet.md +++ b/docs/description/strong_iboutlet.md @@ -4,7 +4,7 @@ * **Identifier:** strong_iboutlet * **Enabled by default:** Disabled -* **Supports autocorrection:** No +* **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 3.0.0 @@ -28,18 +28,18 @@ class ViewController: UIViewController { ```swift class ViewController: UIViewController { - @IBOutlet weak ↓var label: UILabel? + @IBOutlet ↓weak var label: UILabel? } ``` ```swift class ViewController: UIViewController { - @IBOutlet unowned ↓var label: UILabel! + @IBOutlet ↓unowned var label: UILabel! } ``` ```swift class ViewController: UIViewController { - @IBOutlet weak ↓var textField: UITextField? + @IBOutlet ↓weak var textField: UITextField? } ``` \ No newline at end of file diff --git a/docs/description/superfluous_disable_command.md b/docs/description/superfluous_disable_command.md old mode 100644 new mode 100755 diff --git a/docs/description/switch_case_alignment.md b/docs/description/switch_case_alignment.md old mode 100644 new mode 100755 diff --git a/docs/description/switch_case_on_newline.md b/docs/description/switch_case_on_newline.md old mode 100644 new mode 100755 diff --git a/docs/description/syntactic_sugar.md b/docs/description/syntactic_sugar.md old mode 100644 new mode 100755 diff --git a/docs/description/test_case_accessibility.md b/docs/description/test_case_accessibility.md new file mode 100755 index 0000000..d4f0ca8 --- /dev/null +++ b/docs/description/test_case_accessibility.md @@ -0,0 +1,101 @@ +# Test case accessibility + +Test cases should only contain private non-test members. + +* **Identifier:** test_case_accessibility +* **Enabled by default:** Disabled +* **Supports autocorrection:** Yes +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 3.0.0 +* **Default configuration:** warning, allowed_prefixes: [[]] + +## Non Triggering Examples + +```swift +let foo: String? + +class FooTests: XCTestCase { + static let allTests: [String] = [] + + private let foo: String { + let nestedMember = "hi" + return nestedMember + } + + override static func setUp() { + super.setUp() + } + + override func setUp() { + super.setUp() + } + + override func setUpWithError() throws { + try super.setUpWithError() + } + + override static func tearDown() { + super.tearDown() + } + + override func tearDown() { + super.tearDown() + } + + override func tearDownWithError() { + try super.tearDownWithError() + } + + override func someFutureXCTestFunction() { + super.someFutureXCTestFunction() + } + + func testFoo() { + XCTAssertTrue(true) + } +} +``` + +```swift +class FooTests: XCTestCase { + func allowedPrefixTestFoo() {} +} +``` + +```swift +class Foobar { + func setUp() {} + + func tearDown() {} + + func testFoo() {} +} +``` + +## Triggering Examples + +```swift +class FooTests: XCTestCase { + ↓var foo: String? + ↓let bar: String? + + ↓static func foo() {} + + ↓func setUp(withParam: String) {} + + ↓func foobar() {} + + ↓func not_testBar() {} + + ↓enum Nested {} + + ↓static func testFoo() {} + + ↓static func allTests() {} +} + +final class BarTests: XCTestCase { + ↓class Nested {} +} +``` \ No newline at end of file diff --git a/docs/description/todo.md b/docs/description/todo.md old mode 100644 new mode 100755 diff --git a/docs/description/toggle_bool.md b/docs/description/toggle_bool.md old mode 100644 new mode 100755 index 48ea7ef..a0095b8 --- a/docs/description/toggle_bool.md +++ b/docs/description/toggle_bool.md @@ -36,6 +36,10 @@ disconnected = !connected ``` +```swift +result = !result.toggle() +``` + ## Triggering Examples ```swift diff --git a/docs/description/trailing_closure.md b/docs/description/trailing_closure.md old mode 100644 new mode 100755 diff --git a/docs/description/trailing_comma.md b/docs/description/trailing_comma.md old mode 100644 new mode 100755 diff --git a/docs/description/trailing_newline.md b/docs/description/trailing_newline.md old mode 100644 new mode 100755 diff --git a/docs/description/trailing_semicolon.md b/docs/description/trailing_semicolon.md old mode 100644 new mode 100755 index 15e18d2..7147019 --- a/docs/description/trailing_semicolon.md +++ b/docs/description/trailing_semicolon.md @@ -17,6 +17,10 @@ let a = 0 ``` +```swift +let a = 0; let b = 0 +``` + ## Triggering Examples ```swift @@ -28,19 +32,4 @@ let a = 0↓; let a = 0↓; let b = 1 -``` - -```swift -let a = 0↓;; - -``` - -```swift -let a = 0↓; ;; - -``` - -```swift -let a = 0↓; ; ; - ``` \ No newline at end of file diff --git a/docs/description/trailing_whitespace.md b/docs/description/trailing_whitespace.md old mode 100644 new mode 100755 diff --git a/docs/description/type_body_length.md b/docs/description/type_body_length.md old mode 100644 new mode 100755 diff --git a/docs/description/type_contents_order.md b/docs/description/type_contents_order.md old mode 100644 new mode 100755 diff --git a/docs/description/type_name.md b/docs/description/type_name.md old mode 100644 new mode 100755 diff --git a/docs/description/unavailable_function.md b/docs/description/unavailable_function.md old mode 100644 new mode 100755 index 10a423b..5e22a1d --- a/docs/description/unavailable_function.md +++ b/docs/description/unavailable_function.md @@ -16,7 +16,7 @@ Unimplemented functions should be marked as unavailable. class ViewController: UIViewController { @available(*, unavailable) public required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") + preconditionFailure("init(coder:) has not been implemented") } } ``` @@ -34,6 +34,14 @@ func jsonValue(_ jsonString: String) -> NSObject { } ``` +```swift +func resetOnboardingStateAndCrash() -> Never { + resetUserDefaults() + // Crash the app to re-start the onboarding flow. + fatalError("Onboarding re-start crash.") +} +``` + ## Triggering Examples ```swift @@ -51,4 +59,20 @@ class ViewController: UIViewController { fatalError(reason) } } +``` + +```swift +class ViewController: UIViewController { + public required ↓init?(coder aDecoder: NSCoder) { + preconditionFailure("init(coder:) has not been implemented") + } +} +``` + +```swift +func resetOnboardingStateAndCrash() { + resetUserDefaults() + // Crash the app to re-start the onboarding flow. + fatalError("Onboarding re-start crash.") +} ``` \ No newline at end of file diff --git a/docs/description/unneeded_break_in_switch.md b/docs/description/unneeded_break_in_switch.md old mode 100644 new mode 100755 diff --git a/docs/description/unneeded_notification_center_removal.md b/docs/description/unneeded_notification_center_removal.md deleted file mode 100644 index f295895..0000000 --- a/docs/description/unneeded_notification_center_removal.md +++ /dev/null @@ -1,56 +0,0 @@ -# Unneeded NotificationCenter Removal - -Observers are automatically unregistered on dealloc (iOS 9 / macOS 10.11) so you should't call `removeObserver(self)` in the deinit. - -* **Identifier:** unneeded_notification_center_removal -* **Enabled by default:** Enabled -* **Supports autocorrection:** No -* **Kind:** lint -* **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning - -## Non Triggering Examples - -```swift -class Example { - deinit { - NotificationCenter.default.removeObserver(someOtherObserver) - } -} -``` - -```swift -class Example { - func removeObservers() { - NotificationCenter.default.removeObserver(self) - } -} -``` - -```swift -class Example { - deinit { - cleanup() - } -} -``` - -## Triggering Examples - -```swift -class Foo { - deinit { - NotificationCenter.default.removeObserver(↓self) - } -} -``` - -```swift -class Foo { - deinit { - NotificationCenter.default.removeObserver(↓self, - name: UITextView.textDidChangeNotification, object: nil) - } -} -``` \ No newline at end of file diff --git a/docs/description/unneeded_parentheses_in_closure_argument.md b/docs/description/unneeded_parentheses_in_closure_argument.md old mode 100644 new mode 100755 diff --git a/docs/description/unowned_variable_capture.md b/docs/description/unowned_variable_capture.md old mode 100644 new mode 100755 diff --git a/docs/description/untyped_error_in_catch.md b/docs/description/untyped_error_in_catch.md old mode 100644 new mode 100755 diff --git a/docs/description/unused_capture_list.md b/docs/description/unused_capture_list.md old mode 100644 new mode 100755 index 4edeca0..48a27ea --- a/docs/description/unused_capture_list.md +++ b/docs/description/unused_capture_list.md @@ -12,6 +12,17 @@ Unused reference in a capture list should be removed. ## Non Triggering Examples +```swift +[1, 2].map { + [ weak + delegate, + unowned + self + ] num in + delegate.handle(num) +} +``` + ```swift [1, 2].map { [weak self] num in self?.handle(num) @@ -47,6 +58,46 @@ withEnvironment(apiService: MockService(fetchProjectResponse: project)) { sizes.max().flatMap { [(offset: offset, size: $0)] } ?? [] ``` +```swift +[1, 2].map { [self] num in + handle(num) +} +``` + +```swift +[1, 2].map { [unowned self] num in + handle(num) +} +``` + +```swift +[1, 2].map { [self, unowned delegate = self.delegate!] num in + delegate.handle(num) +} +``` + +```swift +[1, 2].map { [unowned self, unowned delegate = self.delegate!] num in + delegate.handle(num) +} +``` + +```swift +[1, 2].map { + [ weak + delegate, + self + ] num in + delegate.handle(num) +} +``` + +```swift +rx.onViewDidAppear.subscribe(onNext: { [unowned self] in + doSomething() +}).disposed(by: disposeBag) +``` + ## Triggering Examples ```swift @@ -74,6 +125,13 @@ numbers.forEach({ }) ``` +```swift +numbers.forEach({ + [self, weak handler] in + print($0) +}) +``` + ```swift withEnvironment(apiService: MockService(fetchProjectResponse: project)) { [↓foo] in [Device.phone4_7inch, Device.phone5_8inch, Device.pad].forEach { device in diff --git a/docs/description/unused_closure_parameter.md b/docs/description/unused_closure_parameter.md old mode 100644 new mode 100755 index ac25104..3164dd9 --- a/docs/description/unused_closure_parameter.md +++ b/docs/description/unused_closure_parameter.md @@ -7,7 +7,7 @@ Unused parameter in a closure should be replaced with _. * **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 4.2.0 * **Default configuration:** warning ## Non Triggering Examples @@ -103,6 +103,12 @@ viewModel?.profileImage.didSet(weak: self) { (self, profileImage) in } ``` +```swift +let failure: Failure = { task, error in + observer.sendFailed(error, task) +} +``` + ## Triggering Examples ```swift @@ -169,4 +175,10 @@ func foo () { viewModel?.profileImage.didSet(weak: self) { (↓self, profileImage) in profileImageView.image = profileImage } +``` + +```swift +let failure: Failure = { ↓task, error in + observer.sendFailed(error) +} ``` \ No newline at end of file diff --git a/docs/description/unused_control_flow_label.md b/docs/description/unused_control_flow_label.md old mode 100644 new mode 100755 diff --git a/docs/description/unused_declaration.md b/docs/description/unused_declaration.md old mode 100644 new mode 100755 index cf56ad8..07faffd --- a/docs/description/unused_declaration.md +++ b/docs/description/unused_declaration.md @@ -8,7 +8,7 @@ Declarations should be referenced at least once within all files linted. * **Kind:** lint * **Analyzer rule:** Yes * **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** severity: error, include_public_and_open: false +* **Default configuration:** severity: error, include_public_and_open: false, related_usrs_to_skip: ["s:7SwiftUI15PreviewProviderP"] ## Non Triggering Examples @@ -60,6 +60,67 @@ class ResponseModel { _ = ResponseModel() ``` +```swift +public func foo() {} +``` + +```swift +protocol Foo {} + +extension Foo { + func bar() {} +} + +struct MyStruct: Foo {} +MyStruct().bar() +``` + +```swift +import XCTest +class MyTests: XCTestCase { + func testExample() {} +} +``` + +```swift +import XCTest +open class BestTestCase: XCTestCase {} +class MyTests: BestTestCase { + func testExample() {} +} +``` + +```swift +enum Component { + case string(StaticString) + indirect case array([Component]) + indirect case optional(Component?) +} + +@_functionBuilder +struct ComponentBuilder { + static func buildExpression(_ string: StaticString) -> Component { + return .string(string) + } + + static func buildBlock(_ components: Component...) -> Component { + return .array(components) + } + + static func buildIf(_ value: Component?) -> Component { + return .optional(value) + } +} + +func acceptComponentBuilder(@ComponentBuilder _ body: () -> Component) { + print(body()) +} + +acceptComponentBuilder { + "hello" +} +``` + ## Triggering Examples ```swift @@ -82,4 +143,57 @@ class ↓ResponseModel { func ↓foo() { } } +``` + +```swift +public func ↓foo() {} +``` + +```swift +protocol Foo { + func ↓bar1() +} + +extension Foo { + func bar1() {} + func ↓bar2() {} +} + +struct MyStruct: Foo {} +_ = MyStruct() +``` + +```swift +import XCTest +class ↓MyTests: NSObject { + func ↓testExample() {} +} +``` + +```swift +enum Component { + case string(StaticString) + indirect case array([Component]) + indirect case optional(Component?) +} + +struct ComponentBuilder { + func ↓buildExpression(_ string: StaticString) -> Component { + return .string(string) + } + + func ↓buildBlock(_ components: Component...) -> Component { + return .array(components) + } + + func ↓buildIf(_ value: Component?) -> Component { + return .optional(value) + } + + static func ↓buildABear(_ components: Component...) -> Component { + return .array(components) + } +} + +_ = ComponentBuilder() ``` \ No newline at end of file diff --git a/docs/description/unused_enumerated.md b/docs/description/unused_enumerated.md old mode 100644 new mode 100755 diff --git a/docs/description/unused_import.md b/docs/description/unused_import.md old mode 100644 new mode 100755 index 534c6c7..2fed7d2 --- a/docs/description/unused_import.md +++ b/docs/description/unused_import.md @@ -8,7 +8,7 @@ All imported modules should be required to make the file compile. * **Kind:** lint * **Analyzer rule:** Yes * **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** severity: warning, require_explicit_imports: false, allowed_transitive_imports: [] +* **Default configuration:** severity: warning, require_explicit_imports: false, allowed_transitive_imports: [], always_keep_imports: [] ## Non Triggering Examples @@ -75,9 +75,4 @@ class A {} ↓import Foundation import UnknownModule func foo(error: Swift.Error) {} -``` - -```swift -↓import Foundation -typealias Foo = CFData ``` \ No newline at end of file diff --git a/docs/description/unused_optional_binding.md b/docs/description/unused_optional_binding.md old mode 100644 new mode 100755 diff --git a/docs/description/unused_setter_value.md b/docs/description/unused_setter_value.md old mode 100644 new mode 100755 diff --git a/docs/description/valid_ibinspectable.md b/docs/description/valid_ibinspectable.md old mode 100644 new mode 100755 diff --git a/docs/description/vertical_parameter_alignment.md b/docs/description/vertical_parameter_alignment.md old mode 100644 new mode 100755 diff --git a/docs/description/vertical_parameter_alignment_on_call.md b/docs/description/vertical_parameter_alignment_on_call.md old mode 100644 new mode 100755 diff --git a/docs/description/vertical_whitespace.md b/docs/description/vertical_whitespace.md old mode 100644 new mode 100755 diff --git a/docs/description/vertical_whitespace_between_cases.md b/docs/description/vertical_whitespace_between_cases.md old mode 100644 new mode 100755 diff --git a/docs/description/vertical_whitespace_closing_braces.md b/docs/description/vertical_whitespace_closing_braces.md old mode 100644 new mode 100755 index 11cbeb3..6600927 --- a/docs/description/vertical_whitespace_closing_braces.md +++ b/docs/description/vertical_whitespace_closing_braces.md @@ -12,28 +12,6 @@ Don't include vertical whitespace (empty line) before closing braces. ## Non Triggering Examples -```swift - ) -} - } -} -``` - -```swift - print("x is 5") -} -``` - -```swift - print("x is 5") -} -``` - -```swift - print("x is 5") -} -``` - ```swift /* class X { @@ -53,55 +31,48 @@ Don't include vertical whitespace (empty line) before closing braces. ``` ```swift -[1, 2].map { $0 }.filter { +[1, 2].map { $0 }.filter { num in true } ``` ```swift -[1, 2].map { $0 }.filter { num in +[1, 2].map { $0 }.filter { true } ``` ```swift -class Name { - run(5) { x in print(x) } +do { + print("x is 5") } ``` ```swift -foo( -x: 5, -y:6 -) -``` - -## Triggering Examples - -```swift - ) -} -↓ - } +do { + print("x is 5") } ``` ```swift - print("x is 5") -↓ - +do { + print("x is 5") } ``` ```swift - print("x is 5") -↓ -} +foo( + x: 5, + y:6 +) ``` ```swift - print("x is 5") -↓ +func foo() { + run(5) { x in + print(x) + } } ``` +## Triggering Examples + ```swift [ 1, @@ -112,16 +83,41 @@ y:6 ``` ```swift -class Name { - run(5) { x in print(x) } +do { + print("x is 5") +↓ + +} +``` + +```swift +do { + print("x is 5") +↓ + +} +``` + +```swift +do { + print("x is 5") ↓ } ``` ```swift foo( -x: 5, -y:6 + x: 5, + y:6 ↓ ) +``` + +```swift +func foo() { + run(5) { x in + print(x) + } +↓ +} ``` \ No newline at end of file diff --git a/docs/description/vertical_whitespace_opening_braces.md b/docs/description/vertical_whitespace_opening_braces.md old mode 100644 new mode 100755 index ae52009..4bbf0ad --- a/docs/description/vertical_whitespace_opening_braces.md +++ b/docs/description/vertical_whitespace_opening_braces.md @@ -23,12 +23,13 @@ Don't include vertical whitespace (empty line) after opening braces. ``` ```swift -// [1, 2].map { $0 }.filter { num in +// [1, 2].map { $0 }.filter { num in true } ``` ```swift KingfisherManager.shared.retrieveImage(with: url, options: nil, progressBlock: nil) { image, _, _, _ in guard let img = image else { return } +} ``` ```swift @@ -40,71 +41,60 @@ KingfisherManager.shared.retrieveImage(with: url, options: nil, progressBlock: n ``` ```swift -[1, 2].map { $0 }.filter { num in +[1, 2].map { $0 }.filter { num in true } ``` ```swift [1, 2].map { $0 }.foo() ``` -```swift -class Name { - run(5) { x in print(x) } -} -``` - ```swift class X { - struct Y { + struct Y { class Z { - + } + } +} ``` ```swift foo( -x: 5, -y:6 + x: 5, + y:6 ) ``` ```swift -if x == 5 { - print("x is 5") +foo({ }) { _ in + self.dismiss(animated: false, completion: { + }) +} ``` ```swift -if x == 5 { - print("x is 5") +func foo() { + run(5) { x in + print(x) + } +} ``` ```swift if x == 5 { - print("x is 5") + print("x is 5") +} ``` ```swift if x == 5 { print("x is 5") -``` - -```swift -struct MyStruct { - let x = 5 -``` - -```swift -struct MyStruct { - let x = 5 +} ``` ```swift struct MyStruct { let x = 5 -``` - -```swift -}) { _ in - self.dismiss(animated: false, completion: { +} ``` ## Triggering Examples @@ -113,6 +103,7 @@ struct MyStruct { KingfisherManager.shared.retrieveImage(with: url, options: nil, progressBlock: nil) { image, _, _, _ in ↓ guard let img = image else { return } +} ``` ```swift @@ -124,74 +115,59 @@ KingfisherManager.shared.retrieveImage(with: url, options: nil, progressBlock: n ] ``` -```swift -class Name { -↓ - run(5) { x in print(x) } -} -``` - ```swift class X { - struct Y { + struct Y { ↓ class Z { - + } + } +} ``` ```swift foo( ↓ -x: 5, -y:6 + x: 5, + y:6 ) ``` ```swift -if x == 5 { +foo({ }) { _ in ↓ - print("x is 5") + self.dismiss(animated: false, completion: { + }) +} ``` ```swift -if x == 5 { +func foo() { ↓ - - print("x is 5") + run(5) { x in + print(x) + } +} ``` ```swift if x == 5 { ↓ - print("x is 5") -``` -```swift -if x == 5 { -↓ print("x is 5") +} ``` ```swift -struct MyStruct { -↓ - let x = 5 -``` - -```swift -struct MyStruct { +if x == 5 { ↓ - let x = 5 + print("x is 5") +} ``` ```swift struct MyStruct { ↓ let x = 5 -``` - -```swift -}) { _ in -↓ - self.dismiss(animated: false, completion: { +} ``` \ No newline at end of file diff --git a/docs/description/void_return.md b/docs/description/void_return.md old mode 100644 new mode 100755 index 6a57efe..a8a1943 --- a/docs/description/void_return.md +++ b/docs/description/void_return.md @@ -28,22 +28,22 @@ func foo(completion: () -> Void) ``` ```swift -let foo: (ConfigurationTests) -> () throws -> Void) +let foo: (ConfigurationTests) -> () throws -> Void ``` ```swift -let foo: (ConfigurationTests) -> () throws -> Void) +let foo: (ConfigurationTests) -> () throws -> Void ``` ```swift -let foo: (ConfigurationTests) ->() throws -> Void) +let foo: (ConfigurationTests) ->() throws -> Void ``` ```swift -let foo: (ConfigurationTests) -> () -> Void) +let foo: (ConfigurationTests) -> () -> Void ``` @@ -80,6 +80,6 @@ func foo(completion: () -> ↓(Void)) ``` ```swift -let foo: (ConfigurationTests) -> () throws -> ↓()) +let foo: (ConfigurationTests) -> () throws -> ↓() ``` \ No newline at end of file diff --git a/docs/description/weak_delegate.md b/docs/description/weak_delegate.md old mode 100644 new mode 100755 index adf4898..81cf4ce --- a/docs/description/weak_delegate.md +++ b/docs/description/weak_delegate.md @@ -78,6 +78,12 @@ class Foo { } ``` +```swift +struct Foo { + @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/xct_specific_matcher.md b/docs/description/xct_specific_matcher.md old mode 100644 new mode 100755 diff --git a/docs/description/xctfail_message.md b/docs/description/xctfail_message.md old mode 100644 new mode 100755 diff --git a/docs/description/yoda_condition.md b/docs/description/yoda_condition.md old mode 100644 new mode 100755 index 8e9b9cd..bfa6cb0 --- a/docs/description/yoda_condition.md +++ b/docs/description/yoda_condition.md @@ -42,15 +42,15 @@ while foo > 1 { } ``` ```swift -while foo + 1 == 2 +while foo + 1 == 2 {} ``` ```swift -if optionalValue?.property ?? 0 == 2 +if optionalValue?.property ?? 0 == 2 {} ``` ```swift -if foo == nil +if foo == nil {} ``` ## Triggering Examples @@ -83,5 +83,5 @@ if foo == nil ``` ```swift -↓if nil == foo +↓if nil == foo {} ``` \ No newline at end of file diff --git a/docs/patterns.json b/docs/patterns.json index b52a399..4fd787c 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -1,6 +1,6 @@ { "name" : "swiftlint", - "version" : "0.40.0", + "version" : "0.43.1", "patterns" : [ { "patternId" : "anyobject_protocol", "level" : "Warning", @@ -22,6 +22,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "balanced_xctest_lifecycle", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "block_based_kvo", "level" : "Warning", @@ -29,6 +36,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "capture_variable", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "class_delegate_protocol", "level" : "Warning", @@ -92,6 +106,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "comment_spacing", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true }, { "patternId" : "compiler_protocol_init", "level" : "Warning", @@ -182,7 +203,14 @@ "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], - "enabled" : true + "enabled" : false + }, { + "patternId" : "discouraged_assert", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "discouraged_direct_init", "level" : "Info", @@ -505,6 +533,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "inclusive_language", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true }, { "patternId" : "indentation_width", "level" : "Info", @@ -596,6 +631,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "legacy_objc_type", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "legacy_random", "level" : "Warning", @@ -682,7 +724,7 @@ "enabled" : false }, { "patternId" : "multiline_parameters", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -787,14 +829,14 @@ "enabled" : false }, { "patternId" : "opening_brace", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "operator_usage_whitespace", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -841,6 +883,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "prefer_nimble", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "prefer_self_type_over_type_of_self", "level" : "Warning", @@ -883,6 +932,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "private_subject", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "private_unit_test", "level" : "Info", @@ -1114,6 +1170,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "test_case_accessibility", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "todo", "level" : "Warning", @@ -1198,13 +1261,6 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true - }, { - "patternId" : "unneeded_notification_center_removal", - "level" : "Warning", - "category" : "ErrorProne", - "parameters" : [ ], - "languages" : [ ], - "enabled" : true }, { "patternId" : "unneeded_parentheses_in_closure_argument", "level" : "Warning", From 5d89f02095a8146d63df9a56ada0378cf4834c51 Mon Sep 17 00:00:00 2001 From: rubensantoscodacy Date: Wed, 6 Jul 2022 12:24:22 +0100 Subject: [PATCH 051/119] Usage default config file usage behavior of swiftlint (don't specify config file) --- .../patterns.xml | 4 ++++ .../results.xml | 7 +++++++ .../src/.swiftlint.yml | 2 ++ .../src/main.swift | 5 +++++ .../src/sub_module/.swiftlint.yml | 5 +++++ .../src/sub_module/sub_main.swift | 5 +++++ src/main/scala/codacy/swiftlint/SwiftLint.scala | 16 +--------------- 7 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml create mode 100644 docs/multiple-tests/multiple-config-submodules-and-custom-rules/results.xml create mode 100644 docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/.swiftlint.yml create mode 100644 docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/main.swift create mode 100644 docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/sub_module/.swiftlint.yml create mode 100644 docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/sub_module/sub_main.swift diff --git a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml new file mode 100644 index 0000000..bfab521 --- /dev/null +++ b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml @@ -0,0 +1,4 @@ + + + + diff --git a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/results.xml b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/results.xml new file mode 100644 index 0000000..e691e4d --- /dev/null +++ b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/results.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/.swiftlint.yml b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/.swiftlint.yml new file mode 100644 index 0000000..8477628 --- /dev/null +++ b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/.swiftlint.yml @@ -0,0 +1,2 @@ +disabled_rules: + - todo diff --git a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/main.swift b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/main.swift new file mode 100644 index 0000000..23dac9b --- /dev/null +++ b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/main.swift @@ -0,0 +1,5 @@ +// TODO: something special + +debugPrint("something to debug") + +// TODO [MAGIC-101]: yeah magic diff --git a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/sub_module/.swiftlint.yml b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/sub_module/.swiftlint.yml new file mode 100644 index 0000000..74f4759 --- /dev/null +++ b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/sub_module/.swiftlint.yml @@ -0,0 +1,5 @@ +custom_rules: + jira_todo: + name: "TODOs and FIXMEs should be resolved or task should be created" + regex: '\b(?:TODO|FIXME)[^\[]*(?!\[[\w-]+\])[^\[]*$' + message: "TODO/FIXME is not acceptable without JIRA TASK ID. Include Jira ID in the message: `TODO: [ABC-XXX] Fix this line`" \ No newline at end of file diff --git a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/sub_module/sub_main.swift b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/sub_module/sub_main.swift new file mode 100644 index 0000000..1c39712 --- /dev/null +++ b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/src/sub_module/sub_main.swift @@ -0,0 +1,5 @@ +// TODO: submodule something special + +debugPrint("something to debug") + +// TODO [MAGIC-101]: submodule yeah magic diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index 2d374af..5c1f4bf 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -47,10 +47,6 @@ object SwiftLint extends Tool { } } - def nativeConfigurationFile(source: Source.Directory): Option[String] = { - FileHelper.findConfigurationFile(Paths.get(source.path), nativeConfigFileNames).map(_.toString) - } - def configsFromCodacyConfiguration( configuration: Option[List[Pattern.Definition]] )(implicit specification: Tool.Specification): Option[String] = { @@ -62,16 +58,6 @@ object SwiftLint extends Tool { } } - def lintConfiguration(source: Source.Directory, configuration: Option[List[Pattern.Definition]])( - implicit specification: Tool.Specification - ): Option[String] = { - lazy val nativeConfig = nativeConfigurationFile(source) - - val config = configsFromCodacyConfiguration(configuration) - - config.orElse(nativeConfig) - } - private def commandToRun(configOpt: Option[String], file: String): List[String] = { val baseCmd = List("swiftlint", "lint", "--quiet", "--reporter", "json") @@ -120,7 +106,7 @@ object SwiftLint extends Tool { val filesToLint = listOfFilesToLint(files, source) - val cfgOpt = lintConfiguration(source, configuration) + val cfgOpt = configsFromCodacyConfiguration(configuration) filesToLint.flatMap { file => val command: List[String] = commandToRun(cfgOpt, file) From ec3fa745c0c9fefa4b0d87fda0ec5128fb0be2d7 Mon Sep 17 00:00:00 2001 From: rubensantoscodacy Date: Wed, 6 Jul 2022 12:39:19 +0100 Subject: [PATCH 052/119] bump: ci codacy@base --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fe501b9..f614b90 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codacy: codacy/base@4.2.7 + codacy: codacy/base@8.1.0 codacy_plugins_test: codacy/plugins-test@0.15.4 workflows: From 23a5d511206344a52cace0c330635c87af57c70d Mon Sep 17 00:00:00 2001 From: Vasco Dias Date: Wed, 6 Jul 2022 12:58:16 +0100 Subject: [PATCH 053/119] update the circle orb version --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fe501b9..f614b90 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codacy: codacy/base@4.2.7 + codacy: codacy/base@8.1.0 codacy_plugins_test: codacy/plugins-test@0.15.4 workflows: From 20b38d18e65e0ff97ab8539d46d53f7718a4915f Mon Sep 17 00:00:00 2001 From: rubensantoscodacy Date: Wed, 6 Jul 2022 13:01:08 +0100 Subject: [PATCH 054/119] Fix multiple-tests --- README.md | 3 +++ .../multiple-config-submodules-and-custom-rules/patterns.xml | 3 +++ .../multiple-config-submodules-and-custom-rules/results.xml | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a64ff26..1f6889d 100755 --- a/README.md +++ b/README.md @@ -23,6 +23,9 @@ The docker is ran with the following command: docker run -it -v $srcDir:/src : ``` +## Generate docs +Run `amm doc-generator.sc` + ## Test For a faster development loop you can create a Docker image based on the JVM instead of creating a native-image: diff --git a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml index bfab521..b08b9a3 100644 --- a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml +++ b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml @@ -1,4 +1,7 @@ + + + diff --git a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/results.xml b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/results.xml index e691e4d..b9d9a7a 100644 --- a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/results.xml +++ b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/results.xml @@ -1,7 +1,7 @@ - - + + From e9c48a8215fd789647e3cc86129d0d93378b7139 Mon Sep 17 00:00:00 2001 From: Vasco Dias Date: Wed, 6 Jul 2022 13:32:34 +0100 Subject: [PATCH 055/119] update the codacy test orb since it's segfaulting --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f614b90..3be92b3 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 orbs: codacy: codacy/base@8.1.0 - codacy_plugins_test: codacy/plugins-test@0.15.4 + codacy_plugins_test: codacy/plugins-test@1.1.1 workflows: version: 2 From 580fe05e85b566b09a64cd06a79913bd05c065f9 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Tue, 29 Nov 2022 10:27:24 +0100 Subject: [PATCH 056/119] feature: Update swiftlint to last version 0.50.1 --- Dockerfile | 4 ++-- Dockerfile.dev | 4 ++-- build.sbt | 14 +------------- doc-generator.sc | 2 +- project/build.properties | 2 +- src/main/scala/codacy/swiftlint/SwiftLint.scala | 5 ++--- 6 files changed, 9 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4352631..2b003f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM norionomura/swiftlint:0.43.1_swift-5.4.0 as builder +FROM norionomura/swiftlint:0.50.1_swift-5.7.0 as builder -FROM swift:5.5.0-xenial-slim +FROM swift:5.7.0-xenial-slim COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so diff --git a/Dockerfile.dev b/Dockerfile.dev index 1e169dd..fe4745c 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,6 +1,6 @@ -FROM norionomura/swiftlint:0.43.1_swift-5.4.0 as builder +FROM norionomura/swiftlint:0.50.1_swift-5.7.0 as builder -FROM swift:5.5.0-xenial-slim +FROM swift:5.7.0-xenial-slim RUN apt-get update && apt-get install -y openjdk-8-jre diff --git a/build.sbt b/build.sbt index 5d44990..48ce7a9 100755 --- a/build.sbt +++ b/build.sbt @@ -2,19 +2,7 @@ organization := "com.codacy" name := "codacy-swiftlint" -scalaVersion := "2.13.3" - -lazy val swiftlintVersion = Def.setting("1.10.0") - -Compile / sourceGenerators += Def.task { - val file = (Compile / sourceManaged).value / "codacy" / "swiftlint" / "Versions.scala" - IO.write(file, s"""package codacy.swiftlint - |object Versions { - | val swiftlintVersion: String = "${swiftlintVersion.value}" - |} - |""".stripMargin) - Seq(file) -}.taskValue +scalaVersion := "2.13.10" enablePlugins(GraalVMNativeImagePlugin) diff --git a/doc-generator.sc b/doc-generator.sc index c013fd8..81cd4ed 100644 --- a/doc-generator.sc +++ b/doc-generator.sc @@ -19,7 +19,7 @@ val baseCommand = Seq( ) os.proc(baseCommand :+ "generate-docs").call() -// Hack: docker in CircleCI makes files only available to the root user +// Hack: docker in CircleCI makes files only available to the root user os.proc("sudo", "chmod", "-R", "777", tempDir).call() val rulesOutput = os.proc(baseCommand :+ "rules").call().out.lines().map(_.split('|').map(_.trim).toList.tail).tail diff --git a/project/build.properties b/project/build.properties index d91c272..8b9a0b0 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.6 +sbt.version=1.8.0 diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index 5c1f4bf..05907f5 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -52,9 +52,8 @@ object SwiftLint extends Tool { )(implicit specification: Tool.Specification): Option[String] = { val patternsToLintOpt = configuration.withDefaultParameters - patternsToLintOpt.fold(Option.empty[String]) { - case patternsToLint if patternsToLint.nonEmpty => - Some(writeConfigFile(patternsToLint).toString) + patternsToLintOpt.map { patternsToLint => + writeConfigFile(patternsToLint).toString } } From da6fa1a7bc4b02ae217e143509236b70172d80d5 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Tue, 29 Nov 2022 10:59:47 +0100 Subject: [PATCH 057/119] fix: Update base image --- Dockerfile | 2 +- Dockerfile.dev | 2 +- doc-generator.sc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2b003f9..8cc1813 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM norionomura/swiftlint:0.50.1_swift-5.7.0 as builder -FROM swift:5.7.0-xenial-slim +FROM swift:5.7.0-jammy-slim COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so diff --git a/Dockerfile.dev b/Dockerfile.dev index fe4745c..996df8d 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,6 +1,6 @@ FROM norionomura/swiftlint:0.50.1_swift-5.7.0 as builder -FROM swift:5.7.0-xenial-slim +FROM swift:5.7.0-jammy-slim RUN apt-get update && apt-get install -y openjdk-8-jre diff --git a/doc-generator.sc b/doc-generator.sc index 81cd4ed..400233d 100644 --- a/doc-generator.sc +++ b/doc-generator.sc @@ -1,4 +1,4 @@ -import $ivy.`com.codacy::codacy-engine-scala-seed:5.0.3` +import $ivy.`com.codacy::codacy-engine-scala-seed:6.0.1` import com.codacy.plugins.api._ import com.codacy.plugins.api.results._ From 459c9649804f7f2d4e2e74357e175034108672a4 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 4 Jan 2023 16:40:45 +0100 Subject: [PATCH 058/119] Update to scala-cli and fix scalafmt checks --- .circleci/config.yml | 9 +++---- .gitignore | 2 +- doc-generator.sc | 4 +++- scala-cli | 57 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 8 deletions(-) create mode 100755 scala-cli diff --git a/.circleci/config.yml b/.circleci/config.yml index 3be92b3..dea3560 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,15 +13,12 @@ workflows: - codacy/sbt: name: publish_docker_local cmd: | - sbt "scalafmt::test; - test:scalafmt::test; - sbt:scalafmt::test; + sbt "scalafmtCheckAll; + scalafmtSbtCheck; graalvm-native-image:packageBin" docker build -t $CIRCLE_PROJECT_REPONAME:latest . - # Install Ammonite - sudo sh -c '(echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/Ammonite/releases/download/2.3.8/2.13-2.3.8) > /usr/local/bin/amm && chmod +x /usr/local/bin/amm' # Run doc-generator - sudo amm doc-generator.sc + sudo ./scala-cli doc-generator.sc # Update docker image with generated docs docker build -t $CIRCLE_PROJECT_REPONAME:latest . docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest diff --git a/.gitignore b/.gitignore index ad209d4..e0f59f1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ target .bloop .vscode .bsp -.ammonite +.scala-build diff --git a/doc-generator.sc b/doc-generator.sc index 400233d..38a8e58 100644 --- a/doc-generator.sc +++ b/doc-generator.sc @@ -1,4 +1,6 @@ -import $ivy.`com.codacy::codacy-engine-scala-seed:6.0.1` +//> using scala "2" +//> using lib "com.codacy::codacy-engine-scala-seed:6.0.1" +//> using lib "com.lihaoyi::os-lib:0.9.0" import com.codacy.plugins.api._ import com.codacy.plugins.api.results._ diff --git a/scala-cli b/scala-cli new file mode 100755 index 0000000..96ea5d9 --- /dev/null +++ b/scala-cli @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# This is the launcher script of Scala CLI (https://github.com/VirtusLab/scala-cli). +# This script downloads and runs the Scala CLI version set by SCALA_CLI_VERSION below. +# +# Download the latest version of this script at https://github.com/VirtusLab/scala-cli/raw/main/scala-cli.sh + +set -eu + +SCALA_CLI_VERSION="0.1.19" + +GH_ORG="VirtusLab" +GH_NAME="scala-cli" + +if [ "$SCALA_CLI_VERSION" == "nightly" ]; then + TAG="nightly" +else + TAG="v$SCALA_CLI_VERSION" +fi + +if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" == "Linux" ]; then + arch=$(uname -m) + if [[ "$arch" == "aarch64" ]] || [[ "$arch" == "x86_64" ]]; then + SCALA_CLI_URL="https://github.com/$GH_ORG/$GH_NAME/releases/download/$TAG/scala-cli-${arch}-pc-linux.gz" + else + echoerr "scala-cli is not supported on $arch" + exit 2 + fi + CACHE_BASE="$HOME/.cache/coursier/v1" +elif [ "$(uname)" == "Darwin" ]; then + SCALA_CLI_URL="https://github.com/$GH_ORG/$GH_NAME/releases/download/$TAG/scala-cli-x86_64-apple-darwin.gz" + CACHE_BASE="$HOME/Library/Caches/Coursier/v1" +else + echo "This standalone scala-cli launcher is supported only in Linux and macOS. If you are using Windows, please use the dedicated launcher scala-cli.bat" + exit 1 +fi + +CACHE_DEST="$CACHE_BASE/$(echo "$SCALA_CLI_URL" | sed 's@://@/@')" +SCALA_CLI_BIN_PATH=${CACHE_DEST%.gz} + +if [ ! -f "$CACHE_DEST" ]; then + mkdir -p "$(dirname "$CACHE_DEST")" + TMP_DEST="$CACHE_DEST.tmp-setup" + echo "Downloading $SCALA_CLI_URL" + curl -fLo "$TMP_DEST" "$SCALA_CLI_URL" + mv "$TMP_DEST" "$CACHE_DEST" +fi + +if [ ! -f "$SCALA_CLI_BIN_PATH" ]; then + gunzip -k "$CACHE_DEST" +fi + +if [ ! -x "$SCALA_CLI_BIN_PATH" ]; then + chmod +x "$SCALA_CLI_BIN_PATH" +fi + +exec "$SCALA_CLI_BIN_PATH" "$@" From 90e73f648c6595867d7d396baf8c7ac6dc1c3666 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 4 Jan 2023 16:42:24 +0100 Subject: [PATCH 059/119] bump: Update codacy-sbt-plugin --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 46fe6a2..27833dc 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,2 @@ -addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "21.0.0") +addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "24.0.0") addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1") From e0550e4afac4370c61f68bc748c8e57be47fe719 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 4 Jan 2023 16:58:34 +0100 Subject: [PATCH 060/119] Migrate doc-generator to sbt --- .circleci/config.yml | 4 +- .gitignore | 6 -- build.sbt | 10 +- doc-generator.sc | 98 ------------------- .../src/main/scala/doc-generator.scala | 97 ++++++++++++++++++ scala-cli | 57 ----------- 6 files changed, 108 insertions(+), 164 deletions(-) delete mode 100644 doc-generator.sc create mode 100644 doc-generator/src/main/scala/doc-generator.scala delete mode 100755 scala-cli diff --git a/.circleci/config.yml b/.circleci/config.yml index dea3560..a149e8f 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,9 +16,9 @@ workflows: sbt "scalafmtCheckAll; scalafmtSbtCheck; graalvm-native-image:packageBin" - docker build -t $CIRCLE_PROJECT_REPONAME:latest . + docker build -t $CIRCLE_PROJECT_REPONAME:latest -f Dockerfile.dev . # Run doc-generator - sudo ./scala-cli doc-generator.sc + sudo sbt doc-generator/run # Update docker image with generated docs docker build -t $CIRCLE_PROJECT_REPONAME:latest . docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest diff --git a/.gitignore b/.gitignore index e0f59f1..8f82c4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ -/RUNNING_PID -/logs/ -/project/*-shim.sbt -/project/project/ -/project/target/ target .idea .DS_Store @@ -10,4 +5,3 @@ target .bloop .vscode .bsp -.scala-build diff --git a/build.sbt b/build.sbt index 48ce7a9..33e19c6 100755 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ organization := "com.codacy" name := "codacy-swiftlint" -scalaVersion := "2.13.10" +ThisBuild / scalaVersion := "2.13.10" enablePlugins(GraalVMNativeImagePlugin) @@ -20,3 +20,11 @@ graalVMNativeImageOptions ++= Seq( "--report-unsupported-elements-at-runtime", "--static" ) + +lazy val `doc-generator` = project + .settings( + libraryDependencies ++= Seq( + "com.codacy" %% "codacy-engine-scala-seed" % "6.0.1", + "com.lihaoyi" %% "os-lib" % "0.9.0" + ) + ) diff --git a/doc-generator.sc b/doc-generator.sc deleted file mode 100644 index 38a8e58..0000000 --- a/doc-generator.sc +++ /dev/null @@ -1,98 +0,0 @@ -//> using scala "2" -//> using lib "com.codacy::codacy-engine-scala-seed:6.0.1" -//> using lib "com.lihaoyi::os-lib:0.9.0" - -import com.codacy.plugins.api._ -import com.codacy.plugins.api.results._ -import play.api.libs.json.Json - -val tempDir = os.temp.dir(dir = os.pwd / "target") - -val workdir = "/workdir" - -val baseCommand = Seq( - "docker", - "run", - s"--volume=$tempDir:$workdir", - s"-w=$workdir", - s"--user=root", - "--entrypoint=swiftlint", - "codacy-swiftlint" -) - -os.proc(baseCommand :+ "generate-docs").call() -// Hack: docker in CircleCI makes files only available to the root user -os.proc("sudo", "chmod", "-R", "777", tempDir).call() - -val rulesOutput = os.proc(baseCommand :+ "rules").call().out.lines().map(_.split('|').map(_.trim).toList.tail).tail - -val version = os.proc(baseCommand :+ "version").call().out.text().trim - -val mdFiles = os.list(tempDir / "rule_docs").filter(_.last != "Rule Directory.md") - -val docsDirectory = os.pwd / "docs" -val descriptionDirectory = docsDirectory / "description" - -val patternDescriptions = mdFiles.map { file => - val patternId = file.last.stripSuffix(".md") - val lines = os.read(file).linesIterator - val title = lines.next().stripPrefix("# ") - lines.next() - val description = lines.next() - Pattern.Description(Pattern.Id(patternId), Pattern.Title(title), Some(Pattern.DescriptionText(description)), None) -} - -val ids = rulesOutput.head.zipWithIndex.toMap - -case class SwiftlintRule( - identifier: String, - correctable: Boolean, - enabledInYourConfig: Boolean, - kind: String, - configuration: String -) - -val swiftLintRules = rulesOutput.tail - .filter(_.length == ids.size) - .map { arr => - def toBoolean(s: String) = s == "yes" - SwiftlintRule( - identifier = arr(ids("identifier")), - correctable = toBoolean(arr(ids("correctable"))), - enabledInYourConfig = toBoolean(arr(ids("enabled in your config"))), - kind = arr(ids("kind")), - configuration = arr(ids("configuration")) - ) - } - -def configurationToLevel(kind: String) = kind match { - case "warning" => Result.Level.Warn - case "error" => Result.Level.Err - case _ => Result.Level.Info -} - -def kindToCategory(kind: String) = kind match { - case "style" => Pattern.Category.CodeStyle - case "lint" => Pattern.Category.ErrorProne - case "performance" => Pattern.Category.Performance - case "metrics" => Pattern.Category.Complexity - case _ => Pattern.Category.ErrorProne -} - -val patternSpecifications = swiftLintRules.map { swiftLintRule => - Pattern.Specification( - Pattern.Id(swiftLintRule.identifier), - configurationToLevel(swiftLintRule.configuration), - kindToCategory(swiftLintRule.kind), - subcategory = None, - enabled = swiftLintRule.enabledInYourConfig - ) -} - -val specification = Tool.Specification(Tool.Name("swiftlint"), Some(Tool.Version(version)), patternSpecifications.toSet) - -os.write.over(os.pwd / "docs" / "patterns.json", Json.prettyPrint(Json.toJson(specification)) + "\n") -os.remove.all(descriptionDirectory) -mdFiles.foreach(os.copy.into(_, descriptionDirectory, replaceExisting = true, createFolders = true)) -os.write.over(descriptionDirectory / "description.json", Json.prettyPrint(Json.toJson(patternDescriptions)) + "\n") -os.remove.all(tempDir) diff --git a/doc-generator/src/main/scala/doc-generator.scala b/doc-generator/src/main/scala/doc-generator.scala new file mode 100644 index 0000000..c53ab16 --- /dev/null +++ b/doc-generator/src/main/scala/doc-generator.scala @@ -0,0 +1,97 @@ +import com.codacy.plugins.api._ +import com.codacy.plugins.api.results._ +import play.api.libs.json.Json + +object Main extends App { + val tempDir = os.temp.dir(dir = os.pwd / "target") + + val workdir = "/workdir" + + val baseCommand = Seq( + "docker", + "run", + s"--volume=$tempDir:$workdir", + s"-w=$workdir", + s"--user=root", + "--entrypoint=swiftlint", + "codacy-swiftlint" + ) + + os.proc(baseCommand :+ "generate-docs").call() +// Hack: docker in CircleCI makes files only available to the root user + os.proc("sudo", "chmod", "-R", "777", tempDir).call() + + val rulesOutput = os.proc(baseCommand :+ "rules").call().out.lines().map(_.split('|').map(_.trim).toList.tail).tail + + val version = os.proc(baseCommand :+ "version").call().out.text().trim + + val mdFiles = os.list(tempDir / "rule_docs").filter(_.last != "Rule Directory.md") + + val docsDirectory = os.pwd / "docs" + val descriptionDirectory = docsDirectory / "description" + + val patternDescriptions = mdFiles.map { file => + val patternId = file.last.stripSuffix(".md") + val lines = os.read(file).linesIterator + val title = lines.next().stripPrefix("# ") + lines.next() + val description = lines.next() + Pattern.Description(Pattern.Id(patternId), Pattern.Title(title), Some(Pattern.DescriptionText(description)), None) + } + + val ids = rulesOutput.head.zipWithIndex.toMap + + case class SwiftlintRule( + identifier: String, + correctable: Boolean, + enabledInYourConfig: Boolean, + kind: String, + configuration: String + ) + + val swiftLintRules = rulesOutput.tail + .filter(_.length == ids.size) + .map { arr => + def toBoolean(s: String) = s == "yes" + SwiftlintRule( + identifier = arr(ids("identifier")), + correctable = toBoolean(arr(ids("correctable"))), + enabledInYourConfig = toBoolean(arr(ids("enabled in your config"))), + kind = arr(ids("kind")), + configuration = arr(ids("configuration")) + ) + } + + def configurationToLevel(kind: String) = kind match { + case "warning" => Result.Level.Warn + case "error" => Result.Level.Err + case _ => Result.Level.Info + } + + def kindToCategory(kind: String) = kind match { + case "style" => Pattern.Category.CodeStyle + case "lint" => Pattern.Category.ErrorProne + case "performance" => Pattern.Category.Performance + case "metrics" => Pattern.Category.Complexity + case _ => Pattern.Category.ErrorProne + } + + val patternSpecifications = swiftLintRules.map { swiftLintRule => + Pattern.Specification( + Pattern.Id(swiftLintRule.identifier), + configurationToLevel(swiftLintRule.configuration), + kindToCategory(swiftLintRule.kind), + subcategory = None, + enabled = swiftLintRule.enabledInYourConfig + ) + } + + val specification = + Tool.Specification(Tool.Name("swiftlint"), Some(Tool.Version(version)), patternSpecifications.toSet) + + os.write.over(os.pwd / "docs" / "patterns.json", Json.prettyPrint(Json.toJson(specification)) + "\n") + os.remove.all(descriptionDirectory) + mdFiles.foreach(os.copy.into(_, descriptionDirectory, replaceExisting = true, createFolders = true)) + os.write.over(descriptionDirectory / "description.json", Json.prettyPrint(Json.toJson(patternDescriptions)) + "\n") + os.remove.all(tempDir) +} diff --git a/scala-cli b/scala-cli deleted file mode 100755 index 96ea5d9..0000000 --- a/scala-cli +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -# This is the launcher script of Scala CLI (https://github.com/VirtusLab/scala-cli). -# This script downloads and runs the Scala CLI version set by SCALA_CLI_VERSION below. -# -# Download the latest version of this script at https://github.com/VirtusLab/scala-cli/raw/main/scala-cli.sh - -set -eu - -SCALA_CLI_VERSION="0.1.19" - -GH_ORG="VirtusLab" -GH_NAME="scala-cli" - -if [ "$SCALA_CLI_VERSION" == "nightly" ]; then - TAG="nightly" -else - TAG="v$SCALA_CLI_VERSION" -fi - -if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" == "Linux" ]; then - arch=$(uname -m) - if [[ "$arch" == "aarch64" ]] || [[ "$arch" == "x86_64" ]]; then - SCALA_CLI_URL="https://github.com/$GH_ORG/$GH_NAME/releases/download/$TAG/scala-cli-${arch}-pc-linux.gz" - else - echoerr "scala-cli is not supported on $arch" - exit 2 - fi - CACHE_BASE="$HOME/.cache/coursier/v1" -elif [ "$(uname)" == "Darwin" ]; then - SCALA_CLI_URL="https://github.com/$GH_ORG/$GH_NAME/releases/download/$TAG/scala-cli-x86_64-apple-darwin.gz" - CACHE_BASE="$HOME/Library/Caches/Coursier/v1" -else - echo "This standalone scala-cli launcher is supported only in Linux and macOS. If you are using Windows, please use the dedicated launcher scala-cli.bat" - exit 1 -fi - -CACHE_DEST="$CACHE_BASE/$(echo "$SCALA_CLI_URL" | sed 's@://@/@')" -SCALA_CLI_BIN_PATH=${CACHE_DEST%.gz} - -if [ ! -f "$CACHE_DEST" ]; then - mkdir -p "$(dirname "$CACHE_DEST")" - TMP_DEST="$CACHE_DEST.tmp-setup" - echo "Downloading $SCALA_CLI_URL" - curl -fLo "$TMP_DEST" "$SCALA_CLI_URL" - mv "$TMP_DEST" "$CACHE_DEST" -fi - -if [ ! -f "$SCALA_CLI_BIN_PATH" ]; then - gunzip -k "$CACHE_DEST" -fi - -if [ ! -x "$SCALA_CLI_BIN_PATH" ]; then - chmod +x "$SCALA_CLI_BIN_PATH" -fi - -exec "$SCALA_CLI_BIN_PATH" "$@" From 1ca1ef44102199017f024b714b94bf3e6ee27f60 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 4 Jan 2023 17:46:02 +0100 Subject: [PATCH 061/119] Update build to use steps --- .circleci/config.yml | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a149e8f..9b5497d 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,18 +10,30 @@ workflows: jobs: - codacy/checkout_and_version: write_sbt_version: true - - codacy/sbt: + - codacy/sbt_docker: name: publish_docker_local - cmd: | - sbt "scalafmtCheckAll; - scalafmtSbtCheck; - graalvm-native-image:packageBin" - docker build -t $CIRCLE_PROJECT_REPONAME:latest -f Dockerfile.dev . - # Run doc-generator - sudo sbt doc-generator/run - # Update docker image with generated docs - docker build -t $CIRCLE_PROJECT_REPONAME:latest . - docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest + steps: + - run: + name: Check Scalafmt on sources + command: sbt scalafmtCheckAll + - run: + name: Check Scalafmt on Sbt sources + command: sbt scalafmtSbtCheck + - run: + name: Build Development Docker image + command: docker build -t $CIRCLE_PROJECT_REPONAME:latest -f Dockerfile.dev . + - run: + name: Build Development Docker image + command: docker build -t $CIRCLE_PROJECT_REPONAME:latest -f Dockerfile.dev . + - run: + name: Run Documentation generator + command: SBT_NATIVE_CLIENT=false sudo sbt doc-generator/run + - run: + name: Build release Docker image + command: docker build -t $CIRCLE_PROJECT_REPONAME:latest . + - run: + name: Save Docker image to workspace + command: docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest persist_to_workspace: true cache_prefix: sbt-cache-27102021-3 requires: From ec7fc0c6ef639ff223523400d86d8c1786cc1b47 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 4 Jan 2023 17:51:59 +0100 Subject: [PATCH 062/119] fix: Fix build --- .circleci/config.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9b5497d..75a63b9 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,14 +20,17 @@ workflows: name: Check Scalafmt on Sbt sources command: sbt scalafmtSbtCheck - run: - name: Build Development Docker image - command: docker build -t $CIRCLE_PROJECT_REPONAME:latest -f Dockerfile.dev . + name: Build stage build for Development image + command: sbt stage - run: name: Build Development Docker image command: docker build -t $CIRCLE_PROJECT_REPONAME:latest -f Dockerfile.dev . - run: name: Run Documentation generator command: SBT_NATIVE_CLIENT=false sudo sbt doc-generator/run + - run: + name: Build Graalvm native-image + command: sbt graalvm-native-image:packageBin - run: name: Build release Docker image command: docker build -t $CIRCLE_PROJECT_REPONAME:latest . From 989bc2625f851400741d89a484aea28238245734 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 4 Jan 2023 17:55:31 +0100 Subject: [PATCH 063/119] bump: Codacy orbs --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 75a63b9..0d9579b 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codacy: codacy/base@8.1.0 + codacy: codacy/base@10.0.2 codacy_plugins_test: codacy/plugins-test@1.1.1 workflows: From 75c6a556bf3cc5c4266f145415441d1577602cdd Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 4 Jan 2023 18:00:23 +0100 Subject: [PATCH 064/119] Avoid sbt_docker --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d9579b..26f4ae6 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ workflows: jobs: - codacy/checkout_and_version: write_sbt_version: true - - codacy/sbt_docker: + - codacy/sbt: name: publish_docker_local steps: - run: From 33bc474cbda4dc3a666e28fe990cb16cf628cd76 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 4 Jan 2023 18:08:46 +0100 Subject: [PATCH 065/119] Use headless jre in dev Dockerfile --- Dockerfile.dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index 996df8d..96654ca 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -2,7 +2,7 @@ FROM norionomura/swiftlint:0.50.1_swift-5.7.0 as builder FROM swift:5.7.0-jammy-slim -RUN apt-get update && apt-get install -y openjdk-8-jre +RUN apt-get update && apt-get install -y openjdk-8-jre-headless COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so From e3c5d0bfbe3f5b19be8e0b088f3c5396c0a84689 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 4 Jan 2023 18:29:59 +0100 Subject: [PATCH 066/119] Use main docker image --- .circleci/config.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 26f4ae6..37ce028 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,17 +20,14 @@ workflows: name: Check Scalafmt on Sbt sources command: sbt scalafmtSbtCheck - run: - name: Build stage build for Development image - command: sbt stage + name: Build Graalvm native-image + command: sbt graalvm-native-image:packageBin - run: - name: Build Development Docker image - command: docker build -t $CIRCLE_PROJECT_REPONAME:latest -f Dockerfile.dev . + name: Build Docker image for doc-generator + command: docker build -t $CIRCLE_PROJECT_REPONAME:latest . - run: name: Run Documentation generator command: SBT_NATIVE_CLIENT=false sudo sbt doc-generator/run - - run: - name: Build Graalvm native-image - command: sbt graalvm-native-image:packageBin - run: name: Build release Docker image command: docker build -t $CIRCLE_PROJECT_REPONAME:latest . From 323464e6d41badb20b841427dc001b2319557ea9 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Wed, 4 Jan 2023 18:50:26 +0100 Subject: [PATCH 067/119] Add logging to doc-generator --- doc-generator/src/main/scala/doc-generator.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc-generator/src/main/scala/doc-generator.scala b/doc-generator/src/main/scala/doc-generator.scala index c53ab16..df96c39 100644 --- a/doc-generator/src/main/scala/doc-generator.scala +++ b/doc-generator/src/main/scala/doc-generator.scala @@ -20,6 +20,7 @@ object Main extends App { os.proc(baseCommand :+ "generate-docs").call() // Hack: docker in CircleCI makes files only available to the root user os.proc("sudo", "chmod", "-R", "777", tempDir).call() + println("Generated docs using swiftlint generate-docs") val rulesOutput = os.proc(baseCommand :+ "rules").call().out.lines().map(_.split('|').map(_.trim).toList.tail).tail @@ -31,6 +32,7 @@ object Main extends App { val descriptionDirectory = docsDirectory / "description" val patternDescriptions = mdFiles.map { file => + println(s"Generating patterns description from ${file.last}") val patternId = file.last.stripSuffix(".md") val lines = os.read(file).linesIterator val title = lines.next().stripPrefix("# ") @@ -77,6 +79,7 @@ object Main extends App { } val patternSpecifications = swiftLintRules.map { swiftLintRule => + println(s"Generating patterns specification for ${swiftLintRule.identifier}") Pattern.Specification( Pattern.Id(swiftLintRule.identifier), configurationToLevel(swiftLintRule.configuration), From 0c71730e714322340bd5fdfb0852c20380043f4d Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 5 Jan 2023 13:15:51 +0100 Subject: [PATCH 068/119] fix: Enable JavaAppPackaging plugin --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index 33e19c6..f8f80c3 100755 --- a/build.sbt +++ b/build.sbt @@ -28,3 +28,4 @@ lazy val `doc-generator` = project "com.lihaoyi" %% "os-lib" % "0.9.0" ) ) + .enablePlugins(JavaAppPackaging) From 0758b4fff01308bacc0baec77bc078cd3be7690c Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 5 Jan 2023 13:15:59 +0100 Subject: [PATCH 069/119] Run doc-generator --- docs/description/Swift Syntax Dashboard.md | 240 ++ .../accessibility_label_for_image.md | 303 +++ .../accessibility_trait_for_button.md | 302 +++ ...anonymous_argument_in_multiline_closure.md | 41 + docs/description/anyobject_protocol.md | 4 +- docs/description/array_init.md | 42 +- docs/description/attributes.md | 21 +- docs/description/balanced_xctest_lifecycle.md | 4 +- docs/description/block_based_kvo.md | 4 +- docs/description/capture_variable.md | 25 +- docs/description/class_delegate_protocol.md | 24 +- docs/description/closing_brace.md | 4 +- docs/description/closure_body_length.md | 206 +- docs/description/closure_end_indentation.md | 8 +- .../description/closure_parameter_position.md | 4 +- docs/description/closure_spacing.md | 8 +- docs/description/collection_alignment.md | 4 +- docs/description/colon.md | 133 +- docs/description/comma.md | 25 +- docs/description/comma_inheritance.md | 79 + docs/description/comment_spacing.md | 4 +- docs/description/compiler_protocol_init.md | 14 +- docs/description/computed_accessors_order.md | 4 +- .../conditional_returns_on_newline.md | 11 +- .../description/contains_over_filter_count.md | 4 +- .../contains_over_filter_is_empty.md | 4 +- .../contains_over_first_not_nil.md | 4 +- .../contains_over_range_nil_comparison.md | 4 +- docs/description/control_statement.md | 4 +- docs/description/convenience_type.md | 16 +- docs/description/custom_rules.md | 4 +- docs/description/cyclomatic_complexity.md | 4 +- docs/description/deployment_target.md | 56 +- docs/description/description.json | 100 +- .../discarded_notification_center_observer.md | 9 +- docs/description/discouraged_assert.md | 4 +- docs/description/discouraged_direct_init.md | 30 +- docs/description/discouraged_none_name.md | 205 ++ .../description/discouraged_object_literal.md | 4 +- .../discouraged_optional_boolean.md | 8 +- .../discouraged_optional_collection.md | 4 +- docs/description/duplicate_enum_cases.md | 26 +- docs/description/duplicate_imports.md | 117 +- .../duplicated_key_in_dictionary_literal.md | 87 + docs/description/dynamic_inline.md | 4 +- docs/description/empty_collection_literal.md | 4 +- docs/description/empty_count.md | 14 +- docs/description/empty_enum_arguments.md | 52 +- docs/description/empty_parameters.md | 6 +- ...empty_parentheses_with_trailing_closure.md | 4 +- docs/description/empty_string.md | 16 +- docs/description/empty_xctest_method.md | 22 +- .../enum_case_associated_values_count.md | 4 +- docs/description/expiring_todo.md | 27 +- docs/description/explicit_acl.md | 4 +- docs/description/explicit_enum_raw_value.md | 12 +- docs/description/explicit_init.md | 36 +- docs/description/explicit_self.md | 4 +- docs/description/explicit_top_level_acl.md | 14 +- docs/description/explicit_type_interface.md | 4 +- docs/description/extension_access_modifier.md | 4 +- docs/description/fallthrough.md | 4 +- docs/description/fatal_error_message.md | 4 +- docs/description/file_header.md | 4 +- docs/description/file_length.md | 411 +++- docs/description/file_name.md | 4 +- docs/description/file_name_no_space.md | 4 +- docs/description/file_types_order.md | 41 +- docs/description/first_where.md | 12 +- docs/description/flatmap_over_map_reduce.md | 4 +- docs/description/for_where.md | 45 +- docs/description/force_cast.md | 4 +- docs/description/force_try.md | 4 +- docs/description/force_unwrapping.md | 28 +- docs/description/function_body_length.md | 6 +- .../function_default_parameter_at_end.md | 26 +- docs/description/function_parameter_count.md | 6 +- docs/description/generic_type_name.md | 4 +- .../description/ibinspectable_in_extension.md | 6 +- docs/description/identical_operands.md | 158 +- docs/description/identifier_name.md | 8 +- docs/description/implicit_getter.md | 29 +- docs/description/implicit_return.md | 16 +- .../implicitly_unwrapped_optional.md | 8 +- docs/description/inclusive_language.md | 8 +- docs/description/indentation_width.md | 14 +- docs/description/inert_defer.md | 4 +- docs/description/is_disjoint.md | 4 +- docs/description/joined_default_parameter.md | 4 +- docs/description/large_tuple.md | 117 +- docs/description/last_where.md | 4 +- docs/description/leading_whitespace.md | 5 +- .../legacy_cggeometry_functions.md | 4 +- docs/description/legacy_constant.md | 4 +- docs/description/legacy_constructor.md | 4 +- docs/description/legacy_hashing.md | 4 +- docs/description/legacy_multiple.md | 6 +- .../legacy_nsgeometry_functions.md | 6 +- docs/description/legacy_objc_type.md | 48 +- docs/description/legacy_random.md | 4 +- docs/description/let_var_whitespace.md | 24 +- docs/description/line_length.md | 4 +- .../literal_expression_end_indentation.md | 4 +- docs/description/local_doc_comment.md | 45 + docs/description/lower_acl_than_parent.md | 98 +- docs/description/mark.md | 14 +- docs/description/missing_docs.md | 24 +- docs/description/modifier_order.md | 6 +- docs/description/multiline_arguments.md | 4 +- .../multiline_arguments_brackets.md | 56 +- docs/description/multiline_function_chains.md | 4 +- .../description/multiline_literal_brackets.md | 23 +- docs/description/multiline_parameters.md | 19 +- .../multiline_parameters_brackets.md | 4 +- ...multiple_closures_with_trailing_closure.md | 4 +- docs/description/nesting.md | 4 +- docs/description/nimble_operator.md | 22 +- .../no_extension_access_modifier.md | 4 +- docs/description/no_fallthrough_only.md | 4 +- docs/description/no_grouping_extension.md | 4 +- docs/description/no_magic_numbers.md | 91 + docs/description/no_space_in_method_call.md | 4 +- .../notification_center_detachment.md | 4 +- .../ns_number_init_as_function_reference.md | 39 + docs/description/nslocalizedstring_key.md | 4 +- .../nslocalizedstring_require_bundle.md | 4 +- docs/description/nsobject_prefer_isequal.md | 4 +- docs/description/number_separator.md | 70 +- docs/description/object_literal.md | 4 +- docs/description/opening_brace.md | 4 +- docs/description/operator_usage_whitespace.md | 89 +- docs/description/operator_whitespace.md | 4 +- .../optional_enum_case_matching.md | 2 +- docs/description/orphaned_doc_comment.md | 4 +- docs/description/overridden_super_call.md | 4 +- docs/description/override_in_extension.md | 4 +- docs/description/pattern_matching_keywords.md | 16 +- docs/description/prefer_nimble.md | 4 +- .../prefer_self_in_static_references.md | 86 + .../prefer_self_type_over_type_of_self.md | 2 +- .../prefer_zero_over_explicit_init.md | 12 +- .../description/prefixed_toplevel_constant.md | 32 +- docs/description/private_action.md | 4 +- docs/description/private_outlet.md | 60 +- docs/description/private_over_fileprivate.md | 4 +- docs/description/private_subject.md | 6 +- docs/description/private_unit_test.md | 41 +- .../prohibited_interface_builder.md | 4 +- docs/description/prohibited_super_call.md | 4 +- .../protocol_property_accessors_order.md | 4 +- docs/description/quick_discouraged_call.md | 17 +- .../quick_discouraged_focused_test.md | 12 +- .../quick_discouraged_pending_test.md | 12 +- .../raw_value_for_camel_cased_codable_enum.md | 4 +- docs/description/reduce_boolean.md | 4 +- docs/description/reduce_into.md | 22 +- docs/description/redundant_discardable_let.md | 8 +- docs/description/redundant_nil_coalescing.md | 11 +- docs/description/redundant_objc_attribute.md | 11 +- .../redundant_optional_initialization.md | 10 +- .../redundant_set_access_control.md | 16 +- .../redundant_string_enum_value.md | 4 +- docs/description/redundant_type_annotation.md | 4 +- docs/description/redundant_void_return.md | 4 +- docs/description/required_deinit.md | 4 +- docs/description/required_enum_case.md | 12 +- docs/description/return_arrow_whitespace.md | 48 +- .../return_value_from_void_function.md | 275 +++ docs/description/self_binding.md | 71 + .../self_in_property_initialization.md | 75 + docs/description/shorthand_operator.md | 8 +- .../description/shorthand_optional_binding.md | 45 + docs/description/single_test_class.md | 10 +- docs/description/sorted_first_last.md | 4 +- docs/description/sorted_imports.md | 4 +- docs/description/statement_position.md | 4 +- docs/description/static_operator.md | 4 +- docs/description/strict_fileprivate.md | 4 +- docs/description/strong_iboutlet.md | 4 +- .../superfluous_disable_command.md | 4 +- docs/description/switch_case_alignment.md | 4 +- docs/description/switch_case_on_newline.md | 4 +- docs/description/syntactic_sugar.md | 72 +- docs/description/test_case_accessibility.md | 26 +- docs/description/todo.md | 4 +- docs/description/toggle_bool.md | 4 +- docs/description/trailing_closure.md | 4 +- docs/description/trailing_comma.md | 9 +- docs/description/trailing_newline.md | 4 +- docs/description/trailing_semicolon.md | 4 +- docs/description/trailing_whitespace.md | 4 +- docs/description/type_body_length.md | 2073 ++++++++++++++++- docs/description/type_contents_order.md | 11 +- docs/description/type_name.md | 135 +- docs/description/typesafe_array_init.md | 55 + docs/description/unavailable_condition.md | 67 + docs/description/unavailable_function.md | 6 +- docs/description/unneeded_break_in_switch.md | 18 +- ...nneeded_parentheses_in_closure_argument.md | 10 +- docs/description/unowned_variable_capture.md | 2 +- docs/description/untyped_error_in_catch.md | 14 +- docs/description/unused_capture_list.md | 6 +- docs/description/unused_closure_parameter.md | 39 +- docs/description/unused_control_flow_label.md | 4 +- docs/description/unused_declaration.md | 44 +- docs/description/unused_enumerated.md | 4 +- docs/description/unused_import.md | 10 +- docs/description/unused_optional_binding.md | 8 +- docs/description/unused_setter_value.md | 24 +- docs/description/valid_ibinspectable.md | 26 +- .../vertical_parameter_alignment.md | 24 +- .../vertical_parameter_alignment_on_call.md | 4 +- docs/description/vertical_whitespace.md | 4 +- .../vertical_whitespace_between_cases.md | 4 +- .../vertical_whitespace_closing_braces.md | 126 +- .../vertical_whitespace_opening_braces.md | 6 +- docs/description/void_function_in_ternary.md | 130 ++ docs/description/void_return.md | 4 +- docs/description/weak_delegate.md | 45 +- docs/description/xct_specific_matcher.md | 4 +- docs/description/xctfail_message.md | 4 +- docs/description/yoda_condition.md | 32 +- docs/patterns.json | 129 +- 223 files changed, 7515 insertions(+), 911 deletions(-) create mode 100755 docs/description/Swift Syntax Dashboard.md create mode 100755 docs/description/accessibility_label_for_image.md create mode 100755 docs/description/accessibility_trait_for_button.md create mode 100755 docs/description/anonymous_argument_in_multiline_closure.md create mode 100755 docs/description/comma_inheritance.md create mode 100755 docs/description/discouraged_none_name.md create mode 100755 docs/description/duplicated_key_in_dictionary_literal.md create mode 100755 docs/description/local_doc_comment.md create mode 100755 docs/description/no_magic_numbers.md create mode 100755 docs/description/ns_number_init_as_function_reference.md create mode 100755 docs/description/prefer_self_in_static_references.md create mode 100755 docs/description/return_value_from_void_function.md create mode 100755 docs/description/self_binding.md create mode 100755 docs/description/self_in_property_initialization.md create mode 100755 docs/description/shorthand_optional_binding.md create mode 100755 docs/description/typesafe_array_init.md create mode 100755 docs/description/unavailable_condition.md create mode 100755 docs/description/void_function_in_ternary.md diff --git a/docs/description/Swift Syntax Dashboard.md b/docs/description/Swift Syntax Dashboard.md new file mode 100755 index 0000000..d328b2e --- /dev/null +++ b/docs/description/Swift Syntax Dashboard.md @@ -0,0 +1,240 @@ +# Swift Syntax Dashboard + +Efforts are actively under way to migrate most rules off SourceKit to use SwiftSyntax instead. + +Rules written using SwiftSyntax tend to be significantly faster and have fewer false positives +than rules that use SourceKit to get source structure information. + +47 out of 215 (21%) +of SwiftLint's linter rules use SourceKit. + +## Rules Using SourceKit + +### Enabled By Default (16) + +* `control_statement`: Control Statement +* `custom_rules`: Custom Rules +* `cyclomatic_complexity`: Cyclomatic Complexity +* `duplicate_imports`: Duplicate Imports +* `file_length`: File Length +* `identifier_name`: Identifier Name +* `line_length`: Line Length +* `mark`: Mark +* `nesting`: Nesting +* `opening_brace`: Opening Brace Spacing +* `redundant_void_return`: Redundant Void Return +* `statement_position`: Statement Position +* `todo`: Todo +* `trailing_whitespace`: Trailing Whitespace +* `vertical_whitespace`: Vertical Whitespace +* `void_return`: Void Return + +### Opt-In (31) + +* `accessibility_label_for_image`: Accessibility Label for Image +* `accessibility_trait_for_button`: Accessibility Trait for Button +* `closure_end_indentation`: Closure End Indentation +* `discouraged_optional_collection`: Discouraged Optional Collection +* `expiring_todo`: Expiring Todo +* `explicit_acl`: Explicit ACL +* `explicit_type_interface`: Explicit Type Interface +* `extension_access_modifier`: Extension Access Modifier +* `file_header`: File Header +* `file_types_order`: File Types Order +* `implicit_return`: Implicit Return +* `indentation_width`: Indentation Width +* `let_var_whitespace`: Variable Declaration Whitespace +* `literal_expression_end_indentation`: Literal Expression End Indentation +* `missing_docs`: Missing Docs +* `modifier_order`: Modifier Order +* `multiline_arguments`: Multiline Arguments +* `multiline_function_chains`: Multiline Function Chains +* `multiline_literal_brackets`: Multiline Literal Brackets +* `multiline_parameters_brackets`: Multiline Parameters Brackets +* `nimble_operator`: Nimble Operator +* `no_grouping_extension`: No Grouping Extension +* `quick_discouraged_call`: Quick Discouraged Call +* `redundant_type_annotation`: Redundant Type Annotation +* `sorted_imports`: Sorted Imports +* `trailing_closure`: Trailing Closure +* `type_contents_order`: Type Contents Order +* `vertical_parameter_alignment_on_call`: Vertical Parameter Alignment On Call +* `vertical_whitespace_between_cases`: Vertical Whitespace Between Cases +* `vertical_whitespace_closing_braces`: Vertical Whitespace before Closing Braces +* `vertical_whitespace_opening_braces`: Vertical Whitespace after Opening Braces + +## Rules Not Using SourceKit + +### Enabled By Default (75) + +* `block_based_kvo`: Block Based KVO +* `class_delegate_protocol`: Class Delegate Protocol +* `closing_brace`: Closing Brace Spacing +* `closure_parameter_position`: Closure Parameter Position +* `colon`: Colon Spacing +* `comma`: Comma Spacing +* `comment_spacing`: Comment Spacing +* `compiler_protocol_init`: Compiler Protocol Init +* `computed_accessors_order`: Computed Accessors Order +* `deployment_target`: Deployment Target +* `discouraged_direct_init`: Discouraged Direct Initialization +* `duplicate_enum_cases`: Duplicate Enum Cases +* `duplicated_key_in_dictionary_literal`: Duplicated Key in Dictionary Literal +* `dynamic_inline`: Dynamic Inline +* `empty_enum_arguments`: Empty Enum Arguments +* `empty_parameters`: Empty Parameters +* `empty_parentheses_with_trailing_closure`: Empty Parentheses with Trailing Closure +* `for_where`: For Where +* `force_cast`: Force Cast +* `force_try`: Force Try +* `function_body_length`: Function Body Length +* `function_parameter_count`: Function Parameter Count +* `generic_type_name`: Generic Type Name +* `implicit_getter`: Implicit Getter +* `inclusive_language`: Inclusive Language +* `inert_defer`: Inert Defer +* `is_disjoint`: Is Disjoint +* `large_tuple`: Large Tuple +* `leading_whitespace`: Leading Whitespace +* `legacy_cggeometry_functions`: Legacy CGGeometry Functions +* `legacy_constant`: Legacy Constant +* `legacy_constructor`: Legacy Constructor +* `legacy_hashing`: Legacy Hashing +* `legacy_nsgeometry_functions`: Legacy NSGeometry Functions +* `legacy_random`: Legacy Random +* `multiple_closures_with_trailing_closure`: Multiple Closures with Trailing Closure +* `no_fallthrough_only`: No Fallthrough Only +* `no_space_in_method_call`: No Space in Method Call +* `notification_center_detachment`: Notification Center Detachment +* `ns_number_init_as_function_reference`: NSNumber Init as Function Reference +* `nsobject_prefer_isequal`: NSObject Prefer isEqual +* `operator_whitespace`: Operator Function Whitespace +* `orphaned_doc_comment`: Orphaned Doc Comment +* `private_over_fileprivate`: Private over fileprivate +* `private_unit_test`: Private Unit Test +* `protocol_property_accessors_order`: Protocol Property Accessors Order +* `reduce_boolean`: Reduce Boolean +* `redundant_discardable_let`: Redundant Discardable Let +* `redundant_objc_attribute`: Redundant @objc Attribute +* `redundant_optional_initialization`: Redundant Optional Initialization +* `redundant_set_access_control`: Redundant Set Access Control Rule +* `redundant_string_enum_value`: Redundant String Enum Value +* `return_arrow_whitespace`: Returning Whitespace +* `self_in_property_initialization`: Self in Property Initialization +* `shorthand_operator`: Shorthand Operator +* `superfluous_disable_command`: Superfluous Disable Command +* `switch_case_alignment`: Switch and Case Statement Alignment +* `syntactic_sugar`: Syntactic Sugar +* `trailing_comma`: Trailing Comma +* `trailing_newline`: Trailing Newline +* `trailing_semicolon`: Trailing Semicolon +* `type_body_length`: Type Body Length +* `type_name`: Type Name +* `unavailable_condition`: Unavailable Condition +* `unneeded_break_in_switch`: Unneeded Break in Switch +* `unused_capture_list`: Unused Capture List +* `unused_closure_parameter`: Unused Closure Parameter +* `unused_control_flow_label`: Unused Control Flow Label +* `unused_enumerated`: Unused Enumerated +* `unused_optional_binding`: Unused Optional Binding +* `unused_setter_value`: Unused Setter Value +* `valid_ibinspectable`: Valid IBInspectable +* `vertical_parameter_alignment`: Vertical Parameter Alignment +* `void_function_in_ternary`: Void Function in Ternary +* `xctfail_message`: XCTFail Message + +### Opt-In (93) + +* `anonymous_argument_in_multiline_closure`: Anonymous Argument in Multiline Closure +* `anyobject_protocol`: AnyObject Protocol +* `array_init`: Array Init +* `attributes`: Attributes +* `balanced_xctest_lifecycle`: Balanced XCTest life-cycle +* `closure_body_length`: Closure Body Length +* `closure_spacing`: Closure Spacing +* `collection_alignment`: Collection Element Alignment +* `comma_inheritance`: Comma Inheritance Rule +* `conditional_returns_on_newline`: Conditional Returns on Newline +* `contains_over_filter_count`: Contains Over Filter Count +* `contains_over_filter_is_empty`: Contains Over Filter Is Empty +* `contains_over_first_not_nil`: Contains over first not nil +* `contains_over_range_nil_comparison`: Contains over range(of:) comparison to nil +* `convenience_type`: Convenience Type +* `discarded_notification_center_observer`: Discarded Notification Center Observer +* `discouraged_assert`: Discouraged Assert +* `discouraged_none_name`: Discouraged None Name +* `discouraged_object_literal`: Discouraged Object Literal +* `discouraged_optional_boolean`: Discouraged Optional Boolean +* `empty_collection_literal`: Empty Collection Literal +* `empty_count`: Empty Count +* `empty_string`: Empty String +* `empty_xctest_method`: Empty XCTest Method +* `enum_case_associated_values_count`: Enum Case Associated Values Count +* `explicit_enum_raw_value`: Explicit Enum Raw Value +* `explicit_init`: Explicit Init +* `explicit_top_level_acl`: Explicit Top Level ACL +* `fallthrough`: Fallthrough +* `fatal_error_message`: Fatal Error Message +* `file_name`: File Name +* `file_name_no_space`: File Name No Space +* `first_where`: First Where +* `flatmap_over_map_reduce`: FlatMap over map and reduce +* `force_unwrapping`: Force Unwrapping +* `function_default_parameter_at_end`: Function Default Parameter at End +* `ibinspectable_in_extension`: IBInspectable in Extension +* `identical_operands`: Identical Operands +* `implicitly_unwrapped_optional`: Implicitly Unwrapped Optional +* `joined_default_parameter`: Joined Default Parameter +* `last_where`: Last Where +* `legacy_multiple`: Legacy Multiple +* `legacy_objc_type`: Legacy Objective-C Reference Type +* `local_doc_comment`: Local Doc Comment +* `lower_acl_than_parent`: Lower ACL than parent +* `multiline_arguments_brackets`: Multiline Arguments Brackets +* `multiline_parameters`: Multiline Parameters +* `no_extension_access_modifier`: No Extension Access Modifier +* `no_magic_numbers`: No Magic Numbers +* `nslocalizedstring_key`: NSLocalizedString Key +* `nslocalizedstring_require_bundle`: NSLocalizedString Require Bundle +* `number_separator`: Number Separator +* `object_literal`: Object Literal +* `operator_usage_whitespace`: Operator Usage Whitespace +* `optional_enum_case_matching`: Optional Enum Case Match +* `overridden_super_call`: Overridden methods call super +* `override_in_extension`: Override in Extension +* `pattern_matching_keywords`: Pattern Matching Keywords +* `prefer_nimble`: Prefer Nimble +* `prefer_self_in_static_references`: Prefer Self in Static References +* `prefer_self_type_over_type_of_self`: Prefer Self Type Over Type of Self +* `prefer_zero_over_explicit_init`: Prefer Zero Over Explicit Init +* `prefixed_toplevel_constant`: Prefixed Top-Level Constant +* `private_action`: Private Actions +* `private_outlet`: Private Outlets +* `private_subject`: Private Combine Subject +* `prohibited_interface_builder`: Prohibited Interface Builder +* `prohibited_super_call`: Prohibited calls to super +* `quick_discouraged_focused_test`: Quick Discouraged Focused Test +* `quick_discouraged_pending_test`: Quick Discouraged Pending Test +* `raw_value_for_camel_cased_codable_enum`: Raw Value For Camel Cased Codable Enum +* `reduce_into`: Reduce Into +* `redundant_nil_coalescing`: Redundant Nil Coalescing +* `required_deinit`: Required Deinit +* `required_enum_case`: Required Enum Case +* `return_value_from_void_function`: Return Value from Void Function +* `self_binding`: Self Binding +* `shorthand_optional_binding`: Shorthand Optional Binding +* `single_test_class`: Single Test Class +* `sorted_first_last`: Min or Max over Sorted First or Last +* `static_operator`: Static Operator +* `strict_fileprivate`: Strict fileprivate +* `strong_iboutlet`: Strong IBOutlet +* `switch_case_on_newline`: Switch Case on Newline +* `test_case_accessibility`: Test case accessibility +* `toggle_bool`: Toggle Bool +* `unavailable_function`: Unavailable Function +* `unneeded_parentheses_in_closure_argument`: Unneeded Parentheses in Closure Argument +* `unowned_variable_capture`: Unowned Variable Capture +* `untyped_error_in_catch`: Untyped Error in Catch +* `weak_delegate`: Weak Delegate +* `xct_specific_matcher`: XCTest Specific Matcher +* `yoda_condition`: Yoda condition rule diff --git a/docs/description/accessibility_label_for_image.md b/docs/description/accessibility_label_for_image.md new file mode 100755 index 0000000..0e58523 --- /dev/null +++ b/docs/description/accessibility_label_for_image.md @@ -0,0 +1,303 @@ +# Accessibility Label for Image + +All Images that provide context should have an accessibility label. Purely decorative images can be hidden from accessibility. + +* **Identifier:** accessibility_label_for_image +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +struct MyView: View { + var body: some View { + Image(decorative: "my-image") + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Image(systemName: "circle.plus") + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Image("my-image", label: Text("Alt text for my image")) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Image("my-image") + .accessibility(hidden: true) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Image("my-image") + .accessibilityHidden(true) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Image("my-image") + .accessibility(label: Text("Alt text for my image")) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Image("my-image") + .accessibilityLabel(Text("Alt text for my image")) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Image(uiImage: myUiImage) + .renderingMode(.template) + .foregroundColor(.blue) + .accessibilityHidden(true) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Image(uiImage: myUiImage) + .accessibilityLabel(Text("Alt text for my image")) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + SwiftUI.Image(uiImage: "my-image").resizable().accessibilityHidden(true) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + VStack { + Image(decorative: "my-image") + .renderingMode(.template) + .foregroundColor(.blue) + Image("my-image") + .accessibility(label: Text("Alt text for my image")) + } + } +} +``` + +```swift +struct MyView: View { + var body: some View { + VStack { + Image("my-image") + .renderingMode(.template) + .foregroundColor(.blue) + Image("my-image") + .accessibility(label: Text("Alt text for my image")) + }.accessibilityElement() + } +} +``` + +```swift +struct MyView: View { + var body: some View { + VStack { + Image("my-image") + .renderingMode(.template) + .foregroundColor(.blue) + Image("my-image") + .accessibility(label: Text("Alt text for my image")) + }.accessibilityHidden(true) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + HStack(spacing: 8) { + Image(decorative: "my-image") + .renderingMode(.template) + .foregroundColor(.blue) + Text("Text to accompany my image") + }.accessibilityElement(children: .combine) + .padding(16) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + HStack(spacing: 8) { + Image("my-image") + .renderingMode(.template) + .foregroundColor(.blue) + Text("Text to accompany my image") + }.accessibilityElement(children: .ignore) + .padding(16) + .accessibilityLabel(Text("Label for my image and text")) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Button(action: { doAction() }) { + Image("my-image") + .renderingMode(.template) + .foregroundColor(.blue) + } + .accessibilityLabel(Text("Label for my image")) + } +} +``` + +## Triggering Examples + +```swift +struct MyView: View { + var body: some View { + ↓Image("my-image") + .resizable(true) + .frame(width: 48, height: 48) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + ↓Image(uiImage: myUiImage) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + ↓SwiftUI.Image(uiImage: "my-image").resizable().accessibilityHidden(false) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Image(uiImage: myUiImage) + .resizable() + .frame(width: 48, height: 48) + .accessibilityLabel(Text("Alt text for my image")) + ↓Image("other image") + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Image(decorative: "image1") + ↓Image("image2") + Image(uiImage: "image3") + .accessibility(label: Text("a pretty picture")) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + VStack { + Image(decorative: "my-image") + .renderingMode(.template) + .foregroundColor(.blue) + ↓Image("my-image") + } + } +} +``` + +```swift +struct MyView: View { + var body: some View { + VStack { + ↓Image("my-image") + .renderingMode(.template) + .foregroundColor(.blue) + Image("my-image") + .accessibility(label: Text("Alt text for my image")) + }.accessibilityElement(children: .contain) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + VStack { + ↓Image("my-image") + .renderingMode(.template) + .foregroundColor(.blue) + Image("my-image") + .accessibility(label: Text("Alt text for my image")) + }.accessibilityHidden(false) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + HStack(spacing: 8) { + ↓Image("my-image") + .renderingMode(.template) + .foregroundColor(.blue) + Text("Text to accompany my image") + }.accessibilityElement(children: .combine) + .padding(16) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Button(action: { doAction() }) { + ↓Image("my-image") + .renderingMode(.template) + .foregroundColor(.blue) + } + } +} +``` \ No newline at end of file diff --git a/docs/description/accessibility_trait_for_button.md b/docs/description/accessibility_trait_for_button.md new file mode 100755 index 0000000..b3baaa9 --- /dev/null +++ b/docs/description/accessibility_trait_for_button.md @@ -0,0 +1,302 @@ +# Accessibility Trait for Button + +All views with tap gestures added should include the .isButton accessibility trait. If a tap opens an external link the .isLink trait should be used instead. + +* **Identifier:** accessibility_trait_for_button +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +struct MyView: View { + var body: some View { + Button { + print("tapped") + } label: { + Text("Learn more") + } + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Link("Open link", destination: myUrl) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Text("Learn more") + .onTapGesture { + print("tapped - open URL") + } + .accessibility(addTraits: .isLink) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Text("Learn more") + .accessibilityAddTraits(.isButton) + .onTapGesture { + print("tapped") + } + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Text("Learn more") + .accessibility(addTraits: [.isButton, .isHeader]) + .onTapGesture { + print("tapped") + } + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Text("Learn more") + .onTapGesture { + print("tapped - open URL") + } + .accessibilityAddTraits([.isHeader, .isLink]) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Text("Learn more") + .onTapGesture(count: 1) { + print("tapped") + } + .accessibility(addTraits: .isButton) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Text("Learn more") + .onTapGesture(count: 1, perform: { + print("tapped") + }) + .accessibility(addTraits: .isButton) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Text("Learn more") + // This rule does not include tap gestures with multiple taps for now. + // Custom gestures like this are also not very accessible, but require + // alternative ways to accomplish the same task with assistive tech. + .onTapGesture(count: 2) { + print("double-tapped") + } + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Label("Learn more", systemImage: "info.circle") + .onTapGesture(count: 1) { + print("tapped") + } + .accessibility(addTraits: .isButton) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + HStack { + Image(systemName: "info.circle") + Text("Learn more") + } + .onTapGesture { + print("tapped") + } + // This modifier is not strictly required — each subview will inherit the button trait. + // That said, grouping a tappable stack into a single element is a good way to reduce + // the number of swipes required for a VoiceOver user to navigate the page. + .accessibilityElement(children: .combine) + .accessibility(addTraits: .isButton) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Text("Learn more") + .gesture(TapGesture().onEnded { + print("tapped") + }) + .accessibilityAddTraits(.isButton) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Text("Learn more") + .simultaneousGesture(TapGesture(count: 1).onEnded { + print("tapped - open URL") + }) + .accessibilityAddTraits(.isLink) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Text("Learn more") + .highPriorityGesture(TapGesture().onEnded { + print("tapped") + }) + .accessibility(addTraits: [.isButton]) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + Text("Learn more") + .gesture(TapGesture(count: 2).onEnded { + print("tapped") + }) + } +} +``` + +## Triggering Examples + +```swift +struct MyView: View { + var body: some View { + ↓Text("Learn more") + .onTapGesture { + print("tapped") + } + } +} +``` + +```swift +struct MyView: View { + var body: some View { + ↓Text("Learn more") + .accessibility(addTraits: .isHeader) + .onTapGesture { + print("tapped") + } + } +} +``` + +```swift +struct MyView: View { + var body: some View { + ↓Text("Learn more") + .onTapGesture(count: 1) { + print("tapped") + } + } +} +``` + +```swift +struct MyView: View { + var body: some View { + ↓Text("Learn more") + .onTapGesture(count: 1, perform: { + print("tapped") + }) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + ↓Label("Learn more", systemImage: "info.circle") + .onTapGesture(count: 1) { + print("tapped") + } + } +} +``` + +```swift +struct MyView: View { + var body: some View { + ↓HStack { + Image(systemName: "info.circle") + Text("Learn more") + } + .onTapGesture { + print("tapped") + } + } +} +``` + +```swift +struct MyView: View { + var body: some View { + ↓Text("Learn more") + .gesture(TapGesture().onEnded { + print("tapped") + }) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + ↓Text("Learn more") + .simultaneousGesture(TapGesture(count: 1).onEnded { + print("tapped") + }) + } +} +``` + +```swift +struct MyView: View { + var body: some View { + ↓Text("Learn more") + .highPriorityGesture(TapGesture().onEnded { + print("tapped") + }) + } +} +``` \ No newline at end of file diff --git a/docs/description/anonymous_argument_in_multiline_closure.md b/docs/description/anonymous_argument_in_multiline_closure.md new file mode 100755 index 0000000..65ac7fc --- /dev/null +++ b/docs/description/anonymous_argument_in_multiline_closure.md @@ -0,0 +1,41 @@ +# Anonymous Argument in Multiline Closure + +Use named arguments in multiline closures + +* **Identifier:** anonymous_argument_in_multiline_closure +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +closure { $0 } +``` + +```swift +closure { print($0) } +``` + +```swift +closure { arg in + print(arg) +} +``` + +```swift +closure { arg in + nestedClosure { $0 + arg } +} +``` + +## Triggering Examples + +```swift +closure { + print(↓$0) +} +``` \ No newline at end of file diff --git a/docs/description/anyobject_protocol.md b/docs/description/anyobject_protocol.md index dfb63c9..bf4b554 100755 --- a/docs/description/anyobject_protocol.md +++ b/docs/description/anyobject_protocol.md @@ -3,11 +3,11 @@ Prefer using `AnyObject` over `class` for class-only protocols. * **Identifier:** anyobject_protocol -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.1.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/array_init.md b/docs/description/array_init.md index 67ff6fb..9946525 100755 --- a/docs/description/array_init.md +++ b/docs/description/array_init.md @@ -3,11 +3,11 @@ Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array. * **Identifier:** array_init -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -65,54 +65,50 @@ foo.map { /* a comment */ !$0 } ## Triggering Examples ```swift -↓foo.map({ $0 }) +foo.↓map({ $0 }) ``` ```swift -↓foo.map { $0 } +foo.↓map { $0 } ``` ```swift -↓foo.map { return $0 } +foo.↓map { return $0 } ``` ```swift -↓foo.map { elem in - elem -} - + foo.↓map { elem in + elem + } ``` ```swift -↓foo.map { elem in - return elem -} - + foo.↓map { elem in + return elem + } ``` ```swift -↓foo.map { (elem: String) in - elem -} - + foo.↓map { (elem: String) in + elem + } ``` ```swift -↓foo.map { elem -> String in - elem -} - + foo.↓map { elem -> String in + elem + } ``` ```swift -↓foo.map { $0 /* a comment */ } +foo.↓map { $0 /* a comment */ } ``` ```swift -↓foo.map { /* a comment */ $0 } +foo.↓map { /* a comment */ $0 } ``` \ No newline at end of file diff --git a/docs/description/attributes.md b/docs/description/attributes.md index 2dc66d7..d1683c9 100755 --- a/docs/description/attributes.md +++ b/docs/description/attributes.md @@ -3,11 +3,11 @@ Attributes should be on their own lines in functions and types, but on the same line as variables and imports. * **Identifier:** attributes -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, always_on_same_line: ["@IBAction", "@NSManaged"], always_on_line_above: [] ## Non Triggering Examples @@ -208,6 +208,23 @@ func printBoolOrTrue(_ expression: @autoclosure () throws -> Bool?) rethrows { } ``` +```swift +import Foundation + +class MyClass: NSObject { + @objc( + first: + ) + static func foo(first: String) {} +} +``` + +```swift +func refreshable(action: @escaping @Sendable () async -> Void) -> some View { + modifier(RefreshableModifier(action: action)) +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/balanced_xctest_lifecycle.md b/docs/description/balanced_xctest_lifecycle.md index aa1d76f..821f0d1 100755 --- a/docs/description/balanced_xctest_lifecycle.md +++ b/docs/description/balanced_xctest_lifecycle.md @@ -3,11 +3,11 @@ Test classes must implement balanced setUp and tearDown methods. * **Identifier:** balanced_xctest_lifecycle -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/block_based_kvo.md b/docs/description/block_based_kvo.md index 2fd69e9..c693fb1 100755 --- a/docs/description/block_based_kvo.md +++ b/docs/description/block_based_kvo.md @@ -3,11 +3,11 @@ Prefer the new block based KVO API with keypaths when using Swift 3.2 or later. * **Identifier:** block_based_kvo -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/capture_variable.md b/docs/description/capture_variable.md index 3701224..da63b6d 100755 --- a/docs/description/capture_variable.md +++ b/docs/description/capture_variable.md @@ -3,11 +3,11 @@ Non-constant variables should not be listed in a closure's capture list to avoid confusion about closures capturing variables at creation time. * **Identifier:** capture_variable -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** Yes -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -118,31 +118,12 @@ class C { } ``` -```swift -class C { - class var iClass: Int { - get { iStatic } - set { iStatic = newValue } - } - static var iStatic: Int = 0 - - func callTest() { - test { [iClass=C.iClass] j in - print(iClass, j) - } - } - - func test(_ completionHandler: @escaping (Int) -> Void) { - } -} -``` - ```swift class C { static var iStatic: Int = 0 static func callTest() { - test { [iStatic] j in + test { [↓iStatic] j in print(iStatic, j) } } diff --git a/docs/description/class_delegate_protocol.md b/docs/description/class_delegate_protocol.md index 8b516ea..a02d8ad 100755 --- a/docs/description/class_delegate_protocol.md +++ b/docs/description/class_delegate_protocol.md @@ -3,11 +3,11 @@ Delegate protocols should be class-only so they can be weakly referenced. * **Identifier:** class_delegate_protocol -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -58,6 +58,21 @@ protocol FooDelegate: NSObjectProtocol {} ``` +```swift +protocol FooDelegate where Self: BarDelegate {} + +``` + +```swift +protocol FooDelegate where Self: AnyObject {} + +``` + +```swift +protocol FooDelegate where Self: NSObjectProtocol {} + +``` + ## Triggering Examples ```swift @@ -68,4 +83,9 @@ protocol FooDelegate: NSObjectProtocol {} ```swift ↓protocol FooDelegate: Bar {} +``` + +```swift +↓protocol FooDelegate where Self: StringProtocol {} + ``` \ No newline at end of file diff --git a/docs/description/closing_brace.md b/docs/description/closing_brace.md index 84a5a7a..c48922f 100755 --- a/docs/description/closing_brace.md +++ b/docs/description/closing_brace.md @@ -3,11 +3,11 @@ Closing brace with closing parenthesis should not have any whitespaces in the middle. * **Identifier:** closing_brace -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/closure_body_length.md b/docs/description/closure_body_length.md index 0786df2..545775b 100755 --- a/docs/description/closure_body_length.md +++ b/docs/description/closure_body_length.md @@ -3,12 +3,12 @@ Closure bodies should not span too many lines. * **Identifier:** closure_body_length -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** metrics * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.2.0 -* **Default configuration:** warning: 20, error: 100 +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning: 30, error: 100 ## Non Triggering Examples @@ -34,6 +34,16 @@ foo.bar { toto in // toto // toto // toto + // toto + // toto + // toto + // toto + // toto + + + + + @@ -68,6 +78,16 @@ foo.bar { toto in let a16 = 0 let a17 = 0 let a18 = 0 + let a19 = 0 + let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 } ``` @@ -92,6 +112,18 @@ foo.bar { toto in let a16 = 0 let a17 = 0 let a18 = 0 + let a19 = 0 + let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 + // toto + // toto // toto // toto // toto @@ -102,6 +134,14 @@ foo.bar { toto in // toto // toto // toto + // toto + // toto + // toto + + + + + @@ -147,6 +187,16 @@ foo.bar({ toto in let a16 = 0 let a17 = 0 let a18 = 0 + let a19 = 0 + let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 }) ``` @@ -182,6 +232,16 @@ foo.bar(label: { toto in let a16 = 0 let a17 = 0 let a18 = 0 + let a19 = 0 + let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 }) ``` @@ -206,6 +266,16 @@ foo.bar(label: { toto in let a16 = 0 let a17 = 0 let a18 = 0 + let a19 = 0 + let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 }, anotherLabel: { toto in let a0 = 0 let a1 = 0 @@ -226,6 +296,16 @@ foo.bar(label: { toto in let a16 = 0 let a17 = 0 let a18 = 0 + let a19 = 0 + let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 }) ``` @@ -250,6 +330,16 @@ foo.bar(label: { toto in let a16 = 0 let a17 = 0 let a18 = 0 + let a19 = 0 + let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 }) { toto in let a0 = 0 let a1 = 0 @@ -270,6 +360,16 @@ foo.bar(label: { toto in let a16 = 0 let a17 = 0 let a18 = 0 + let a19 = 0 + let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 } ``` @@ -294,6 +394,16 @@ let foo: Bar = { toto in let a15 = 0 let a16 = 0 let a17 = 0 + let a18 = 0 + let a19 = 0 + let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 return bar }() ``` @@ -323,6 +433,16 @@ foo.bar ↓{ toto in let a18 = 0 let a19 = 0 let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 + let a29 = 0 + let a30 = 0 } ``` @@ -349,6 +469,16 @@ foo.bar ↓{ toto in let a18 = 0 let a19 = 0 let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 + let a29 = 0 + let a30 = 0 // toto // toto // toto @@ -395,6 +525,16 @@ foo.bar(↓{ toto in let a18 = 0 let a19 = 0 let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 + let a29 = 0 + let a30 = 0 }) ``` @@ -421,6 +561,16 @@ foo.bar(label: ↓{ toto in let a18 = 0 let a19 = 0 let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 + let a29 = 0 + let a30 = 0 }) ``` @@ -447,6 +597,16 @@ foo.bar(label: ↓{ toto in let a18 = 0 let a19 = 0 let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 + let a29 = 0 + let a30 = 0 }, anotherLabel: ↓{ toto in let a0 = 0 let a1 = 0 @@ -469,6 +629,16 @@ foo.bar(label: ↓{ toto in let a18 = 0 let a19 = 0 let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 + let a29 = 0 + let a30 = 0 }) ``` @@ -495,6 +665,16 @@ foo.bar(label: ↓{ toto in let a18 = 0 let a19 = 0 let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 + let a29 = 0 + let a30 = 0 }) ↓{ toto in let a0 = 0 let a1 = 0 @@ -517,6 +697,16 @@ foo.bar(label: ↓{ toto in let a18 = 0 let a19 = 0 let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 + let a29 = 0 + let a30 = 0 } ``` @@ -542,6 +732,16 @@ let foo: Bar = ↓{ toto in let a16 = 0 let a17 = 0 let a18 = 0 + let a19 = 0 + let a20 = 0 + let a21 = 0 + let a22 = 0 + let a23 = 0 + let a24 = 0 + let a25 = 0 + let a26 = 0 + let a27 = 0 + let a28 = 0 return bar }() ``` \ No newline at end of file diff --git a/docs/description/closure_end_indentation.md b/docs/description/closure_end_indentation.md index 3dab5c4..8a0fb5b 100755 --- a/docs/description/closure_end_indentation.md +++ b/docs/description/closure_end_indentation.md @@ -3,11 +3,11 @@ Closure end should have the same indentation as the line that started it. * **Identifier:** closure_end_indentation -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -77,6 +77,10 @@ function(parameter: param, closure: { x in }) ``` +```swift +(-variable).foo() +``` + ## Triggering Examples ```swift diff --git a/docs/description/closure_parameter_position.md b/docs/description/closure_parameter_position.md index 7b1e585..4e203c0 100755 --- a/docs/description/closure_parameter_position.md +++ b/docs/description/closure_parameter_position.md @@ -3,11 +3,11 @@ Closure parameters should be on the same line as opening brace. * **Identifier:** closure_parameter_position -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/closure_spacing.md b/docs/description/closure_spacing.md index b45b5e1..5f61849 100755 --- a/docs/description/closure_spacing.md +++ b/docs/description/closure_spacing.md @@ -3,11 +3,11 @@ Closure expressions should have a single space inside each brace. * **Identifier:** closure_spacing -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -30,6 +30,10 @@ extension UITableViewCell: ReusableView {} ## Triggering Examples +```swift +[].filter↓{ $0.contains(location) } +``` + ```swift [].filter(↓{$0.contains(location)}) ``` diff --git a/docs/description/collection_alignment.md b/docs/description/collection_alignment.md index e3247a0..8e88405 100755 --- a/docs/description/collection_alignment.md +++ b/docs/description/collection_alignment.md @@ -3,11 +3,11 @@ All elements in a collection literal should be vertically aligned * **Identifier:** collection_alignment -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, align_colons: false ## Non Triggering Examples diff --git a/docs/description/colon.md b/docs/description/colon.md index 8723981..b1e6c06 100755 --- a/docs/description/colon.md +++ b/docs/description/colon.md @@ -1,13 +1,13 @@ -# Colon +# Colon Spacing Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. * **Identifier:** colon -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, flexible_right_spacing: false, apply_to_dictionaries: true ## Non Triggering Examples @@ -141,6 +141,11 @@ class Foo {} ``` +```swift +object.method(x: /* comment */ 5) + +``` + ```swift switch foo { case .bar: @@ -185,115 +190,149 @@ return nil Example("} ``` +```swift +range.flatMap(file.syntaxMap.kinds(inByteRange:)) ?? [] +``` + +```swift +@objc(receiveReply:) +public class func receiveReply(_ reply: bad_instruction_exception_reply_t) -> CInt { 0 } +``` + +```swift +switch str { +case "adlm", "adlam": return .adlam +case "aghb", "caucasianalbanian": return .caucasianAlbanian +default: return nil +} +``` + +```swift +precedencegroup PipelinePrecedence { + associativity: left +} +infix operator |> : PipelinePrecedence +``` + +```swift +switch scalar { + case 0x000A...0x000D /* LF ... CR */: return true + case 0x0085 /* NEXT LINE (NEL) */: return true + case 0x2028 /* LINE SEPARATOR */: return true + case 0x2029 /* PARAGRAPH SEPARATOR */: return true + default: return false +} +``` + ## Triggering Examples ```swift -let ↓abc:Void +let abc↓:Void ``` ```swift -let ↓abc: Void +let abc↓: Void ``` ```swift -let ↓abc :Void +let abc↓ :Void ``` ```swift -let ↓abc : Void +let abc↓ : Void ``` ```swift -let ↓abc : [Void: Void] +let abc↓ : [Void: Void] ``` ```swift -let ↓abc : (Void, String, Int) +let abc↓ : (Void, String, Int) ``` ```swift -let ↓abc : ([Void], String, Int) +let abc↓ : ([Void], String, Int) ``` ```swift -let ↓abc : [([Void], String, Int)] +let abc↓ : [([Void], String, Int)] ``` ```swift -let ↓abc: (Void, String, Int) +let abc↓: (Void, String, Int) ``` ```swift -let ↓abc: ([Void], String, Int) +let abc↓: ([Void], String, Int) ``` ```swift -let ↓abc: [([Void], String, Int)] +let abc↓: [([Void], String, Int)] ``` ```swift -let ↓abc :String="def" +let abc↓ :String="def" ``` ```swift -let ↓abc :Int=0 +let abc↓ :Int=0 ``` ```swift -let ↓abc :Int = 0 +let abc↓ :Int = 0 ``` ```swift -let ↓abc:Int=0 +let abc↓:Int=0 ``` ```swift -let ↓abc:Int = 0 +let abc↓:Int = 0 ``` ```swift -let ↓abc:Enum=Enum.Value +let abc↓:Enum=Enum.Value ``` ```swift -func abc(↓def:Void) {} +func abc(def↓:Void) {} ``` ```swift -func abc(↓def: Void) {} +func abc(def↓: Void) {} ``` ```swift -func abc(↓def :Void) {} +func abc(def↓ :Void) {} ``` ```swift -func abc(↓def : Void) {} +func abc(def↓ : Void) {} ``` ```swift -func abc(def: Void, ↓ghi :Void) {} +func abc(def: Void, ghi↓ :Void) {} ``` @@ -328,87 +367,87 @@ let abc = [1: [3↓ : 2], 3↓: 4] ``` ```swift -let abc: [↓String : Int] +let abc: [String↓ : Int] ``` ```swift -let abc: [↓String:Int] +let abc: [String↓:Int] ``` ```swift -func foo(bar: [↓String : Int]) {} +func foo(bar: [String↓ : Int]) {} ``` ```swift -func foo(bar: [↓String:Int]) {} +func foo(bar: [String↓:Int]) {} ``` ```swift -func foo() -> [↓String : Int] { return [:] } +func foo() -> [String↓ : Int] { return [:] } ``` ```swift -func foo() -> [↓String:Int] { return [:] } +func foo() -> [String↓:Int] { return [:] } ``` ```swift -let ↓abc : Any +let abc↓ : Any ``` ```swift -let abc: [↓Any : Int] +let abc: [Any↓ : Int] ``` ```swift -let abc: [↓String : Any] +let abc: [String↓ : Any] ``` ```swift -class ↓Foo : Bar {} +class Foo↓ : Bar {} ``` ```swift -class ↓Foo:Bar {} +class Foo↓:Bar {} ``` ```swift -class ↓Foo : Bar {} +class Foo↓ : Bar {} ``` ```swift -class ↓Foo:Bar {} +class Foo↓:Bar {} ``` ```swift -class ↓Foo:Bar {} +class Foo↓:Bar {} ``` ```swift -class ↓Foo:Bar {} +class Foo↓:Bar {} ``` ```swift -class Foo<↓T:Equatable> {} +class Foo {} ``` ```swift -class Foo<↓T : Equatable> {} +class Foo {} ``` @@ -441,4 +480,14 @@ class ABC { let def = ghi(jkl↓:mno) } } ```swift func foo() { let dict = [1↓ : 1] } +``` + +```swift +switch foo { +case .bar↓ : return baz +} +``` + +```swift +private var action↓:(() -> Void)? ``` \ No newline at end of file diff --git a/docs/description/comma.md b/docs/description/comma.md index fd85ae0..04494c1 100755 --- a/docs/description/comma.md +++ b/docs/description/comma.md @@ -3,11 +3,11 @@ There should be no space before and one after any comma. * **Identifier:** comma -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -46,6 +46,11 @@ func abc( #imageLiteral(resourceName: "foo,bar,baz") ``` +```swift +kvcStringBuffer.advanced(by: rootKVCLength) + .storeBytes(of: 0x2E /* '.' */, as: CChar.self) +``` + ## Triggering Examples ```swift @@ -70,4 +75,20 @@ let result = plus( second: 4 ) +``` + +```swift +Foo( + parameter: a.b.c, + tag: a.d, + value: a.identifier.flatMap { Int64($0) }↓ , + reason: Self.abcd() +) +``` + +```swift +return Foo(bar: .baz, title: fuzz, + message: My.Custom.message↓ , + another: parameter, doIt: true, + alignment: .center) ``` \ No newline at end of file diff --git a/docs/description/comma_inheritance.md b/docs/description/comma_inheritance.md new file mode 100755 index 0000000..692df72 --- /dev/null +++ b/docs/description/comma_inheritance.md @@ -0,0 +1,79 @@ +# Comma Inheritance Rule + +Use commas to separate types in inheritance lists + +* **Identifier:** comma_inheritance +* **Enabled by default:** No +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +struct A: Codable, Equatable {} +``` + +```swift +enum B: Codable, Equatable {} +``` + +```swift +class C: Codable, Equatable {} +``` + +```swift +protocol D: Codable, Equatable {} +``` + +```swift +typealias E = Equatable & Codable +``` + +```swift +func foo(_ param: T) {} +``` + +```swift +protocol G { + associatedtype Model: Codable, Equatable +} +``` + +## Triggering Examples + +```swift +struct A: Codable↓ & Equatable {} +``` + +```swift +struct A: Codable↓ & Equatable {} +``` + +```swift +struct A: Codable↓&Equatable {} +``` + +```swift +struct A: Codable↓& Equatable {} +``` + +```swift +enum B: Codable↓ & Equatable {} +``` + +```swift +class C: Codable↓ & Equatable {} +``` + +```swift +protocol D: Codable↓ & Equatable {} +``` + +```swift +protocol G { + associatedtype Model: Codable↓ & Equatable +} +``` \ No newline at end of file diff --git a/docs/description/comment_spacing.md b/docs/description/comment_spacing.md index e00c657..5f61fb6 100755 --- a/docs/description/comment_spacing.md +++ b/docs/description/comment_spacing.md @@ -3,11 +3,11 @@ Prefer at least one space after slashes for comments. * **Identifier:** comment_spacing -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/compiler_protocol_init.md b/docs/description/compiler_protocol_init.md index 9384e5b..2b975f1 100755 --- a/docs/description/compiler_protocol_init.md +++ b/docs/description/compiler_protocol_init.md @@ -3,11 +3,11 @@ The initializers declared in compiler protocols such as `ExpressibleByArrayLiteral` shouldn't be called directly. * **Identifier:** compiler_protocol_init -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -29,7 +29,17 @@ let set = ↓Set(arrayLiteral: 1, 2) ``` +```swift +let set = ↓Set (arrayLiteral: 1, 2) + +``` + ```swift let set = ↓Set.init(arrayLiteral: 1, 2) +``` + +```swift +let set = ↓Set.init(arrayLiteral : 1, 2) + ``` \ No newline at end of file diff --git a/docs/description/computed_accessors_order.md b/docs/description/computed_accessors_order.md index f9136cc..71b1e60 100755 --- a/docs/description/computed_accessors_order.md +++ b/docs/description/computed_accessors_order.md @@ -3,11 +3,11 @@ Getter and setters in computed properties and subscripts should be in a consistent order. * **Identifier:** computed_accessors_order -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.1.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, order: get_set ## Non Triggering Examples diff --git a/docs/description/conditional_returns_on_newline.md b/docs/description/conditional_returns_on_newline.md index 35118de..693cbfd 100755 --- a/docs/description/conditional_returns_on_newline.md +++ b/docs/description/conditional_returns_on_newline.md @@ -3,11 +3,11 @@ Conditional statements should always return on the next line * **Identifier:** conditional_returns_on_newline -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, if_only: false ## Non Triggering Examples @@ -47,7 +47,8 @@ if true { // return } ``` ```swift -/*if true { */ return } +guard something +else { return } ``` ## Triggering Examples @@ -70,4 +71,8 @@ if true { // return } ```swift ↓if true { return "YES" } else { return "NO" } +``` + +```swift +↓guard condition else { XCTFail(); return } ``` \ No newline at end of file diff --git a/docs/description/contains_over_filter_count.md b/docs/description/contains_over_filter_count.md index bdaef69..bf75bbc 100755 --- a/docs/description/contains_over_filter_count.md +++ b/docs/description/contains_over_filter_count.md @@ -3,11 +3,11 @@ Prefer `contains` over comparing `filter(where:).count` to 0. * **Identifier:** contains_over_filter_count -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/contains_over_filter_is_empty.md b/docs/description/contains_over_filter_is_empty.md index 9f534b5..8286a9e 100755 --- a/docs/description/contains_over_filter_is_empty.md +++ b/docs/description/contains_over_filter_is_empty.md @@ -3,11 +3,11 @@ Prefer `contains` over using `filter(where:).isEmpty` * **Identifier:** contains_over_filter_is_empty -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/contains_over_first_not_nil.md b/docs/description/contains_over_first_not_nil.md index 94fa7a2..f95e674 100755 --- a/docs/description/contains_over_first_not_nil.md +++ b/docs/description/contains_over_first_not_nil.md @@ -3,11 +3,11 @@ Prefer `contains` over `first(where:) != nil` and `firstIndex(where:) != nil`. * **Identifier:** contains_over_first_not_nil -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/contains_over_range_nil_comparison.md b/docs/description/contains_over_range_nil_comparison.md index 1841402..39bce08 100755 --- a/docs/description/contains_over_range_nil_comparison.md +++ b/docs/description/contains_over_range_nil_comparison.md @@ -3,11 +3,11 @@ Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`. * **Identifier:** contains_over_range_nil_comparison -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/control_statement.md b/docs/description/control_statement.md index 71602d9..2ba2d0c 100755 --- a/docs/description/control_statement.md +++ b/docs/description/control_statement.md @@ -3,11 +3,11 @@ `if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses. * **Identifier:** control_statement -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/convenience_type.md b/docs/description/convenience_type.md index 1c7f043..f506bae 100755 --- a/docs/description/convenience_type.md +++ b/docs/description/convenience_type.md @@ -3,11 +3,11 @@ Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation. * **Identifier:** convenience_type -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.1.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -66,6 +66,12 @@ class Foo { // @objc static func can't exist on an enum } ``` +```swift +@objcMembers class Foo { // @objc static func can't exist on an enum + static func foo() {} +} +``` + ```swift final class Foo { // final class, but @objc class func can't exist on an enum @objc class func foo() {} @@ -78,6 +84,12 @@ final class Foo { // final class, but @objc static func can't exist on an enum } ``` +```swift +@globalActor actor MyActor { + static let shared = MyActor() +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/custom_rules.md b/docs/description/custom_rules.md index 5d63236..8212b90 100755 --- a/docs/description/custom_rules.md +++ b/docs/description/custom_rules.md @@ -3,9 +3,9 @@ Create custom rules by providing a regex string. Optionally specify what syntax kinds to match against, the severity level, and what message to display. * **Identifier:** custom_rules -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** user-defined \ No newline at end of file diff --git a/docs/description/cyclomatic_complexity.md b/docs/description/cyclomatic_complexity.md index 0f96c48..de6f623 100755 --- a/docs/description/cyclomatic_complexity.md +++ b/docs/description/cyclomatic_complexity.md @@ -3,11 +3,11 @@ Complexity of function bodies should be limited. * **Identifier:** cyclomatic_complexity -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** metrics * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning: 10, error: 20, ignores_case_statements: false ## Non Triggering Examples diff --git a/docs/description/deployment_target.md b/docs/description/deployment_target.md index 7dc560d..49d17d8 100755 --- a/docs/description/deployment_target.md +++ b/docs/description/deployment_target.md @@ -3,12 +3,12 @@ Availability checks or attributes shouldn't be using older versions that are satisfied by the deployment target. * **Identifier:** deployment_target -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.1.0 -* **Default configuration:** warning, iOS_deployment_target: 7.0, macOS_deployment_target: 10.9, watchOS_deployment_target: 1.0, tvOS_deployment_target: 9.0 +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning, iOSApplicationExtension_deployment_target: 7.0, iOS_deployment_target: 7.0, macOSApplicationExtension_deployment_target: 10.9, macOS_deployment_target: 10.9, tvOSApplicationExtension_deployment_target: 9.0, tvOS_deployment_target: 9.0, watchOSApplicationExtension_deployment_target: 1.0, watchOS_deployment_target: 1.0 ## Non Triggering Examples @@ -17,11 +17,21 @@ Availability checks or attributes shouldn't be using older versions that are sat class A {} ``` +```swift +@available(iOSApplicationExtension 13.0, *) +class A {} +``` + ```swift @available(watchOS 4.0, *) class A {} ``` +```swift +@available(watchOSApplicationExtension 4.0, *) +class A {} +``` + ```swift @available(swift 3.0.2) class A {} @@ -43,6 +53,14 @@ if #available(iOS 10, *) {} guard #available(iOS 12.0, *) else { return } ``` +```swift +#if #unavailable(iOS 15.0) {} +``` + +```swift +#guard #unavailable(iOS 15.0) {} else { return } +``` + ## Triggering Examples ```swift @@ -50,6 +68,11 @@ guard #available(iOS 12.0, *) else { return } class A {} ``` +```swift +↓@available(iOSApplicationExtension 6.0, *) +class A {} +``` + ```swift ↓@available(iOS 7.0, *) class A {} @@ -75,6 +98,11 @@ class A {} class A {} ``` +```swift +↓@available(macOSApplicationExtension 10.7, *) +class A {} +``` + ```swift ↓@available(OSX 10.7, *) class A {} @@ -85,11 +113,21 @@ class A {} class A {} ``` +```swift +↓@available(watchOSApplicationExtension 0.9, *) +class A {} +``` + ```swift ↓@available(tvOS 8, *) class A {} ``` +```swift +↓@available(tvOSApplicationExtension 8, *) +class A {} +``` + ```swift if ↓#available(iOS 6.0, *) {} ``` @@ -100,4 +138,16 @@ if ↓#available(iOS 6, *) {} ```swift guard ↓#available(iOS 6.0, *) else { return } +``` + +```swift +if ↓#unavailable(iOS 7.0) {} +``` + +```swift +if ↓#unavailable(iOS 6.9) {} +``` + +```swift +guard ↓#unavailable(iOS 7.0) {} else { return } ``` \ No newline at end of file diff --git a/docs/description/description.json b/docs/description/description.json index 973444e..30bea49 100644 --- a/docs/description/description.json +++ b/docs/description/description.json @@ -1,4 +1,24 @@ [ { + "patternId" : "Swift Syntax Dashboard", + "title" : "Swift Syntax Dashboard", + "description" : "Efforts are actively under way to migrate most rules off SourceKit to use SwiftSyntax instead.", + "parameters" : [ ] +}, { + "patternId" : "accessibility_label_for_image", + "title" : "Accessibility Label for Image", + "description" : "All Images that provide context should have an accessibility label. Purely decorative images can be hidden from accessibility.", + "parameters" : [ ] +}, { + "patternId" : "accessibility_trait_for_button", + "title" : "Accessibility Trait for Button", + "description" : "All views with tap gestures added should include the .isButton accessibility trait. If a tap opens an external link the .isLink trait should be used instead.", + "parameters" : [ ] +}, { + "patternId" : "anonymous_argument_in_multiline_closure", + "title" : "Anonymous Argument in Multiline Closure", + "description" : "Use named arguments in multiline closures", + "parameters" : [ ] +}, { "patternId" : "anyobject_protocol", "title" : "AnyObject Protocol", "description" : "Prefer using `AnyObject` over `class` for class-only protocols.", @@ -65,7 +85,7 @@ "parameters" : [ ] }, { "patternId" : "colon", - "title" : "Colon", + "title" : "Colon Spacing", "description" : "Colons should be next to the identifier when specifying a type and next to the key in dictionary literals.", "parameters" : [ ] }, { @@ -73,6 +93,11 @@ "title" : "Comma Spacing", "description" : "There should be no space before and one after any comma.", "parameters" : [ ] +}, { + "patternId" : "comma_inheritance", + "title" : "Comma Inheritance Rule", + "description" : "Use commas to separate types in inheritance lists", + "parameters" : [ ] }, { "patternId" : "comment_spacing", "title" : "Comment Spacing", @@ -153,6 +178,11 @@ "title" : "Discouraged Direct Initialization", "description" : "Discouraged direct initialization of types that can be harmful.", "parameters" : [ ] +}, { + "patternId" : "discouraged_none_name", + "title" : "Discouraged None Name", + "description" : "Discourages name cases/static members `none`, which can conflict with `Optional.none`.", + "parameters" : [ ] }, { "patternId" : "discouraged_object_literal", "title" : "Discouraged Object Literal", @@ -178,6 +208,11 @@ "title" : "Duplicate Imports", "description" : "Imports should be unique.", "parameters" : [ ] +}, { + "patternId" : "duplicated_key_in_dictionary_literal", + "title" : "Duplicated Key in Dictionary Literal", + "description" : "Dictionary literals with duplicated keys will crash in runtime.", + "parameters" : [ ] }, { "patternId" : "dynamic_inline", "title" : "Dynamic Inline", @@ -225,7 +260,7 @@ "parameters" : [ ] }, { "patternId" : "expiring_todo", - "title" : "ExpiringTodo", + "title" : "Expiring Todo", "description" : "TODOs and FIXMEs should be resolved prior to their expiry date.", "parameters" : [ ] }, { @@ -381,7 +416,7 @@ }, { "patternId" : "inclusive_language", "title" : "Inclusive Language", - "description" : " Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status", + "description" : "Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status", "parameters" : [ ] }, { "patternId" : "indentation_width", @@ -473,10 +508,15 @@ "title" : "Literal Expression End Indentation", "description" : "Array and dictionary literal end should have the same indentation as the line that started it.", "parameters" : [ ] +}, { + "patternId" : "local_doc_comment", + "title" : "Local Doc Comment", + "description" : "Doc comments shouldn't be used in local scopes. Use regular comments.", + "parameters" : [ ] }, { "patternId" : "lower_acl_than_parent", "title" : "Lower ACL than parent", - "description" : "Ensure definitions have a lower access control level than their enclosing parent", + "description" : "Ensure declarations have a lower access control level than their enclosing parent", "parameters" : [ ] }, { "patternId" : "mark", @@ -553,6 +593,11 @@ "title" : "No Grouping Extension", "description" : "Extensions shouldn't be used to group code within the same source file.", "parameters" : [ ] +}, { + "patternId" : "no_magic_numbers", + "title" : "No Magic Numbers", + "description" : "Magic numbers should be replaced by named constants.", + "parameters" : [ ] }, { "patternId" : "no_space_in_method_call", "title" : "No Space in Method Call", @@ -563,6 +608,11 @@ "title" : "Notification Center Detachment", "description" : "An object should only remove itself as an observer in `deinit`.", "parameters" : [ ] +}, { + "patternId" : "ns_number_init_as_function_reference", + "title" : "NSNumber Init as Function Reference", + "description" : "Passing `NSNumber.init` or `NSDecimalNumber.init` as a function reference is dangerous as it can cause the wrong initializer to be used, causing crashes. Use `.init(value:)` instead.", + "parameters" : [ ] }, { "patternId" : "nslocalizedstring_key", "title" : "NSLocalizedString Key", @@ -633,6 +683,11 @@ "title" : "Prefer Nimble", "description" : "Prefer Nimble matchers over XCTAssert functions.", "parameters" : [ ] +}, { + "patternId" : "prefer_self_in_static_references", + "title" : "Prefer Self in Static References", + "description" : "Use `Self` to refer to the surrounding type name.", + "parameters" : [ ] }, { "patternId" : "prefer_self_type_over_type_of_self", "title" : "Prefer Self Type Over Type of Self", @@ -773,11 +828,31 @@ "title" : "Returning Whitespace", "description" : "Return arrow and return type should be separated by a single space or on a separate line.", "parameters" : [ ] +}, { + "patternId" : "return_value_from_void_function", + "title" : "Return Value from Void Function", + "description" : "Returning values from Void functions should be avoided.", + "parameters" : [ ] +}, { + "patternId" : "self_binding", + "title" : "Self Binding", + "description" : "Re-bind `self` to a consistent identifier name.", + "parameters" : [ ] +}, { + "patternId" : "self_in_property_initialization", + "title" : "Self in Property Initialization", + "description" : "`self` refers to the unapplied `NSObject.self()` method, which is likely not expected. Make the variable `lazy` to be able to refer to the current instance or use `ClassName.self`.", + "parameters" : [ ] }, { "patternId" : "shorthand_operator", "title" : "Shorthand Operator", "description" : "Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning.", "parameters" : [ ] +}, { + "patternId" : "shorthand_optional_binding", + "title" : "Shorthand Optional Binding", + "description" : "Use shorthand syntax for optional binding", + "parameters" : [ ] }, { "patternId" : "single_test_class", "title" : "Single Test Class", @@ -888,6 +963,16 @@ "title" : "Type Name", "description" : "Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 40 characters in length.", "parameters" : [ ] +}, { + "patternId" : "typesafe_array_init", + "title" : "Type-safe Array Init", + "description" : "Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array.", + "parameters" : [ ] +}, { + "patternId" : "unavailable_condition", + "title" : "Unavailable Condition", + "description" : "Use #unavailable/#available instead of #available/#unavailable with an empty body.", + "parameters" : [ ] }, { "patternId" : "unavailable_function", "title" : "Unavailable Function", @@ -988,6 +1073,11 @@ "title" : "Vertical Whitespace after Opening Braces", "description" : "Don't include vertical whitespace (empty line) after opening braces.", "parameters" : [ ] +}, { + "patternId" : "void_function_in_ternary", + "title" : "Void Function in Ternary", + "description" : "Using ternary to call Void functions should be avoided.", + "parameters" : [ ] }, { "patternId" : "void_return", "title" : "Void Return", @@ -1011,6 +1101,6 @@ }, { "patternId" : "yoda_condition", "title" : "Yoda condition rule", - "description" : "The variable should be placed on the left, the constant on the right of a comparison operator.", + "description" : "The constant literal should be placed on the right-hand side of the comparison operator.", "parameters" : [ ] } ] diff --git a/docs/description/discarded_notification_center_observer.md b/docs/description/discarded_notification_center_observer.md index e2161f0..2390c02 100755 --- a/docs/description/discarded_notification_center_observer.md +++ b/docs/description/discarded_notification_center_observer.md @@ -3,11 +3,11 @@ When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later. * **Identifier:** discarded_notification_center_observer -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -67,6 +67,11 @@ var obs: [NSObjectProtocol] = [ ``` +```swift +_ = ↓nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { } + +``` + ```swift ↓nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { }) diff --git a/docs/description/discouraged_assert.md b/docs/description/discouraged_assert.md index 5a3fbb2..cc59a7f 100755 --- a/docs/description/discouraged_assert.md +++ b/docs/description/discouraged_assert.md @@ -3,11 +3,11 @@ Prefer `assertionFailure()` and/or `preconditionFailure()` over `assert(false)` * **Identifier:** discouraged_assert -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/discouraged_direct_init.md b/docs/description/discouraged_direct_init.md index 3a59ac8..041fcb4 100755 --- a/docs/description/discouraged_direct_init.md +++ b/docs/description/discouraged_direct_init.md @@ -3,12 +3,12 @@ Discouraged direct initialization of types that can be harmful. * **Identifier:** discouraged_direct_init -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning, types: ["Bundle", "Bundle.init", "UIDevice", "UIDevice.init"] +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning, types: ["Bundle", "Bundle.init", "NSError", "NSError.init", "UIDevice", "UIDevice.init"] ## Non Triggering Examples @@ -36,6 +36,18 @@ let foo = Bundle.init(path: "bar") let foo = Bundle.init(identifier: "bar") ``` +```swift +let foo = NSError(domain: "bar", code: 0) +``` + +```swift +let foo = NSError.init(domain: "bar", code: 0) +``` + +```swift +func testNSError() +``` + ## Triggering Examples ```swift @@ -55,7 +67,11 @@ let foo = ↓Bundle() ``` ```swift -let foo = bar(bundle: ↓Bundle(), device: ↓UIDevice()) +let foo = ↓NSError() +``` + +```swift +let foo = bar(bundle: ↓Bundle(), device: ↓UIDevice(), error: ↓NSError()) ``` ```swift @@ -66,6 +82,10 @@ let foo = bar(bundle: ↓Bundle(), device: ↓UIDevice()) ↓Bundle.init() ``` +```swift +↓NSError.init() +``` + ```swift let foo = ↓UIDevice.init() ``` @@ -75,5 +95,5 @@ let foo = ↓Bundle.init() ``` ```swift -let foo = bar(bundle: ↓Bundle.init(), device: ↓UIDevice.init()) +let foo = bar(bundle: ↓Bundle.init(), device: ↓UIDevice.init(), error: ↓NSError.init()) ``` \ No newline at end of file diff --git a/docs/description/discouraged_none_name.md b/docs/description/discouraged_none_name.md new file mode 100755 index 0000000..09074d9 --- /dev/null +++ b/docs/description/discouraged_none_name.md @@ -0,0 +1,205 @@ +# Discouraged None Name + +Discourages name cases/static members `none`, which can conflict with `Optional.none`. + +* **Identifier:** discouraged_none_name +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +enum MyEnum { + case nOne +} +``` + +```swift +enum MyEnum { + case _none +} +``` + +```swift +enum MyEnum { + case none_ +} +``` + +```swift +enum MyEnum { + case none(Any) +} +``` + +```swift +enum MyEnum { + case nonenone +} +``` + +```swift +class MyClass { + class var nonenone: MyClass { MyClass() } +} +``` + +```swift +class MyClass { + static var nonenone = MyClass() +} +``` + +```swift +class MyClass { + static let nonenone = MyClass() +} +``` + +```swift +struct MyStruct { + static var nonenone = MyStruct() +} +``` + +```swift +struct MyStruct { + static let nonenone = MyStruct() +} +``` + +```swift +struct MyStruct { + let none = MyStruct() +} +``` + +```swift +struct MyStruct { + var none = MyStruct() +} +``` + +```swift +class MyClass { + let none = MyClass() +} +``` + +```swift +class MyClass { + var none = MyClass() +} +``` + +## Triggering Examples + +```swift +enum MyEnum { + case ↓none +} +``` + +```swift +enum MyEnum { + case a, ↓none +} +``` + +```swift +enum MyEnum { + case ↓none, b +} +``` + +```swift +enum MyEnum { + case a, ↓none, b +} +``` + +```swift +enum MyEnum { + case a + case ↓none +} +``` + +```swift +enum MyEnum { + case ↓none + case b +} +``` + +```swift +enum MyEnum { + case a + case ↓none + case b +} +``` + +```swift +class MyClass { + ↓static let none = MyClass() +} +``` + +```swift +class MyClass { + ↓static let none: MyClass = MyClass() +} +``` + +```swift +class MyClass { + ↓static var none: MyClass = MyClass() +} +``` + +```swift +class MyClass { + ↓class var none: MyClass { MyClass() } +} +``` + +```swift +struct MyStruct { + ↓static var none = MyStruct() +} +``` + +```swift +struct MyStruct { + ↓static var none: MyStruct = MyStruct() +} +``` + +```swift +struct MyStruct { + ↓static var none = MyStruct() +} +``` + +```swift +struct MyStruct { + ↓static var none: MyStruct = MyStruct() +} +``` + +```swift +struct MyStruct { + ↓static var a = MyStruct(), none = MyStruct() +} +``` + +```swift +struct MyStruct { + ↓static var none = MyStruct(), a = MyStruct() +} +``` \ No newline at end of file diff --git a/docs/description/discouraged_object_literal.md b/docs/description/discouraged_object_literal.md index 708a48b..410f3c8 100755 --- a/docs/description/discouraged_object_literal.md +++ b/docs/description/discouraged_object_literal.md @@ -3,11 +3,11 @@ Prefer initializers over object literals. * **Identifier:** discouraged_object_literal -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, image_literal: true, color_literal: true ## Non Triggering Examples diff --git a/docs/description/discouraged_optional_boolean.md b/docs/description/discouraged_optional_boolean.md index de9c2dc..e82a2e9 100755 --- a/docs/description/discouraged_optional_boolean.md +++ b/docs/description/discouraged_optional_boolean.md @@ -3,11 +3,11 @@ Prefer non-optional booleans over optional booleans. * **Identifier:** discouraged_optional_boolean -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -624,4 +624,8 @@ enum Foo { enum Foo { static func foo(input: [↓Bool?]) {} } +``` + +```swift +_ = ↓Bool?.values() ``` \ No newline at end of file diff --git a/docs/description/discouraged_optional_collection.md b/docs/description/discouraged_optional_collection.md index 1f8a9c2..3366799 100755 --- a/docs/description/discouraged_optional_collection.md +++ b/docs/description/discouraged_optional_collection.md @@ -3,11 +3,11 @@ Prefer empty collection over optional collection. * **Identifier:** discouraged_optional_collection -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/duplicate_enum_cases.md b/docs/description/duplicate_enum_cases.md index 4f8dd91..b52921b 100755 --- a/docs/description/duplicate_enum_cases.md +++ b/docs/description/duplicate_enum_cases.md @@ -3,11 +3,11 @@ Enum can't contain multiple cases with the same name. * **Identifier:** duplicate_enum_cases -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** error ## Non Triggering Examples @@ -28,6 +28,28 @@ enum B { } ``` +```swift +enum Tag: String { +#if CONFIG_A + case value = "CONFIG_A" +#elseif CONFIG_B + case value = "CONFIG_B" +#else + case value = "CONFIG_DEFAULT" +#endif +} +``` + +```swift +enum Target { +#if os(iOS) + case file +#else + case file(URL) +#endif +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/duplicate_imports.md b/docs/description/duplicate_imports.md index ea8b2c3..0b86c63 100755 --- a/docs/description/duplicate_imports.md +++ b/docs/description/duplicate_imports.md @@ -3,11 +3,11 @@ Imports should be unique. * **Identifier:** duplicate_imports -* **Enabled by default:** Enabled -* **Supports autocorrection:** No +* **Enabled by default:** Yes +* **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -55,39 +55,15 @@ func test() { ## Triggering Examples ```swift -import Foundation -import Dispatch -↓import Foundation -``` - -```swift -import Foundation -↓import Foundation.NSString -``` - -```swift -@_implementationOnly import A @_implementationOnly import A -``` - -```swift -@testable import A -@testable import A -``` +↓@_implementationOnly import A -```swift -↓import Foundation.NSString -import Foundation ``` ```swift -↓import A.B.C -import A.B -``` +@testable import A +↓@testable import A -```swift -import A.B -↓import A.B.C ``` ```swift @@ -98,124 +74,91 @@ import A import KsApi #endif ↓import A -``` -```swift -import A -↓import typealias A.Foo -``` - -```swift -import A -↓import struct A.Foo ``` ```swift import A ↓import class A.Foo + ``` ```swift import A ↓import enum A.Foo -``` -```swift -import A -↓import protocol A.Foo ``` ```swift import A -↓import let A.Foo -``` +↓import func A.Foo -```swift -import A -↓import var A.Foo ``` ```swift import A -↓import func A.Foo -``` +↓import let A.Foo -```swift -import A -↓import typealias A.B.Foo ``` ```swift import A -↓import struct A.B.Foo -``` +↓import protocol A.Foo -```swift -import A -↓import class A.B.Foo ``` ```swift import A -↓import enum A.B.Foo -``` +↓import struct A.Foo -```swift -import A -↓import protocol A.B.Foo ``` ```swift import A -↓import let A.B.Foo -``` +↓import typealias A.Foo -```swift -import A -↓import var A.B.Foo ``` ```swift import A -↓import func A.B.Foo -``` +↓import var A.Foo -```swift -import A.B -↓import typealias A.B.Foo ``` ```swift import A.B -↓import struct A.B.Foo -``` +↓import A.B.C -```swift -import A.B -↓import class A.B.Foo ``` ```swift -import A.B -↓import enum A.B.Foo +import Foundation +import Dispatch +↓import Foundation + ``` ```swift -import A.B -↓import protocol A.B.Foo +import Foundation +↓import Foundation +↓import Foundation + ``` ```swift -import A.B -↓import let A.B.Foo +import Foundation +↓import Foundation.NSString + ``` ```swift +↓import A.B.C import A.B -↓import var A.B.Foo + ``` ```swift -import A.B -↓import func A.B.Foo +↓import Foundation.NSString +import Foundation + ``` \ No newline at end of file diff --git a/docs/description/duplicated_key_in_dictionary_literal.md b/docs/description/duplicated_key_in_dictionary_literal.md new file mode 100755 index 0000000..f4c3189 --- /dev/null +++ b/docs/description/duplicated_key_in_dictionary_literal.md @@ -0,0 +1,87 @@ +# Duplicated Key in Dictionary Literal + +Dictionary literals with duplicated keys will crash in runtime. + +* **Identifier:** duplicated_key_in_dictionary_literal +* **Enabled by default:** Yes +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift + [ + 1: "1", + 2: "2" + ] +``` + +```swift + [ + "1": 1, + "2": 2 + ] +``` + +```swift + [ + foo: "1", + bar: "2" + ] +``` + +```swift + [ + UUID(): "1", + UUID(): "2" + ] +``` + +```swift + [ + #line: "1", + #line: "2" + ] +``` + +## Triggering Examples + +```swift + [ + 1: "1", + 2: "2", + ↓1: "one" + ] +``` + +```swift + [ + "1": 1, + "2": 2, + ↓"2": 2 + ] +``` + +```swift + [ + foo: "1", + bar: "2", + baz: "3", + ↓foo: "4", + zaz: "5" + ] +``` + +```swift + [ + .one: "1", + .two: "2", + .three: "3", + ↓.one: "1", + .four: "4", + .five: "5" + ] +``` \ No newline at end of file diff --git a/docs/description/dynamic_inline.md b/docs/description/dynamic_inline.md index 644716f..d6b52a3 100755 --- a/docs/description/dynamic_inline.md +++ b/docs/description/dynamic_inline.md @@ -3,11 +3,11 @@ Avoid using 'dynamic' and '@inline(__always)' together. * **Identifier:** dynamic_inline -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** error ## Non Triggering Examples diff --git a/docs/description/empty_collection_literal.md b/docs/description/empty_collection_literal.md index 99aa2b7..2ca5b3d 100755 --- a/docs/description/empty_collection_literal.md +++ b/docs/description/empty_collection_literal.md @@ -3,11 +3,11 @@ Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal. * **Identifier:** empty_collection_literal -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/empty_count.md b/docs/description/empty_count.md index c3d2380..053caf2 100755 --- a/docs/description/empty_count.md +++ b/docs/description/empty_count.md @@ -3,11 +3,11 @@ Prefer checking `isEmpty` over comparing `count` to zero. * **Identifier:** empty_count -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** error, only_after_dot: false ## Non Triggering Examples @@ -64,6 +64,16 @@ order.discount == 0 ``` +```swift +0 == [Int]().↓count + +``` + +```swift +[Int]().↓count==0 + +``` + ```swift [Int]().↓count > 0 diff --git a/docs/description/empty_enum_arguments.md b/docs/description/empty_enum_arguments.md index e6a00d3..564c2cd 100755 --- a/docs/description/empty_enum_arguments.md +++ b/docs/description/empty_enum_arguments.md @@ -3,11 +3,11 @@ Arguments can be omitted when matching enums with associated values if they are not used. * **Identifier:** empty_enum_arguments -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -70,6 +70,29 @@ guard case .bar = foo else { } ``` +```swift +if foo == .bar() {} +``` + +```swift +guard foo == .bar() else { return } +``` + +```swift +if case .appStore = self.appInstaller, !UIDevice.isSimulator() { + viewController.present(self, animated: false) +} else { + UIApplication.shared.open(self.appInstaller.url) +} +``` + +```swift +let updatedUserNotificationSettings = deepLink.filter { nav in + guard case .settings(.notifications(_, nil)) = nav else { return false } + return true +} +``` + ## Triggering Examples ```swift @@ -113,4 +136,29 @@ if case .bar↓(_) = foo { ```swift guard case .bar↓(_) = foo else { } +``` + +```swift +if case .bar↓() = foo { +} +``` + +```swift +guard case .bar↓() = foo else { +} +``` + +```swift +if case .appStore↓(_) = self.appInstaller, !UIDevice.isSimulator() { + viewController.present(self, animated: false) +} else { + UIApplication.shared.open(self.appInstaller.url) +} +``` + +```swift +let updatedUserNotificationSettings = deepLink.filter { nav in + guard case .settings(.notifications↓(_, _)) = nav else { return false } + return true +} ``` \ No newline at end of file diff --git a/docs/description/empty_parameters.md b/docs/description/empty_parameters.md index 524d318..7dcf92d 100755 --- a/docs/description/empty_parameters.md +++ b/docs/description/empty_parameters.md @@ -3,11 +3,11 @@ Prefer `() -> ` over `Void -> `. * **Identifier:** empty_parameters -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -23,7 +23,7 @@ func foo(completion: () -> Void) ``` ```swift -func foo(completion: () thows -> Void) +func foo(completion: () throws -> Void) ``` diff --git a/docs/description/empty_parentheses_with_trailing_closure.md b/docs/description/empty_parentheses_with_trailing_closure.md index df2cd9e..849585b 100755 --- a/docs/description/empty_parentheses_with_trailing_closure.md +++ b/docs/description/empty_parentheses_with_trailing_closure.md @@ -3,11 +3,11 @@ When using trailing closures, empty parentheses should be avoided after the method call. * **Identifier:** empty_parentheses_with_trailing_closure -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/empty_string.md b/docs/description/empty_string.md index 6c71bde..9f879e3 100755 --- a/docs/description/empty_string.md +++ b/docs/description/empty_string.md @@ -3,11 +3,11 @@ Prefer checking `isEmpty` over comparing `string` to an empty string literal. * **Identifier:** empty_string -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -34,4 +34,16 @@ myString↓ == "" ```swift myString↓ != "" +``` + +```swift +myString↓=="" +``` + +```swift +myString↓ == #""# +``` + +```swift +myString↓ == ##""## ``` \ No newline at end of file diff --git a/docs/description/empty_xctest_method.md b/docs/description/empty_xctest_method.md index 983f422..0cdcadf 100755 --- a/docs/description/empty_xctest_method.md +++ b/docs/description/empty_xctest_method.md @@ -3,11 +3,11 @@ Empty XCTest method should be avoided. * **Identifier:** empty_xctest_method -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -21,6 +21,10 @@ class TotoTests: XCTestCase { foobar = Foobar() } + override func setUpWithError() throws { + foobar = nil + } + override func tearDown() { foobar = nil super.tearDown() @@ -37,6 +41,10 @@ class TotoTests: XCTestCase { // comment... } + + func testBaz() { + _ = 4 + 4 + } } ``` @@ -70,6 +78,16 @@ class TotoTests: XCTestCase { } ``` +```swift +class TotoTests: XCTestCase { + override class var runsForEachTargetApplicationUIConfiguration: Bool { true } + + static var allTests = [("testFoo", testFoo)] + + func testFoo() { XCTAssert(true) } +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/enum_case_associated_values_count.md b/docs/description/enum_case_associated_values_count.md index 58b95ee..9a10c3d 100755 --- a/docs/description/enum_case_associated_values_count.md +++ b/docs/description/enum_case_associated_values_count.md @@ -3,11 +3,11 @@ Number of associated values in an enum case should be low * **Identifier:** enum_case_associated_values_count -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** metrics * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning: 5, error: 6 ## Non Triggering Examples diff --git a/docs/description/expiring_todo.md b/docs/description/expiring_todo.md index 9d2c666..632d161 100755 --- a/docs/description/expiring_todo.md +++ b/docs/description/expiring_todo.md @@ -1,14 +1,14 @@ -# ExpiringTodo +# Expiring Todo TODOs and FIXMEs should be resolved prior to their expiry date. * **Identifier:** expiring_todo -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** (approaching_expiry_severity) warning, (reached_or_passed_expiry_severity) error +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** approaching_expiry_severity: warning, expired_severity: error, bad_formatting_severity: error, approaching_expiry_threshold: 15, date_format: MM/dd/yyyy, date_delimiters: { opening: [, closing: ] }, date_separator: / ## Non Triggering Examples @@ -60,11 +60,26 @@ TODOs and FIXMEs should be resolved prior to their expiry date. ## Triggering Examples ```swift -// TODO: [10/14/2019] +// TODO: [↓10/14/2019] ``` ```swift -// FIXME: [10/14/2019] +// FIXME: [↓10/14/2019] + +``` + +```swift +// FIXME: [↓1/14/2019] + +``` + +```swift +// FIXME: [↓10/14/2019] + +``` + +```swift +// TODO: [↓9999/14/10] ``` \ No newline at end of file diff --git a/docs/description/explicit_acl.md b/docs/description/explicit_acl.md index 99c00ad..f27e57e 100755 --- a/docs/description/explicit_acl.md +++ b/docs/description/explicit_acl.md @@ -3,11 +3,11 @@ All declarations should specify Access Control Level keywords explicitly. * **Identifier:** explicit_acl -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/explicit_enum_raw_value.md b/docs/description/explicit_enum_raw_value.md index 580dc25..2e6334f 100755 --- a/docs/description/explicit_enum_raw_value.md +++ b/docs/description/explicit_enum_raw_value.md @@ -3,11 +3,11 @@ Enums should be explicitly assigned their raw values. * **Identifier:** explicit_enum_raw_value -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -78,4 +78,12 @@ enum Numbers: String { enum Numbers: Decimal { case ↓one, ↓two } +``` + +```swift +enum Outer { + enum Numbers: Decimal { + case ↓one, ↓two + } +} ``` \ No newline at end of file diff --git a/docs/description/explicit_init.md b/docs/description/explicit_init.md index 02b96a4..ba082e2 100755 --- a/docs/description/explicit_init.md +++ b/docs/description/explicit_init.md @@ -3,21 +3,33 @@ Explicitly calling .init() should be avoided. * **Identifier:** explicit_init -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples ```swift -import Foundation; class C: NSObject { override init() { super.init() }} +import Foundation +class C: NSObject { + override init() { + super.init() + } +} ``` ```swift -struct S { let n: Int }; extension S { init() { self.init(n: 1) } } +struct S { + let n: Int +} +extension S { + init() { + self.init(n: 1) + } +} ``` ```swift @@ -36,6 +48,10 @@ struct S { let n: Int }; extension S { init() { self.init(n: 1) } } Observable.zip(obs1, obs2, resultSelector: MyType.init).asMaybe() ``` +```swift +_ = GleanMetrics.Tabs.someType.init() +``` + ```swift Observable.zip( obs1, @@ -56,14 +72,22 @@ Observable.zip( ```swift func foo() -> [String] { - return [1].flatMap { String↓.init($0) } + return [1].flatMap { String↓.init($0) } } ``` +```swift +_ = GleanMetrics.Tabs.GroupedTabExtra↓.init() +``` + +```swift +_ = Set↓.init() +``` + ```swift Observable.zip( obs1, obs2, - resultSelector: { MyType.init($0, $1) } + resultSelector: { MyType↓.init($0, $1) } ).asMaybe() ``` \ No newline at end of file diff --git a/docs/description/explicit_self.md b/docs/description/explicit_self.md index d8ecef9..f4e18d9 100755 --- a/docs/description/explicit_self.md +++ b/docs/description/explicit_self.md @@ -3,11 +3,11 @@ Instance variables and functions should be explicitly accessed with 'self.'. * **Identifier:** explicit_self -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** Yes -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/explicit_top_level_acl.md b/docs/description/explicit_top_level_acl.md index 700ab9a..a481286 100755 --- a/docs/description/explicit_top_level_acl.md +++ b/docs/description/explicit_top_level_acl.md @@ -3,11 +3,11 @@ Top-level declarations should specify Access Control Level keywords explicitly. * **Identifier:** explicit_top_level_acl -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -58,27 +58,27 @@ extension A {} ## Triggering Examples ```swift -enum A {} +↓enum A {} ``` ```swift -final class B {} +final ↓class B {} ``` ```swift -struct C {} +↓struct C {} ``` ```swift -func a() {} +↓func a() {} ``` ```swift internal let a = 0 -func b() {} +↓func b() {} ``` \ No newline at end of file diff --git a/docs/description/explicit_type_interface.md b/docs/description/explicit_type_interface.md index ad4d8f4..3fd9b1e 100755 --- a/docs/description/explicit_type_interface.md +++ b/docs/description/explicit_type_interface.md @@ -3,11 +3,11 @@ Properties should have a type interface * **Identifier:** explicit_type_interface -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, excluded: [], allow_redundancy: false ## Non Triggering Examples diff --git a/docs/description/extension_access_modifier.md b/docs/description/extension_access_modifier.md index 4ce8ccb..0984f56 100755 --- a/docs/description/extension_access_modifier.md +++ b/docs/description/extension_access_modifier.md @@ -3,11 +3,11 @@ Prefer to use extension access modifiers * **Identifier:** extension_access_modifier -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/fallthrough.md b/docs/description/fallthrough.md index 62ac6c2..abfbb97 100755 --- a/docs/description/fallthrough.md +++ b/docs/description/fallthrough.md @@ -3,11 +3,11 @@ Fallthrough should be avoided. * **Identifier:** fallthrough -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/fatal_error_message.md b/docs/description/fatal_error_message.md index c706f74..6803ad6 100755 --- a/docs/description/fatal_error_message.md +++ b/docs/description/fatal_error_message.md @@ -3,11 +3,11 @@ A fatalError call should have a message. * **Identifier:** fatal_error_message -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/file_header.md b/docs/description/file_header.md index c790009..7dea4e4 100755 --- a/docs/description/file_header.md +++ b/docs/description/file_header.md @@ -3,11 +3,11 @@ Header comments should be consistent with project patterns. The SWIFTLINT_CURRENT_FILENAME placeholder can optionally be used in the required and forbidden patterns. It will be replaced by the real file name. * **Identifier:** file_header -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, required_string: None, required_pattern: None, forbidden_string: None, forbidden_pattern: None ## Non Triggering Examples diff --git a/docs/description/file_length.md b/docs/description/file_length.md index 99f397d..aedf948 100755 --- a/docs/description/file_length.md +++ b/docs/description/file_length.md @@ -3,11 +3,11 @@ Files should not span too many lines. * **Identifier:** file_length -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** metrics * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning: 400, error: 1000, ignore_comment_only_lines: false ## Non Triggering Examples @@ -412,7 +412,6 @@ print("swiftlint") print("swiftlint") print("swiftlint") print("swiftlint") -print("swiftlint") ``` @@ -1226,4 +1225,410 @@ print("swiftlint") print("swiftlint") // +``` + +```swift +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + +print("swiftlint") + + ``` \ No newline at end of file diff --git a/docs/description/file_name.md b/docs/description/file_name.md index 17702a3..d4e87ef 100755 --- a/docs/description/file_name.md +++ b/docs/description/file_name.md @@ -3,9 +3,9 @@ File name should match a type or extension declared in the file (if any). * **Identifier:** file_name -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** (severity) warning, excluded: ["LinuxMain.swift", "main.swift"], prefix_pattern: , suffix_pattern: \+.*, nested_type_separator: . \ No newline at end of file diff --git a/docs/description/file_name_no_space.md b/docs/description/file_name_no_space.md index 3ac0ead..925220b 100755 --- a/docs/description/file_name_no_space.md +++ b/docs/description/file_name_no_space.md @@ -3,9 +3,9 @@ File name should not contain any whitespace. * **Identifier:** file_name_no_space -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** (severity) warning, excluded: [] \ No newline at end of file diff --git a/docs/description/file_types_order.md b/docs/description/file_types_order.md index 50c8f20..cee2d15 100755 --- a/docs/description/file_types_order.md +++ b/docs/description/file_types_order.md @@ -3,12 +3,12 @@ Specifies how the types within a file should be ordered. * **Identifier:** file_types_order -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning, order: [[SwiftLintFramework.FileType.supportingType], [SwiftLintFramework.FileType.mainType], [SwiftLintFramework.FileType.extension], [SwiftLintFramework.FileType.previewProvider]] +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning, order: [[SwiftLintFramework.FileType.supportingType], [SwiftLintFramework.FileType.mainType], [SwiftLintFramework.FileType.extension], [SwiftLintFramework.FileType.previewProvider], [SwiftLintFramework.FileType.libraryContentProvider]] ## Non Triggering Examples @@ -128,15 +128,24 @@ extension Bar { ``` ```swift +// Main Type struct ContentView: View { var body: some View { Text("Hello, World!") } } +// Preview Provider struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } + +// Library Content Provider +struct ContentView_LibraryContent: LibraryContentProvider { + var views: [LibraryItem] { + LibraryItem(ContentView()) + } +} ``` ## Triggering Examples @@ -200,8 +209,30 @@ extension TestViewController: UITableViewDataSource { ```swift // Preview Provider -↓struct ContentView_Previews: PreviewProvider {} +↓struct ContentView_Previews: PreviewProvider { + static var previews: some View { ContentView() } +} + +// Main Type +struct ContentView: View { + var body: some View { + Text("Hello, World!") + } +} +``` + +```swift +// Library Content Provider +↓struct ContentView_LibraryContent: LibraryContentProvider { + var views: [LibraryItem] { + LibraryItem(ContentView()) + } +} // Main Type -struct ContentView: View {} +struct ContentView: View { + var body: some View { + Text("Hello, World!") + } +} ``` \ No newline at end of file diff --git a/docs/description/first_where.md b/docs/description/first_where.md index c58a96d..cacd9db 100755 --- a/docs/description/first_where.md +++ b/docs/description/first_where.md @@ -3,11 +3,11 @@ Prefer using `.first(where:)` over `.filter { }.first` in collections. * **Identifier:** first_where -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -80,4 +80,12 @@ if let pause = timeTracker.pauses.filter("beginDate < %@", beginDate).first { pr ```swift (↓myList.filter { $0 == 1 }).first +``` + +```swift +↓myListOfDict.filter { dict in dict["1"] }.first +``` + +```swift +↓myListOfDict.filter { $0["someString"] }.first ``` \ No newline at end of file diff --git a/docs/description/flatmap_over_map_reduce.md b/docs/description/flatmap_over_map_reduce.md index a7f7ede..53edf71 100755 --- a/docs/description/flatmap_over_map_reduce.md +++ b/docs/description/flatmap_over_map_reduce.md @@ -3,11 +3,11 @@ Prefer `flatMap` over `map` followed by `reduce([], +)`. * **Identifier:** flatmap_over_map_reduce -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/for_where.md b/docs/description/for_where.md index d7f5fa3..4cef146 100755 --- a/docs/description/for_where.md +++ b/docs/description/for_where.md @@ -3,12 +3,12 @@ `where` clauses are preferred over a single `if` inside a `for`. * **Identifier:** for_where -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning, allow_for_as_filter: false ## Non Triggering Examples @@ -68,6 +68,12 @@ for user in users { } ``` +```swift +for user in users { + if user.id == 1, user.age > 18 { } +} +``` + ```swift for (index, value) in array.enumerated() { if case .valueB(_) = value { @@ -76,10 +82,43 @@ for (index, value) in array.enumerated() { } ``` +```swift +for user in users { + if user.id == 1 { return true } +} +``` + +```swift +for user in users { + if user.id == 1 { + let derivedValue = calculateValue(from: user) + return derivedValue != 0 + } +} +``` + ## Triggering Examples ```swift for user in users { ↓if user.id == 1 { return true } } +``` + +```swift +for subview in subviews { + ↓if !(subview is UIStackView) { + subview.removeConstraints(subview.constraints) + subview.removeFromSuperview() + } +} +``` + +```swift +for subview in subviews { + ↓if !(subview is UIStackView) { + subview.removeConstraints(subview.constraints) + subview.removeFromSuperview() + } +} ``` \ No newline at end of file diff --git a/docs/description/force_cast.md b/docs/description/force_cast.md index caf6638..b12992d 100755 --- a/docs/description/force_cast.md +++ b/docs/description/force_cast.md @@ -3,11 +3,11 @@ Force casts should be avoided. * **Identifier:** force_cast -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** error ## Non Triggering Examples diff --git a/docs/description/force_try.md b/docs/description/force_try.md index 75f4dff..7ac131c 100755 --- a/docs/description/force_try.md +++ b/docs/description/force_try.md @@ -3,11 +3,11 @@ Force tries should be avoided. * **Identifier:** force_try -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** error ## Non Triggering Examples diff --git a/docs/description/force_unwrapping.md b/docs/description/force_unwrapping.md index a4df152..5c8b50f 100755 --- a/docs/description/force_unwrapping.md +++ b/docs/description/force_unwrapping.md @@ -3,11 +3,11 @@ Force unwrapping should be avoided. * **Identifier:** force_unwrapping -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -107,11 +107,17 @@ let url = NSURL(string: "http://www.google.com")↓! ``` ```swift -let dict = ["Boooo": "👻"]func bla() -> String { return dict["Boooo"]↓! } +let dict = ["Boooo": "👻"] +func bla() -> String { + return dict["Boooo"]↓! +} ``` ```swift -let dict = ["Boooo": "👻"]func bla() -> String { return dict["Boooo"]↓!.contains("B") } +let dict = ["Boooo": "👻"] +func bla() -> String { + return dict["Boooo"]↓!.contains("B") +} ``` ```swift @@ -123,13 +129,17 @@ dict["abc"]↓!.bar("B") ``` ```swift -if dict["a"]↓!!!! { +if dict["a"]↓!↓!↓!↓! {} ``` ```swift var foo: [Bool]! = dict["abc"]↓! ``` +```swift +realm.objects(SwiftUTF8Object.self).filter("%K == %@", "柱нǢкƱаم👍", utf8TestString).first↓! +``` + ```swift context("abc") { var foo: [Bool]! = dict["abc"]↓! @@ -142,4 +152,12 @@ open var computed: String { return foo.bar↓! } ```swift return self↓! +``` + +```swift +[1, 3, 5, 6].first { $0.isMultiple(of: 2) }↓! +``` + +```swift +map["a"]↓!↓! ``` \ No newline at end of file diff --git a/docs/description/function_body_length.md b/docs/description/function_body_length.md index 6b694fd..26e823e 100755 --- a/docs/description/function_body_length.md +++ b/docs/description/function_body_length.md @@ -3,9 +3,9 @@ Functions bodies should not span too many lines. * **Identifier:** function_body_length -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** metrics * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning: 40, error: 100 \ No newline at end of file +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning: 50, error: 100 \ No newline at end of file diff --git a/docs/description/function_default_parameter_at_end.md b/docs/description/function_default_parameter_at_end.md index 4e04488..866f35d 100755 --- a/docs/description/function_default_parameter_at_end.md +++ b/docs/description/function_default_parameter_at_end.md @@ -3,11 +3,11 @@ Prefer to locate parameters with defaults toward the end of the parameter list. * **Identifier:** function_default_parameter_at_end -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -56,8 +56,30 @@ func foo(a: String, b: String? = nil, c: String? = nil, d: @escaping AlertActionHandler = { _ in }) {} ``` +```swift +override init?(for date: Date = Date(), coordinate: CLLocationCoordinate2D) {} +``` + +```swift +func handleNotification(_ userInfo: NSDictionary, + userInteraction: Bool = false, + completionHandler: ((UIBackgroundFetchResult) -> Void)?) {} +``` + +```swift +func write(withoutNotifying tokens: [NotificationToken] = {}, _ block: (() throws -> Int)) {} +``` + ## Triggering Examples ```swift ↓func foo(bar: Int = 0, baz: String) {} +``` + +```swift +private ↓func foo(bar: Int = 0, baz: String) {} +``` + +```swift +public ↓init?(for date: Date = Date(), coordinate: CLLocationCoordinate2D) {} ``` \ No newline at end of file diff --git a/docs/description/function_parameter_count.md b/docs/description/function_parameter_count.md index 028fe36..784c801 100755 --- a/docs/description/function_parameter_count.md +++ b/docs/description/function_parameter_count.md @@ -3,11 +3,11 @@ Number of function parameters should be low. * **Identifier:** function_parameter_count -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** metrics * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning: 5, error: 8ignores_default_parameters: true ## Non Triggering Examples @@ -64,7 +64,7 @@ override func f(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {} ``` ```swift -↓func f(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int = 2, g: Int) {} +private ↓func f(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int = 2, g: Int) {} ``` ```swift diff --git a/docs/description/generic_type_name.md b/docs/description/generic_type_name.md index 963cc4d..b9a4478 100755 --- a/docs/description/generic_type_name.md +++ b/docs/description/generic_type_name.md @@ -3,11 +3,11 @@ Generic type name should only contain alphanumeric characters, start with an uppercase character and span between 1 and 20 characters in length. * **Identifier:** generic_type_name -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** (min_length) w/e: 1/0, (max_length) w/e: 20/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true ## Non Triggering Examples diff --git a/docs/description/ibinspectable_in_extension.md b/docs/description/ibinspectable_in_extension.md index 2ee7c66..3a49ad3 100755 --- a/docs/description/ibinspectable_in_extension.md +++ b/docs/description/ibinspectable_in_extension.md @@ -3,11 +3,11 @@ Extensions shouldn't add @IBInspectable properties. * **Identifier:** ibinspectable_in_extension -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -22,6 +22,6 @@ class Foo { ```swift extension Foo { - @IBInspectable private var x: Int + ↓@IBInspectable private var x: Int } ``` \ No newline at end of file diff --git a/docs/description/identical_operands.md b/docs/description/identical_operands.md index b014c92..3c84483 100755 --- a/docs/description/identical_operands.md +++ b/docs/description/identical_operands.md @@ -3,11 +3,11 @@ Comparing two identical operands is likely a mistake. * **Identifier:** identical_operands -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -73,6 +73,14 @@ _ = num != nil && num == num?.byteSwapped num == num!.byteSwapped ``` +```swift +1 + 1 == 1 + 2 +``` + +```swift +f( i : 2) == f (i: 3 ) +``` + ```swift 1 != 2 ``` @@ -134,6 +142,14 @@ _ = num != nil && num != num?.byteSwapped num != num!.byteSwapped ``` +```swift +1 + 1 != 1 + 2 +``` + +```swift +f( i : 2) != f (i: 3 ) +``` + ```swift 1 === 2 ``` @@ -195,6 +211,14 @@ _ = num != nil && num === num?.byteSwapped num === num!.byteSwapped ``` +```swift +1 + 1 === 1 + 2 +``` + +```swift +f( i : 2) === f (i: 3 ) +``` + ```swift 1 !== 2 ``` @@ -256,6 +280,14 @@ _ = num != nil && num !== num?.byteSwapped num !== num!.byteSwapped ``` +```swift +1 + 1 !== 1 + 2 +``` + +```swift +f( i : 2) !== f (i: 3 ) +``` + ```swift 1 > 2 ``` @@ -317,6 +349,14 @@ _ = num != nil && num > num?.byteSwapped num > num!.byteSwapped ``` +```swift +1 + 1 > 1 + 2 +``` + +```swift +f( i : 2) > f (i: 3 ) +``` + ```swift 1 >= 2 ``` @@ -378,6 +418,14 @@ _ = num != nil && num >= num?.byteSwapped num >= num!.byteSwapped ``` +```swift +1 + 1 >= 1 + 2 +``` + +```swift +f( i : 2) >= f (i: 3 ) +``` + ```swift 1 < 2 ``` @@ -439,6 +487,14 @@ _ = num != nil && num < num?.byteSwapped num < num!.byteSwapped ``` +```swift +1 + 1 < 1 + 2 +``` + +```swift +f( i : 2) < f (i: 3 ) +``` + ```swift 1 <= 2 ``` @@ -500,6 +556,14 @@ _ = num != nil && num <= num?.byteSwapped num <= num!.byteSwapped ``` +```swift +1 + 1 <= 1 + 2 +``` + +```swift +f( i : 2) <= f (i: 3 ) +``` + ```swift func evaluate(_ mode: CommandMode) -> Result>> ``` @@ -524,6 +588,14 @@ type(of: model).cachePrefix == cachePrefix histogram[156].0 == 0x003B8D96 && histogram[156].1 == 1 ``` +```swift +[Wrapper(type: .three), Wrapper(type: .one)].sorted { "\($0.type)" > "\($1.type)"} +``` + +```swift +array.sorted { "\($0)" < "\($1)" } +``` + ## Triggering Examples ```swift @@ -562,6 +634,15 @@ XCTAssertTrue(↓s3 == s3) if let tab = tabManager.selectedTab, ↓tab.webView == tab.webView ``` +```swift +↓1 + 1 == 1 + 1 +``` + +```swift + ↓f( i : 2) == f (i: + 2 ) +``` + ```swift ↓1 != 1 ``` @@ -598,6 +679,15 @@ XCTAssertTrue(↓s3 != s3) if let tab = tabManager.selectedTab, ↓tab.webView != tab.webView ``` +```swift +↓1 + 1 != 1 + 1 +``` + +```swift + ↓f( i : 2) != f (i: + 2 ) +``` + ```swift ↓1 === 1 ``` @@ -634,6 +724,15 @@ XCTAssertTrue(↓s3 === s3) if let tab = tabManager.selectedTab, ↓tab.webView === tab.webView ``` +```swift +↓1 + 1 === 1 + 1 +``` + +```swift + ↓f( i : 2) === f (i: + 2 ) +``` + ```swift ↓1 !== 1 ``` @@ -670,6 +769,15 @@ XCTAssertTrue(↓s3 !== s3) if let tab = tabManager.selectedTab, ↓tab.webView !== tab.webView ``` +```swift +↓1 + 1 !== 1 + 1 +``` + +```swift + ↓f( i : 2) !== f (i: + 2 ) +``` + ```swift ↓1 > 1 ``` @@ -706,6 +814,15 @@ XCTAssertTrue(↓s3 > s3) if let tab = tabManager.selectedTab, ↓tab.webView > tab.webView ``` +```swift +↓1 + 1 > 1 + 1 +``` + +```swift + ↓f( i : 2) > f (i: + 2 ) +``` + ```swift ↓1 >= 1 ``` @@ -742,6 +859,15 @@ XCTAssertTrue(↓s3 >= s3) if let tab = tabManager.selectedTab, ↓tab.webView >= tab.webView ``` +```swift +↓1 + 1 >= 1 + 1 +``` + +```swift + ↓f( i : 2) >= f (i: + 2 ) +``` + ```swift ↓1 < 1 ``` @@ -778,6 +904,15 @@ XCTAssertTrue(↓s3 < s3) if let tab = tabManager.selectedTab, ↓tab.webView < tab.webView ``` +```swift +↓1 + 1 < 1 + 1 +``` + +```swift + ↓f( i : 2) < f (i: + 2 ) +``` + ```swift ↓1 <= 1 ``` @@ -812,4 +947,23 @@ XCTAssertTrue(↓s3 <= s3) ```swift if let tab = tabManager.selectedTab, ↓tab.webView <= tab.webView +``` + +```swift +↓1 + 1 <= 1 + 1 +``` + +```swift + ↓f( i : 2) <= f (i: + 2 ) +``` + +```swift + return ↓lhs.foo == lhs.foo && + lhs.bar == rhs.bar +``` + +```swift + return lhs.foo == rhs.foo && + ↓lhs.bar == lhs.bar ``` \ No newline at end of file diff --git a/docs/description/identifier_name.md b/docs/description/identifier_name.md index a6f10dd..327f6bd 100755 --- a/docs/description/identifier_name.md +++ b/docs/description/identifier_name.md @@ -3,12 +3,12 @@ Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared static and immutable. Variable names should not be too long or too short. * **Identifier:** identifier_name -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** (min_length) w/e: 3/2, (max_length) w/e: 40/60, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** (min_length) w/e: 3/2, (max_length) w/e: 40/60, excluded: ["id"], allowed_symbols: [], validates_start_with_lowercase: true ## Non Triggering Examples @@ -99,7 +99,7 @@ private ↓let _myExtremelyVeryVeryVeryVeryVeryVeryLongLet = 0 ``` ```swift -↓var id = 0 +↓var aa = 0 ``` ```swift diff --git a/docs/description/implicit_getter.md b/docs/description/implicit_getter.md index 2ed9bc3..2520c5e 100755 --- a/docs/description/implicit_getter.md +++ b/docs/description/implicit_getter.md @@ -3,11 +3,11 @@ Computed read-only properties and subscripts should avoid using the get keyword. * **Identifier:** implicit_getter -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -71,6 +71,7 @@ class Foo { ```swift protocol Foo { var foo: Int { get } +} ``` ```swift @@ -195,6 +196,30 @@ protocol Foo { } ``` +```swift +class DatabaseEntity { + var isSynced: Bool { + get async { + await database.isEntitySynced(self) + } + } +} +``` + +```swift +struct Test { + subscript(value: Int) -> Int { + get throws { + if value == 0 { + throw NSError() + } else { + return value + } + } + } +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/implicit_return.md b/docs/description/implicit_return.md index d378797..14b7237 100755 --- a/docs/description/implicit_return.md +++ b/docs/description/implicit_return.md @@ -3,12 +3,12 @@ Prefer implicit returns in closures, functions and getters. * **Identifier:** implicit_return -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning, included: [getter, function, closure] +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning, included: [closure, function, getter] ## Non Triggering Examples @@ -48,6 +48,16 @@ class Foo { } ``` +```swift +func fetch() -> Data? { + do { + return try loadData() + } catch { + return nil + } +} +``` + ```swift var foo: Bool { true } ``` diff --git a/docs/description/implicitly_unwrapped_optional.md b/docs/description/implicitly_unwrapped_optional.md index 79db81d..6ec49f7 100755 --- a/docs/description/implicitly_unwrapped_optional.md +++ b/docs/description/implicitly_unwrapped_optional.md @@ -3,11 +3,11 @@ Implicitly unwrapped optionals should be avoided when possible. * **Identifier:** implicitly_unwrapped_optional -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, mode: allExceptIBOutlets ## Non Triggering Examples @@ -70,10 +70,6 @@ let int: Int! = nil var int: Int! = 42 ``` -```swift -let int: ImplicitlyUnwrappedOptional -``` - ```swift let collection: AnyCollection ``` diff --git a/docs/description/inclusive_language.md b/docs/description/inclusive_language.md index ab3d922..b973aec 100755 --- a/docs/description/inclusive_language.md +++ b/docs/description/inclusive_language.md @@ -1,13 +1,13 @@ # Inclusive Language - Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status +Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status * **Identifier:** inclusive_language -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, additional_terms: [], override_terms: [], override_allowed_terms: [] ## Non Triggering Examples @@ -61,7 +61,7 @@ enum ListType { ``` ```swift -↓init(master: String, slave: String) {} +init(↓master: String, ↓slave: String) {} ``` ```swift diff --git a/docs/description/indentation_width.md b/docs/description/indentation_width.md index 3a3d011..46fbffe 100755 --- a/docs/description/indentation_width.md +++ b/docs/description/indentation_width.md @@ -3,12 +3,12 @@ Indent code using either one tab or the configured amount of spaces, unindent to match previous indentations. Don't indent the first line. * **Identifier:** indentation_width -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** severity: warning, indentation_width: 4include_comments: true +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** severity: warning, indentation_width: 4, include_comments: true ## Non Triggering Examples @@ -34,7 +34,7 @@ firstLine firstLine secondLine thirdLine -//test + //test fourthLine ``` @@ -48,7 +48,7 @@ fourthLine ## Triggering Examples ```swift - firstLine +↓ firstLine ``` ```swift @@ -60,12 +60,12 @@ firstLine firstLine secondLine - fourthLine +↓ fourthLine ``` ```swift firstLine secondLine thirdLine - fourthLine +↓ fourthLine ``` \ No newline at end of file diff --git a/docs/description/inert_defer.md b/docs/description/inert_defer.md index 3fd0c4d..068914a 100755 --- a/docs/description/inert_defer.md +++ b/docs/description/inert_defer.md @@ -3,11 +3,11 @@ If defer is at the end of its parent scope, it will be executed right where it is anyway. * **Identifier:** inert_defer -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/is_disjoint.md b/docs/description/is_disjoint.md index 9ce3ff8..0367431 100755 --- a/docs/description/is_disjoint.md +++ b/docs/description/is_disjoint.md @@ -3,11 +3,11 @@ Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty`. * **Identifier:** is_disjoint -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/joined_default_parameter.md b/docs/description/joined_default_parameter.md index 07ad272..1e760f8 100755 --- a/docs/description/joined_default_parameter.md +++ b/docs/description/joined_default_parameter.md @@ -3,11 +3,11 @@ Discouraged explicit usage of the default separator. * **Identifier:** joined_default_parameter -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/large_tuple.md b/docs/description/large_tuple.md index e31b65a..637f190 100755 --- a/docs/description/large_tuple.md +++ b/docs/description/large_tuple.md @@ -3,11 +3,11 @@ Tuples shouldn't have too many members. Create a custom type instead. * **Identifier:** large_tuple -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** metrics * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning: 2, error: 3 ## Non Triggering Examples @@ -92,25 +92,85 @@ func getGenericTypeAndInt() -> (Type, Int)? ``` +```swift +func foo() async -> (Int, Int) + +``` + +```swift +func foo() async -> (Int, Int) {} + +``` + +```swift +func foo(bar: String) async -> (Int, Int) + +``` + +```swift +func foo(bar: String) async -> (Int, Int) {} + +``` + +```swift +func foo() async throws -> (Int, Int) + +``` + +```swift +func foo() async throws -> (Int, Int) {} + +``` + +```swift +let foo: (Int, Int, Int) async -> Void + +``` + +```swift +let foo: (Int, Int, Int) async throws -> Void + +``` + +```swift +func foo(bar: (Int, String, Float) async -> Void) + +``` + +```swift +func foo(bar: (Int, String, Float) async throws -> Void) + +``` + +```swift +func getDictionaryAndInt() async -> (Dictionary, Int)? + +``` + +```swift +func getGenericTypeAndInt() async -> (Type, Int)? + +``` + ## Triggering Examples ```swift -↓let foo: (Int, Int, Int) +let foo: ↓(Int, Int, Int) ``` ```swift -↓let foo: (start: Int, end: Int, value: String) +let foo: ↓(start: Int, end: Int, value: String) ``` ```swift -↓let foo: (Int, (Int, Int, Int)) +let foo: (Int, ↓(Int, Int, Int)) ``` ```swift -func foo(↓bar: (Int, Int, Int)) +func foo(bar: ↓(Int, Int, Int)) ``` @@ -152,4 +212,49 @@ func foo() throws -> ↓(Int, ↓(String, String, String), Int) {} ```swift func getDictionaryAndInt() -> (Dictionary, Int)? +``` + +```swift +func foo(bar: ↓(Int, Int, Int)) async + +``` + +```swift +func foo() async -> ↓(Int, Int, Int) + +``` + +```swift +func foo() async -> ↓(Int, Int, Int) {} + +``` + +```swift +func foo(bar: String) async -> ↓(Int, Int, Int) + +``` + +```swift +func foo(bar: String) async -> ↓(Int, Int, Int) {} + +``` + +```swift +func foo() async throws -> ↓(Int, Int, Int) + +``` + +```swift +func foo() async throws -> ↓(Int, Int, Int) {} + +``` + +```swift +func foo() async throws -> ↓(Int, ↓(String, String, String), Int) {} + +``` + +```swift +func getDictionaryAndInt() async -> (Dictionary, Int)? + ``` \ No newline at end of file diff --git a/docs/description/last_where.md b/docs/description/last_where.md index 1c4c00e..3ecff1c 100755 --- a/docs/description/last_where.md +++ b/docs/description/last_where.md @@ -3,11 +3,11 @@ Prefer using `.last(where:)` over `.filter { }.last` in collections. * **Identifier:** last_where -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.2.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/leading_whitespace.md b/docs/description/leading_whitespace.md index 11c4ac0..f31054b 100755 --- a/docs/description/leading_whitespace.md +++ b/docs/description/leading_whitespace.md @@ -3,11 +3,11 @@ Files should not contain leading whitespace. * **Identifier:** leading_whitespace -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -21,6 +21,7 @@ Files should not contain leading whitespace. ```swift +// ``` diff --git a/docs/description/legacy_cggeometry_functions.md b/docs/description/legacy_cggeometry_functions.md index c610702..f8aca26 100755 --- a/docs/description/legacy_cggeometry_functions.md +++ b/docs/description/legacy_cggeometry_functions.md @@ -3,11 +3,11 @@ Struct extension properties and methods are preferred over legacy functions * **Identifier:** legacy_cggeometry_functions -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/legacy_constant.md b/docs/description/legacy_constant.md index 364cf7a..d92d7ad 100755 --- a/docs/description/legacy_constant.md +++ b/docs/description/legacy_constant.md @@ -3,11 +3,11 @@ Struct-scoped constants are preferred over legacy global constants. * **Identifier:** legacy_constant -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/legacy_constructor.md b/docs/description/legacy_constructor.md index e7be026..738789b 100755 --- a/docs/description/legacy_constructor.md +++ b/docs/description/legacy_constructor.md @@ -3,11 +3,11 @@ Swift constructors are preferred over legacy convenience functions. * **Identifier:** legacy_constructor -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/legacy_hashing.md b/docs/description/legacy_hashing.md index d69b183..fc3466d 100755 --- a/docs/description/legacy_hashing.md +++ b/docs/description/legacy_hashing.md @@ -3,11 +3,11 @@ Prefer using the `hash(into:)` function instead of overriding `hashValue` * **Identifier:** legacy_hashing -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.2.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/legacy_multiple.md b/docs/description/legacy_multiple.md index 58670da..d9b52a8 100755 --- a/docs/description/legacy_multiple.md +++ b/docs/description/legacy_multiple.md @@ -3,7 +3,7 @@ Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`). * **Identifier:** legacy_multiple -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No @@ -48,6 +48,10 @@ let secretValue = (value % 3) + 2 cell.contentView.backgroundColor = indexPath.row ↓% 2 == 0 ? .gray : .white ``` +```swift +cell.contentView.backgroundColor = 0 == indexPath.row ↓% 2 ? .gray : .white +``` + ```swift cell.contentView.backgroundColor = indexPath.row ↓% 2 != 0 ? .gray : .white ``` diff --git a/docs/description/legacy_nsgeometry_functions.md b/docs/description/legacy_nsgeometry_functions.md index d7ef78a..2eca251 100755 --- a/docs/description/legacy_nsgeometry_functions.md +++ b/docs/description/legacy_nsgeometry_functions.md @@ -3,11 +3,11 @@ Struct extension properties and methods are preferred over legacy functions * **Identifier:** legacy_nsgeometry_functions -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -65,7 +65,7 @@ rect1.union(rect2) ``` ```swift -rect1.intersect(rect2) +rect1.intersection(rect2) ``` ```swift diff --git a/docs/description/legacy_objc_type.md b/docs/description/legacy_objc_type.md index 707b6d7..965dbc0 100755 --- a/docs/description/legacy_objc_type.md +++ b/docs/description/legacy_objc_type.md @@ -3,11 +3,11 @@ Prefer Swift value types to bridged Objective-C reference types * **Identifier:** legacy_objc_type -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -21,12 +21,52 @@ var array = Array() var calendar: Calendar? = nil ``` +```swift +var formatter: NSDataDetector +``` + +```swift +var className: String = NSStringFromClass(MyClass.self) +``` + +```swift +_ = URLRequest.CachePolicy.reloadIgnoringLocalCacheData +``` + +```swift +_ = Notification.Name("com.apple.Music.playerInfo") +``` + ## Triggering Examples ```swift -var array = NSArray() +var array = ↓NSArray() +``` + +```swift +var calendar: ↓NSCalendar? = nil +``` + +```swift +_ = ↓NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData +``` + +```swift +_ = ↓NSNotification.Name("com.apple.Music.playerInfo") +``` + +```swift +let keyValuePair: (Int) -> (↓NSString, ↓NSString) = { + let n = "\($0)" as ↓NSString; return (n, n) +} +dictionary = [↓NSString: ↓NSString](uniqueKeysWithValues: + (1...10_000).lazy.map(keyValuePair)) ``` ```swift -var calendar: NSCalendar? = nil +extension Foundation.Notification.Name { + static var reachabilityChanged: Foundation.↓NSNotification.Name { + return Foundation.Notification.Name("org.wordpress.reachability.changed") + } +} ``` \ No newline at end of file diff --git a/docs/description/legacy_random.md b/docs/description/legacy_random.md index 190b379..58ec0de 100755 --- a/docs/description/legacy_random.md +++ b/docs/description/legacy_random.md @@ -3,11 +3,11 @@ Prefer using `type.random(in:)` over legacy functions. * **Identifier:** legacy_random -* **Enabled by default:** Disabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.2.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/let_var_whitespace.md b/docs/description/let_var_whitespace.md index 181c27f..ed629a9 100755 --- a/docs/description/let_var_whitespace.md +++ b/docs/description/let_var_whitespace.md @@ -3,11 +3,11 @@ Let and var should be separated from other statements by a blank line. * **Identifier:** let_var_whitespace -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -119,6 +119,15 @@ var x = 0 let x = bar as! Bar ``` +```swift + @available(swift 4) + @UserDefault("param", defaultValue: true) + var isEnabled = true + + @Attribute + func f() {} +``` + ```swift var x: Int { let a = 0 @@ -168,4 +177,15 @@ var x = 0 } ↓var x = 0 +``` + +```swift + struct S { + func f() {} + ↓@Wapper + let isNumber = false + @Wapper + var isEnabled = true + ↓func g() {} + } ``` \ No newline at end of file diff --git a/docs/description/line_length.md b/docs/description/line_length.md index 03315ce..f0a46b9 100755 --- a/docs/description/line_length.md +++ b/docs/description/line_length.md @@ -3,11 +3,11 @@ Lines should not span too many characters. * **Identifier:** line_length -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** metrics * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning: 120, error: 200, ignores urls: false, ignores function declarations: false, ignores comments: false, ignores interpolated strings: false ## Non Triggering Examples diff --git a/docs/description/literal_expression_end_indentation.md b/docs/description/literal_expression_end_indentation.md index d1499c7..790c86f 100755 --- a/docs/description/literal_expression_end_indentation.md +++ b/docs/description/literal_expression_end_indentation.md @@ -3,11 +3,11 @@ Array and dictionary literal end should have the same indentation as the line that started it. * **Identifier:** literal_expression_end_indentation -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/local_doc_comment.md b/docs/description/local_doc_comment.md new file mode 100755 index 0000000..6886c03 --- /dev/null +++ b/docs/description/local_doc_comment.md @@ -0,0 +1,45 @@ +# Local Doc Comment + +Doc comments shouldn't be used in local scopes. Use regular comments. + +* **Identifier:** local_doc_comment +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func foo() { + // Local scope documentation should use normal comments. + print("foo") +} +``` + +```swift +/// My great property +var myGreatProperty: String! +``` + +```swift +/// Look here for more info: https://github.com. +var myGreatProperty: String! +``` + +```swift +/// Look here for more info: +/// https://github.com. +var myGreatProperty: String! +``` + +## Triggering Examples + +```swift +func foo() { + ↓/// Docstring inside a function declaration + print("foo") +} +``` \ No newline at end of file diff --git a/docs/description/lower_acl_than_parent.md b/docs/description/lower_acl_than_parent.md index 69059ea..b480862 100755 --- a/docs/description/lower_acl_than_parent.md +++ b/docs/description/lower_acl_than_parent.md @@ -1,13 +1,13 @@ # Lower ACL than parent -Ensure definitions have a lower access control level than their enclosing parent +Ensure declarations have a lower access control level than their enclosing parent * **Identifier:** lower_acl_than_parent -* **Enabled by default:** Disabled -* **Supports autocorrection:** No +* **Enabled by default:** No +* **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -24,6 +24,10 @@ internal struct Foo { func bar() {} } struct Foo { func bar() {} } ``` +```swift +struct Foo { internal func bar() {} } +``` + ```swift open class Foo { public func bar() {} } ``` @@ -56,24 +60,100 @@ private func foo(id: String) {} private class Foo { func bar() {} } ``` +```swift +public extension Foo { struct Bar { public func baz() {} }} +``` + +```swift +public extension Foo { struct Bar { internal func baz() {} }} +``` + +```swift +internal extension Foo { struct Bar { internal func baz() {} }} +``` + +```swift +extension Foo { struct Bar { internal func baz() {} }} +``` + ## Triggering Examples ```swift -struct Foo { public ↓func bar() {} } +struct Foo { ↓public func bar() {} } +``` + +```swift +enum Foo { ↓public func bar() {} } +``` + +```swift +public class Foo { ↓open func bar() } +``` + +```swift +class Foo { ↓public private(set) var bar: String? } +``` + +```swift +private struct Foo { ↓public func bar() {} } +``` + +```swift +private class Foo { ↓public func bar() {} } +``` + +```swift +private actor Foo { ↓public func bar() {} } +``` + +```swift +fileprivate struct Foo { ↓public func bar() {} } +``` + +```swift +class Foo { ↓public func bar() {} } +``` + +```swift +actor Foo { ↓public func bar() {} } +``` + +```swift +private struct Foo { ↓internal func bar() {} } +``` + +```swift +fileprivate struct Foo { ↓internal func bar() {} } +``` + +```swift +extension Foo { struct Bar { ↓public func baz() {} }} +``` + +```swift +internal extension Foo { struct Bar { ↓public func baz() {} }} +``` + +```swift +private extension Foo { struct Bar { ↓public func baz() {} }} +``` + +```swift +fileprivate extension Foo { struct Bar { ↓public func baz() {} }} ``` ```swift -enum Foo { public ↓func bar() {} } +private extension Foo { struct Bar { ↓internal func baz() {} }} ``` ```swift -public class Foo { open ↓func bar() } +fileprivate extension Foo { struct Bar { ↓internal func baz() {} }} ``` ```swift -class Foo { public private(set) ↓var bar: String? } +public extension Foo { struct Bar { struct Baz { ↓public func qux() {} }}} ``` ```swift -private class Foo { internal ↓func bar() {} } +final class Foo { ↓public func bar() {} } ``` \ No newline at end of file diff --git a/docs/description/mark.md b/docs/description/mark.md index b040f92..e6cad2c 100755 --- a/docs/description/mark.md +++ b/docs/description/mark.md @@ -3,11 +3,11 @@ MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...' * **Identifier:** mark -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -39,6 +39,16 @@ MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...' // BOOKMARKS ``` +```swift +/* +func test1() { +} +//MARK: mark +func test2() { +} +*/ +``` + ## Triggering Examples ```swift diff --git a/docs/description/missing_docs.md b/docs/description/missing_docs.md index f26397f..ce9db84 100755 --- a/docs/description/missing_docs.md +++ b/docs/description/missing_docs.md @@ -3,12 +3,12 @@ Declarations should be documented. * **Identifier:** missing_docs -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.1.0 -* **Default configuration:** warning: open, public +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning: open, public, excludes_extensions: true, excludes_inherited_types: true, excludes_trivial_init: false ## Non Triggering Examples @@ -18,13 +18,13 @@ public class A { /// docs public func b() {} } -/// docs +// no docs public class B: A { override public func b() {} } ``` ```swift import Foundation -/// docs +// no docs public class B: NSObject { // no docs override public var description: String { fatalError() } } @@ -41,6 +41,13 @@ public class A { public extension A {} ``` +```swift +/// docs +public class A { + public init() {} +} +``` + ## Triggering Examples ```swift @@ -70,4 +77,11 @@ public struct C: A { public let b: Int } +``` + +```swift +/// docs +public class A { + public init(argument: String) {} +} ``` \ No newline at end of file diff --git a/docs/description/modifier_order.md b/docs/description/modifier_order.md index f10644b..e889aa2 100755 --- a/docs/description/modifier_order.md +++ b/docs/description/modifier_order.md @@ -3,18 +3,18 @@ Modifier order should be consistent. * **Identifier:** modifier_order -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.1.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, preferred_modifier_order: [override, acl, setterACL, dynamic, mutators, lazy, final, required, convenience, typeMethods, owned] ## Non Triggering Examples ```swift public class Foo { - public convenience required init() {} + public required convenience init() {} } ``` diff --git a/docs/description/multiline_arguments.md b/docs/description/multiline_arguments.md index 6f319d0..472daa3 100755 --- a/docs/description/multiline_arguments.md +++ b/docs/description/multiline_arguments.md @@ -3,11 +3,11 @@ Arguments should be either on the same line, or one per line. * **Identifier:** multiline_arguments -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, first_argument_location: any_line, only_enforce_after_first_closure_on_first_line: false ## Non Triggering Examples diff --git a/docs/description/multiline_arguments_brackets.md b/docs/description/multiline_arguments_brackets.md index 00a54bf..5747f9d 100755 --- a/docs/description/multiline_arguments_brackets.md +++ b/docs/description/multiline_arguments_brackets.md @@ -3,11 +3,11 @@ Multiline arguments should have their surrounding brackets in a new line. * **Identifier:** multiline_arguments_brackets -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -78,6 +78,40 @@ SomeType(a: [ ], b: [1, 2]) ``` +```swift +SomeType( + a: 1 +) { print("completion") } +``` + +```swift +SomeType( + a: 1 +) { + print("completion") +} +``` + +```swift +SomeType( + a: .init() { print("completion") } +) +``` + +```swift +SomeType( + a: .init() { + print("completion") + } +) +``` + +```swift +SomeType( + a: 1 +) {} onError: {} +``` + ## Triggering Examples ```swift @@ -93,6 +127,12 @@ foo( param3: "Param3"↓) ``` +```swift +foo(↓param1: "Param1", + param2: "Param2", + param3: "Param3"↓) +``` + ```swift foo(↓bar( x: 5, @@ -114,4 +154,16 @@ SomeOtherType(↓a: [ 1, 2, 3 ], b: "two"↓) +``` + +```swift +SomeOtherType( + a: 1↓) {} +``` + +```swift +SomeOtherType( + a: 1↓) { + print("completion") +} ``` \ No newline at end of file diff --git a/docs/description/multiline_function_chains.md b/docs/description/multiline_function_chains.md index 9d9f24b..6154a02 100755 --- a/docs/description/multiline_function_chains.md +++ b/docs/description/multiline_function_chains.md @@ -3,11 +3,11 @@ Chained function calls should be either on the same line, or one per line. * **Identifier:** multiline_function_chains -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/multiline_literal_brackets.md b/docs/description/multiline_literal_brackets.md index e941e5f..a65caa9 100755 --- a/docs/description/multiline_literal_brackets.md +++ b/docs/description/multiline_literal_brackets.md @@ -3,18 +3,18 @@ Multiline literals should have their surrounding brackets in a new line. * **Identifier:** multiline_literal_brackets -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples ```swift let trio = ["harry", "ronald", "hermione"] -let houseCup = ["gryffinder": 460, "hufflepuff": 370, "ravenclaw": 410, "slytherin": 450] +let houseCup = ["gryffindor": 460, "hufflepuff": 370, "ravenclaw": 410, "slytherin": 450] ``` ```swift @@ -24,7 +24,7 @@ let trio = [ "hermione" ] let houseCup = [ - "gryffinder": 460, + "gryffindor": 460, "hufflepuff": 370, "ravenclaw": 410, "slytherin": 450 @@ -36,7 +36,7 @@ let trio = [ "harry", "ronald", "hermione" ] let houseCup = [ - "gryffinder": 460, "hufflepuff": 370, + "gryffindor": 460, "hufflepuff": 370, "ravenclaw": 410, "slytherin": 450 ] ``` @@ -62,11 +62,18 @@ let trio = [↓"harry", ``` ```swift -let houseCup = [↓"gryffinder": 460, "hufflepuff": 370, +let houseCup = [↓"gryffindor": 460, "hufflepuff": 370, "ravenclaw": 410, "slytherin": 450 ] ``` +```swift +let houseCup = [↓"gryffindor": 460, + "hufflepuff": 370, + "ravenclaw": 410, + "slytherin": 450↓] +``` + ```swift let trio = [ "harry", @@ -76,14 +83,14 @@ let trio = [ ```swift let houseCup = [ - "gryffinder": 460, "hufflepuff": 370, + "gryffindor": 460, "hufflepuff": 370, "ravenclaw": 410, "slytherin": 450↓] ``` ```swift class Hogwarts { let houseCup = [ - "gryffinder": 460, "hufflepuff": 370, + "gryffindor": 460, "hufflepuff": 370, "ravenclaw": 410, "slytherin": 450↓] } ``` diff --git a/docs/description/multiline_parameters.md b/docs/description/multiline_parameters.md index 16530f9..24f4e4c 100755 --- a/docs/description/multiline_parameters.md +++ b/docs/description/multiline_parameters.md @@ -3,11 +3,11 @@ Functions and methods parameters should be either on the same line, or one per line. * **Identifier:** multiline_parameters -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, allowsSingleLine: true ## Non Triggering Examples @@ -324,6 +324,14 @@ class Foo { } ``` +```swift +class Foo { + init(param1: Int, + param2: Bool, + param3: @escaping ((Int) -> Void)? = { _ in }) { } +} +``` + ```swift func foo() { } ``` @@ -507,6 +515,13 @@ class Foo { } ``` +```swift +class Foo { + ↓init(param1: Int, param2: Bool, + param3: @escaping ((Int) -> Void)? = { _ in }) { } +} +``` + ```swift func ↓foo(param1: Int, param2: Bool) { } ``` diff --git a/docs/description/multiline_parameters_brackets.md b/docs/description/multiline_parameters_brackets.md index f6dd1e5..abeda76 100755 --- a/docs/description/multiline_parameters_brackets.md +++ b/docs/description/multiline_parameters_brackets.md @@ -3,11 +3,11 @@ Multiline parameters should have their surrounding brackets in a new line. * **Identifier:** multiline_parameters_brackets -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/multiple_closures_with_trailing_closure.md b/docs/description/multiple_closures_with_trailing_closure.md index e603738..f83d1db 100755 --- a/docs/description/multiple_closures_with_trailing_closure.md +++ b/docs/description/multiple_closures_with_trailing_closure.md @@ -3,11 +3,11 @@ Trailing closure syntax should not be used when passing more than one closure argument. * **Identifier:** multiple_closures_with_trailing_closure -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/nesting.md b/docs/description/nesting.md index 3b8039a..ad37870 100755 --- a/docs/description/nesting.md +++ b/docs/description/nesting.md @@ -3,11 +3,11 @@ Types should be nested at most 1 level deep, and functions should be nested at most 2 levels deep. * **Identifier:** nesting -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** metrics * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** (type_level) w: 1, (function_level) w: 2, (check_nesting_in_closures_and_statements) true, (always_allow_one_type_in_functions) false ## Non Triggering Examples diff --git a/docs/description/nimble_operator.md b/docs/description/nimble_operator.md index b8dfe98..b4994a8 100755 --- a/docs/description/nimble_operator.md +++ b/docs/description/nimble_operator.md @@ -3,11 +3,11 @@ Prefer Nimble operator overloads over free matcher functions. * **Identifier:** nimble_operator -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -54,6 +54,14 @@ expect(10) == 10 expect(success) == true ``` +```swift +expect(value) == nil +``` + +```swift +expect(value) != nil +``` + ```swift expect(object.asyncFunction()).toEventually(equal(1)) @@ -128,6 +136,16 @@ foo.method { ``` +```swift +↓expect(value).to(beNil()) + +``` + +```swift +↓expect(value).toNot(beNil()) + +``` + ```swift expect(10) > 2 ↓expect(10).to(beGreaterThan(2)) diff --git a/docs/description/no_extension_access_modifier.md b/docs/description/no_extension_access_modifier.md index 86bf5bf..a605127 100755 --- a/docs/description/no_extension_access_modifier.md +++ b/docs/description/no_extension_access_modifier.md @@ -3,11 +3,11 @@ Prefer not to use extension access modifiers * **Identifier:** no_extension_access_modifier -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** error ## Non Triggering Examples diff --git a/docs/description/no_fallthrough_only.md b/docs/description/no_fallthrough_only.md index b4329c7..0ca558f 100755 --- a/docs/description/no_fallthrough_only.md +++ b/docs/description/no_fallthrough_only.md @@ -3,11 +3,11 @@ Fallthroughs can only be used if the `case` contains at least one other statement. * **Identifier:** no_fallthrough_only -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/no_grouping_extension.md b/docs/description/no_grouping_extension.md index afb22c0..06273ab 100755 --- a/docs/description/no_grouping_extension.md +++ b/docs/description/no_grouping_extension.md @@ -3,11 +3,11 @@ Extensions shouldn't be used to group code within the same source file. * **Identifier:** no_grouping_extension -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/no_magic_numbers.md b/docs/description/no_magic_numbers.md new file mode 100755 index 0000000..9005451 --- /dev/null +++ b/docs/description/no_magic_numbers.md @@ -0,0 +1,91 @@ +# No Magic Numbers + +Magic numbers should be replaced by named constants. + +* **Identifier:** no_magic_numbers +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +var foo = 123 +``` + +```swift +static let bar: Double = 0.123 +``` + +```swift +let a = b + 1.0 +``` + +```swift +array[0] + array[1] +``` + +```swift +let foo = 1_000.000_01 +``` + +```swift +// array[1337] +``` + +```swift +baz("9999") +``` + +```swift +func foo() { + let x: Int = 2 + let y = 3 + let vector = [x, y, -1] +} +``` + +```swift +class A { + var foo: Double = 132 + static let bar: Double = 0.98 +} +``` + +```swift +@available(iOS 13, *) +func version() { + if #available(iOS 13, OSX 10.10, *) { + return + } +} +``` + +## Triggering Examples + +```swift +foo(↓321) +``` + +```swift +bar(↓1_000.005_01) +``` + +```swift +array[↓42] +``` + +```swift +let box = array[↓12 + ↓14] +``` + +```swift +let a = b + ↓2.0 +``` + +```swift +Color.primary.opacity(isAnimate ? ↓0.1 : ↓1.5) +``` \ No newline at end of file diff --git a/docs/description/no_space_in_method_call.md b/docs/description/no_space_in_method_call.md index 23f82cd..4ccd464 100755 --- a/docs/description/no_space_in_method_call.md +++ b/docs/description/no_space_in_method_call.md @@ -3,11 +3,11 @@ Don't add a space between the method name and the parentheses. * **Identifier:** no_space_in_method_call -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.2.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/notification_center_detachment.md b/docs/description/notification_center_detachment.md index 446bb84..b994997 100755 --- a/docs/description/notification_center_detachment.md +++ b/docs/description/notification_center_detachment.md @@ -3,11 +3,11 @@ An object should only remove itself as an observer in `deinit`. * **Identifier:** notification_center_detachment -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/ns_number_init_as_function_reference.md b/docs/description/ns_number_init_as_function_reference.md new file mode 100755 index 0000000..76386e4 --- /dev/null +++ b/docs/description/ns_number_init_as_function_reference.md @@ -0,0 +1,39 @@ +# NSNumber Init as Function Reference + +Passing `NSNumber.init` or `NSDecimalNumber.init` as a function reference is dangerous as it can cause the wrong initializer to be used, causing crashes. Use `.init(value:)` instead. + +* **Identifier:** ns_number_init_as_function_reference +* **Enabled by default:** Yes +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +[0, 0.2].map(NSNumber.init(value:)) +``` + +```swift +[0, 0.2].map { NSNumber(value: $0) } +``` + +```swift +[0, 0.2].map(NSDecimalNumber.init(value:)) +``` + +```swift +[0, 0.2].map { NSDecimalNumber(value: $0) } +``` + +## Triggering Examples + +```swift +[0, 0.2].map(↓NSNumber.init) +``` + +```swift +[0, 0.2].map(↓NSDecimalNumber.init) +``` \ No newline at end of file diff --git a/docs/description/nslocalizedstring_key.md b/docs/description/nslocalizedstring_key.md index 11c482b..41a8946 100755 --- a/docs/description/nslocalizedstring_key.md +++ b/docs/description/nslocalizedstring_key.md @@ -3,11 +3,11 @@ Static strings should be used as key/comment in NSLocalizedString in order for genstrings to work. * **Identifier:** nslocalizedstring_key -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/nslocalizedstring_require_bundle.md b/docs/description/nslocalizedstring_require_bundle.md index 2fabf63..8845e12 100755 --- a/docs/description/nslocalizedstring_require_bundle.md +++ b/docs/description/nslocalizedstring_require_bundle.md @@ -3,11 +3,11 @@ Calls to NSLocalizedString should specify the bundle which contains the strings file. * **Identifier:** nslocalizedstring_require_bundle -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/nsobject_prefer_isequal.md b/docs/description/nsobject_prefer_isequal.md index 2a106aa..2cd1ea0 100755 --- a/docs/description/nsobject_prefer_isequal.md +++ b/docs/description/nsobject_prefer_isequal.md @@ -3,11 +3,11 @@ NSObject subclasses should implement isEqual instead of ==. * **Identifier:** nsobject_prefer_isequal -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/number_separator.md b/docs/description/number_separator.md index 80ebc5c..4fae190 100755 --- a/docs/description/number_separator.md +++ b/docs/description/number_separator.md @@ -3,12 +3,12 @@ Underscores should be used as thousand separator in large decimal numbers. * **Identifier:** number_separator -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning, minimum_length: 0 +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning, minimum_length: 0, minimum_fraction_length: none ## Non Triggering Examples @@ -25,11 +25,11 @@ let foo = -1_000_000 ``` ```swift -let foo = -1.000_1 +let foo = -1.0001 ``` ```swift -let foo = -1_000_000.000_000_1 +let foo = -1_000_000.0000001 ``` ```swift @@ -57,7 +57,7 @@ let octal = -0o21_1 ``` ```swift -let exp = -1_000_000.000_000e2 +let exp = -1_000_000.000000e2 ``` ```swift @@ -68,6 +68,10 @@ let foo: Double = -(200) let foo: Double = -(200 / 447.214) ``` +```swift +let foo = -6.2832e-6 +``` + ```swift let foo = +100 ``` @@ -81,11 +85,11 @@ let foo = +1_000_000 ``` ```swift -let foo = +1.000_1 +let foo = +1.0001 ``` ```swift -let foo = +1_000_000.000_000_1 +let foo = +1_000_000.0000001 ``` ```swift @@ -113,7 +117,7 @@ let octal = +0o21_1 ``` ```swift -let exp = +1_000_000.000_000e2 +let exp = +1_000_000.000000e2 ``` ```swift @@ -124,6 +128,10 @@ let foo: Double = +(200) let foo: Double = +(200 / 447.214) ``` +```swift +let foo = +6.2832e-6 +``` + ```swift let foo = 100 ``` @@ -137,11 +145,11 @@ let foo = 1_000_000 ``` ```swift -let foo = 1.000_1 +let foo = 1.0001 ``` ```swift -let foo = 1_000_000.000_000_1 +let foo = 1_000_000.0000001 ``` ```swift @@ -169,7 +177,7 @@ let octal = 0o21_1 ``` ```swift -let exp = 1_000_000.000_000e2 +let exp = 1_000_000.000000e2 ``` ```swift @@ -180,38 +188,46 @@ let foo: Double = (200) let foo: Double = (200 / 447.214) ``` +```swift +let foo = 6.2832e-6 +``` + ## Triggering Examples ```swift -let foo = ↓-10_0 +let foo = -↓10_0 ``` ```swift -let foo = ↓-1000 +let foo = -↓1000 ``` ```swift -let foo = ↓-1000e2 +let foo = -↓1000e2 ``` ```swift -let foo = ↓-1000E2 +let foo = -↓1000E2 ``` ```swift -let foo = ↓-1__000 +let foo = -↓1__000 ``` ```swift -let foo = ↓-1.0001 +let foo = -↓1.0001 ``` ```swift -let foo = ↓-1_000_000.000000_1 +let foo = -↓1_000_000.000000_1 ``` ```swift -let foo = ↓-1000000.000000_1 +let foo = -↓1000000.000000_1 +``` + +```swift +let foo = -↓6.2832e-6 ``` ```swift @@ -246,6 +262,10 @@ let foo = +↓1_000_000.000000_1 let foo = +↓1000000.000000_1 ``` +```swift +let foo = +↓6.2832e-6 +``` + ```swift let foo = ↓10_0 ``` @@ -279,15 +299,19 @@ let foo = ↓1000000.000000_1 ``` ```swift -let foo: Double = ↓-(100000) +let foo = ↓6.2832e-6 +``` + +```swift +let foo: Double = -(↓100000) ``` ```swift -let foo: Double = ↓-(10.000000_1) +let foo: Double = -(↓10.000000_1) ``` ```swift -let foo: Double = ↓-(123456 / ↓447.214214) +let foo: Double = -(↓123456 / ↓447.214214) ``` ```swift diff --git a/docs/description/object_literal.md b/docs/description/object_literal.md index 88a248b..494d0b7 100755 --- a/docs/description/object_literal.md +++ b/docs/description/object_literal.md @@ -3,11 +3,11 @@ Prefer object literals over image and color inits. * **Identifier:** object_literal -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, image_literal: true, color_literal: true ## Non Triggering Examples diff --git a/docs/description/opening_brace.md b/docs/description/opening_brace.md index cb9d1e4..91c92f0 100755 --- a/docs/description/opening_brace.md +++ b/docs/description/opening_brace.md @@ -3,11 +3,11 @@ Opening braces should be preceded by a single space and on the same line as the declaration. * **Identifier:** opening_brace -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, allowMultilineFunc: false ## Non Triggering Examples diff --git a/docs/description/operator_usage_whitespace.md b/docs/description/operator_usage_whitespace.md index 6b76f81..a730ed8 100755 --- a/docs/description/operator_usage_whitespace.md +++ b/docs/description/operator_usage_whitespace.md @@ -3,12 +3,12 @@ Operators should be surrounded by a single whitespace when they are being used. * **Identifier:** operator_usage_whitespace -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning, lines_look_around: 2, skip_aligned_constants: true +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning, lines_look_around: 2, skip_aligned_constants: true, allowed_no_space_operators: ["...", "..<"] ## Non Triggering Examples @@ -121,6 +121,62 @@ let foo = SignalProducer, Error>([ self.signal, next ]).fla } ``` +```swift +let something = Something() +``` + +```swift +return path.flatMap { path in + return compileCommands[path] ?? + compileCommands[path.path(relativeTo: FileManager.default.currentDirectoryPath)] +} +``` + +```swift +internal static func == (lhs: Vertix, rhs: Vertix) -> Bool { + return lhs.filePath == rhs.filePath + && lhs.originalRemoteString == rhs.originalRemoteString + && lhs.rootDirectory == rhs.rootDirectory +} +``` + +```swift +internal static func == (lhs: Vertix, rhs: Vertix) -> Bool { + return lhs.filePath == rhs.filePath && + lhs.originalRemoteString == rhs.originalRemoteString && + lhs.rootDirectory == rhs.rootDirectory +} +``` + +```swift +private static let pattern = + "\\S\(mainPatternGroups)" + // Regexp will match if expression not begin with comma + "|" + // or + "\(mainPatternGroups)" // Regexp will match if expression begins with comma +``` + +```swift +private static let pattern = + "\\S\(mainPatternGroups)" + // Regexp will match if expression not begin with comma + "|" + // or + "\(mainPatternGroups)" // Regexp will match if expression begins with comma +``` + +```swift +typealias Foo = Bar +``` + +```swift +protocol A { + associatedtype B = C +} +``` + +```swift +tabbedViewController.title = nil +``` + ## Triggering Examples ```swift @@ -168,11 +224,6 @@ let foo = bar↓ ?? 0 ``` -```swift -let foo = bar↓??0 - -``` - ```swift let foo = bar↓ != 0 @@ -233,4 +284,26 @@ let foo↓ = "1" case one↓ = 1 case two↓ = 1 } +``` + +```swift +typealias Foo↓ = Bar +``` + +```swift +protocol A { + associatedtype B↓ = C +} +``` + +```swift +tabbedViewController.title↓ = nil +``` + +```swift +let foo = bar ? 0↓:1 +``` + +```swift +let foo = bar↓ ? 0 : 1 ``` \ No newline at end of file diff --git a/docs/description/operator_whitespace.md b/docs/description/operator_whitespace.md index 70c1cd2..594908e 100755 --- a/docs/description/operator_whitespace.md +++ b/docs/description/operator_whitespace.md @@ -3,11 +3,11 @@ Operators should be surrounded by a single whitespace when defining them. * **Identifier:** operator_whitespace -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/optional_enum_case_matching.md b/docs/description/optional_enum_case_matching.md index 87658af..6a73f13 100755 --- a/docs/description/optional_enum_case_matching.md +++ b/docs/description/optional_enum_case_matching.md @@ -3,7 +3,7 @@ Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. * **Identifier:** optional_enum_case_matching -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No diff --git a/docs/description/orphaned_doc_comment.md b/docs/description/orphaned_doc_comment.md index 674d1e9..c225ca5 100755 --- a/docs/description/orphaned_doc_comment.md +++ b/docs/description/orphaned_doc_comment.md @@ -3,11 +3,11 @@ A doc comment should be attached to a declaration. * **Identifier:** orphaned_doc_comment -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.1.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/overridden_super_call.md b/docs/description/overridden_super_call.md index 2aa4702..041e82b 100755 --- a/docs/description/overridden_super_call.md +++ b/docs/description/overridden_super_call.md @@ -3,11 +3,11 @@ Some overridden methods should always call super * **Identifier:** overridden_super_call -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, excluded: [], included: ["*"] ## Non Triggering Examples diff --git a/docs/description/override_in_extension.md b/docs/description/override_in_extension.md index 472e3d8..21b037e 100755 --- a/docs/description/override_in_extension.md +++ b/docs/description/override_in_extension.md @@ -3,11 +3,11 @@ Extensions shouldn't override declarations. * **Identifier:** override_in_extension -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/pattern_matching_keywords.md b/docs/description/pattern_matching_keywords.md index 2656a5e..e83aee1 100755 --- a/docs/description/pattern_matching_keywords.md +++ b/docs/description/pattern_matching_keywords.md @@ -3,11 +3,11 @@ Combine multiple pattern matching bindings by moving keywords out of tuples. * **Identifier:** pattern_matching_keywords -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -86,6 +86,18 @@ switch foo { } ``` +```swift +switch foo { + case (↓let x, ↓let y, .foo): break +} +``` + +```swift +switch foo { + case (↓let x, ↓let y, _): break +} +``` + ```swift switch foo { case .foo(↓let x, ↓let y): break diff --git a/docs/description/prefer_nimble.md b/docs/description/prefer_nimble.md index 3b66fd5..41829bd 100755 --- a/docs/description/prefer_nimble.md +++ b/docs/description/prefer_nimble.md @@ -3,11 +3,11 @@ Prefer Nimble matchers over XCTAssert functions. * **Identifier:** prefer_nimble -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/prefer_self_in_static_references.md b/docs/description/prefer_self_in_static_references.md new file mode 100755 index 0000000..dd5db56 --- /dev/null +++ b/docs/description/prefer_self_in_static_references.md @@ -0,0 +1,86 @@ +# Prefer Self in Static References + +Use `Self` to refer to the surrounding type name. + +* **Identifier:** prefer_self_in_static_references +* **Enabled by default:** No +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift + class C { + static let primes = [2, 3, 5, 7] + func isPrime(i: Int) -> Bool { Self.primes.contains(i) } +``` + +```swift + struct T { + static let i = 0 + } + struct S { + static let i = 0 + } + extension T { + static let j = S.i + T.i + static let k = { T.j }() + } +``` + +```swift + class `Self` { + static let i = 0 + func f() -> Int { Self.i } + } +``` + +## Triggering Examples + +```swift + class C { + struct S { + static let i = 2 + let h = ↓S.i + } + static let i = 1 + let h = C.i + var j: Int { ↓C.i } + func f() -> Int { ↓C.i + h } + } +``` + +```swift + struct S { + let j: Int + static let i = 1 + static func f() -> Int { ↓S.i } + func g() -> Any { ↓S.self } + func h() -> S { ↓S(j: 2) } + func i() -> KeyPath { \↓S.j } + func j(@Wrap(-↓S.i, ↓S.i) n: Int = ↓S.i) {} + } +``` + +```swift + struct S { + struct T { + static let i = 3 + } + struct R { + static let j = S.T.i + } + static let h = ↓S.T.i + ↓S.R.j + } +``` + +```swift + enum E { + case A + static func f() -> E { ↓E.A } + static func g() -> E { ↓E.f() } + } +``` \ No newline at end of file diff --git a/docs/description/prefer_self_type_over_type_of_self.md b/docs/description/prefer_self_type_over_type_of_self.md index 9bfa94d..d679609 100755 --- a/docs/description/prefer_self_type_over_type_of_self.md +++ b/docs/description/prefer_self_type_over_type_of_self.md @@ -3,7 +3,7 @@ Prefer `Self` over `type(of: self)` when accessing properties or calling methods. * **Identifier:** prefer_self_type_over_type_of_self -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No diff --git a/docs/description/prefer_zero_over_explicit_init.md b/docs/description/prefer_zero_over_explicit_init.md index ef46a31..56feb85 100755 --- a/docs/description/prefer_zero_over_explicit_init.md +++ b/docs/description/prefer_zero_over_explicit_init.md @@ -3,11 +3,11 @@ Prefer `.zero` over explicit init with zero parameters (e.g. `CGPoint(x: 0, y: 0)`) * **Identifier:** prefer_zero_over_explicit_init -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -28,6 +28,10 @@ CGSize(width: 2, height: 4) CGVector(dx: -5, dy: 0) ``` +```swift +UIEdgeInsets(top: 0, left: 1, bottom: 0, right: 1) +``` + ## Triggering Examples ```swift @@ -52,4 +56,8 @@ CGVector(dx: -5, dy: 0) ```swift ↓CGVector(dx: 0, dy: 0) +``` + +```swift +↓UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) ``` \ No newline at end of file diff --git a/docs/description/prefixed_toplevel_constant.md b/docs/description/prefixed_toplevel_constant.md index 70b5bc0..ed9ba21 100755 --- a/docs/description/prefixed_toplevel_constant.md +++ b/docs/description/prefixed_toplevel_constant.md @@ -3,11 +3,11 @@ Top-level constants should be prefixed by `k`. * **Identifier:** prefixed_toplevel_constant -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, only_private: false ## Non Triggering Examples @@ -79,6 +79,30 @@ let kFoo = { }() ``` +```swift +var foo: String { + let bar = "" + return bar +} +``` + +```swift +if condition() { + let result = somethingElse() + print(result) + exit() +} +``` + +```swift +[1, 2, 3, 1000, 4000].forEach { number in + let isSmall = number < 10 + if isSmall { + print("\(number) is a small number") + } +} +``` + ## Triggering Examples ```swift @@ -101,10 +125,6 @@ let ↓Foo = true let ↓foo = 2, ↓bar = true ``` -```swift -var foo = true, let ↓Foo = true -``` - ```swift let ↓foo = true diff --git a/docs/description/private_action.md b/docs/description/private_action.md index 5526406..032453c 100755 --- a/docs/description/private_action.md +++ b/docs/description/private_action.md @@ -3,11 +3,11 @@ IBActions should be private. * **Identifier:** private_action -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/private_outlet.md b/docs/description/private_outlet.md index 617373a..5a046e0 100755 --- a/docs/description/private_outlet.md +++ b/docs/description/private_outlet.md @@ -3,11 +3,11 @@ IBOutlets should be private to avoid leaking UIKit to higher layers. * **Identifier:** private_outlet -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, allow_private_set: false ## Non Triggering Examples @@ -47,6 +47,48 @@ class Foo { ``` +```swift +class Foo { + @IBOutlet fileprivate weak var label: UILabel? +} + +``` + +```swift +class Foo { + @IBOutlet private(set) var label: UILabel? +} + +``` + +```swift +class Foo { + @IBOutlet private(set) var label: UILabel! +} + +``` + +```swift +class Foo { + @IBOutlet weak private(set) var label: UILabel? +} + +``` + +```swift +class Foo { + @IBOutlet private(set) weak var label: UILabel? +} + +``` + +```swift +class Foo { + @IBOutlet fileprivate(set) weak var label: UILabel? +} + +``` + ## Triggering Examples ```swift @@ -61,4 +103,18 @@ class Foo { @IBOutlet ↓var label: UILabel! } +``` + +```swift +class Foo { + @IBOutlet private(set) ↓var label: UILabel? +} + +``` + +```swift +class Foo { + @IBOutlet fileprivate(set) ↓var label: UILabel? +} + ``` \ No newline at end of file diff --git a/docs/description/private_over_fileprivate.md b/docs/description/private_over_fileprivate.md index 7f51cfc..038f785 100755 --- a/docs/description/private_over_fileprivate.md +++ b/docs/description/private_over_fileprivate.md @@ -3,11 +3,11 @@ Prefer `private` over `fileprivate` declarations. * **Identifier:** private_over_fileprivate -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, validate_extensions: false ## Non Triggering Examples diff --git a/docs/description/private_subject.md b/docs/description/private_subject.md index 163f2af..64b70ad 100755 --- a/docs/description/private_subject.md +++ b/docs/description/private_subject.md @@ -3,11 +3,11 @@ Combine Subject should be private. * **Identifier:** private_subject -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -173,7 +173,7 @@ final class Foobar { ```swift final class Foobar { - let goodSubject: CurrentValueSubject = .ini("toto") + let goodSubject: CurrentValueSubject = .init("toto") } ``` diff --git a/docs/description/private_unit_test.md b/docs/description/private_unit_test.md index b37b5aa..b54f8d2 100755 --- a/docs/description/private_unit_test.md +++ b/docs/description/private_unit_test.md @@ -3,17 +3,17 @@ Unit tests marked private are silently skipped. * **Identifier:** private_unit_test -* **Enabled by default:** Enabled -* **Supports autocorrection:** No +* **Enabled by default:** Yes +* **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning: XCTestCase ## Non Triggering Examples ```swift -"class FooTest: XCTestCase { +class FooTest: XCTestCase { func test1() {} internal func test2() {} public func test3() {} @@ -39,8 +39,8 @@ public class FooTest: XCTestCase { ```swift @objc private class FooTest: XCTestCase { @objc private func test1() {} - internal func test2() {} - public func test3() {} + internal func test2() {} + public func test3() {} } ``` @@ -62,7 +62,10 @@ private class Foo { ```swift public class FooTest: XCTestCase { - func test1(param: Int) {} + private func test1(param: Int) {} + private func test2() -> String { "" } + private func atest() {} + private static func test3() {} } ``` @@ -71,35 +74,35 @@ public class FooTest: XCTestCase { ```swift private ↓class FooTest: XCTestCase { func test1() {} - internal func test2() {} - public func test3() {} - private func test4() {} + internal func test2() {} + public func test3() {} + private func test4() {} } ``` ```swift class FooTest: XCTestCase { func test1() {} - internal func test2() {} - public func test3() {} - private ↓func test4() {} + internal func test2() {} + public func test3() {} + private ↓func test4() {} } ``` ```swift internal class FooTest: XCTestCase { func test1() {} - internal func test2() {} - public func test3() {} - private ↓func test4() {} + internal func test2() {} + public func test3() {} + private ↓func test4() {} } ``` ```swift public class FooTest: XCTestCase { func test1() {} - internal func test2() {} - public func test3() {} - private ↓func test4() {} + internal func test2() {} + public func test3() {} + private ↓func test4() {} } ``` \ No newline at end of file diff --git a/docs/description/prohibited_interface_builder.md b/docs/description/prohibited_interface_builder.md index 6ba23f5..c5cfc8d 100755 --- a/docs/description/prohibited_interface_builder.md +++ b/docs/description/prohibited_interface_builder.md @@ -3,11 +3,11 @@ Creating views using Interface Builder should be avoided. * **Identifier:** prohibited_interface_builder -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/prohibited_super_call.md b/docs/description/prohibited_super_call.md index f23d814..4d75527 100755 --- a/docs/description/prohibited_super_call.md +++ b/docs/description/prohibited_super_call.md @@ -3,11 +3,11 @@ Some methods should not call super * **Identifier:** prohibited_super_call -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, excluded: [[]], included: [["*"]] ## Non Triggering Examples diff --git a/docs/description/protocol_property_accessors_order.md b/docs/description/protocol_property_accessors_order.md index 560940c..13f742b 100755 --- a/docs/description/protocol_property_accessors_order.md +++ b/docs/description/protocol_property_accessors_order.md @@ -3,11 +3,11 @@ When declaring properties in protocols, the order of accessors should be `get set`. * **Identifier:** protocol_property_accessors_order -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/quick_discouraged_call.md b/docs/description/quick_discouraged_call.md index dd87de8..9d5e775 100755 --- a/docs/description/quick_discouraged_call.md +++ b/docs/description/quick_discouraged_call.md @@ -3,11 +3,11 @@ Discouraged call inside 'describe' and/or 'context' block. * **Identifier:** quick_discouraged_call -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -310,4 +310,17 @@ class TotoTests: QuickSpec { } } } +``` + +```swift +class TotoTests: QuickSpecSubclass { + override func spec() { + xcontext("foo") { + let foo = ↓Foo() + } + fcontext("foo") { + let foo = ↓Foo() + } + } +} ``` \ No newline at end of file diff --git a/docs/description/quick_discouraged_focused_test.md b/docs/description/quick_discouraged_focused_test.md index 2a0bc93..3942056 100755 --- a/docs/description/quick_discouraged_focused_test.md +++ b/docs/description/quick_discouraged_focused_test.md @@ -3,11 +3,11 @@ Discouraged focused test. Other tests won't run while this one is focused. * **Identifier:** quick_discouraged_focused_test -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -91,4 +91,12 @@ class TotoTests: QuickSpec { ↓fitBehavesLike("foo") } } +``` + +```swift +class TotoTests: QuickSpecSubclass { + override func spec() { + ↓fitBehavesLike("foo") + } +} ``` \ No newline at end of file diff --git a/docs/description/quick_discouraged_pending_test.md b/docs/description/quick_discouraged_pending_test.md index c7788be..10da0b4 100755 --- a/docs/description/quick_discouraged_pending_test.md +++ b/docs/description/quick_discouraged_pending_test.md @@ -3,11 +3,11 @@ Discouraged pending test. This test won't run while it's marked as pending. * **Identifier:** quick_discouraged_pending_test -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -99,4 +99,12 @@ class TotoTests: QuickSpec { ↓xitBehavesLike("foo") } } +``` + +```swift +class TotoTests: QuickSpecSubclass { + override func spec() { + ↓xitBehavesLike("foo") + } +} ``` \ No newline at end of file diff --git a/docs/description/raw_value_for_camel_cased_codable_enum.md b/docs/description/raw_value_for_camel_cased_codable_enum.md index e3fb554..15776c4 100755 --- a/docs/description/raw_value_for_camel_cased_codable_enum.md +++ b/docs/description/raw_value_for_camel_cased_codable_enum.md @@ -3,11 +3,11 @@ Camel cased cases of Codable String enums should have raw value. * **Identifier:** raw_value_for_camel_cased_codable_enum -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/reduce_boolean.md b/docs/description/reduce_boolean.md index 298c3a1..9fae3bf 100755 --- a/docs/description/reduce_boolean.md +++ b/docs/description/reduce_boolean.md @@ -3,11 +3,11 @@ Prefer using `.allSatisfy()` or `.contains()` over `reduce(true)` or `reduce(false)` * **Identifier:** reduce_boolean -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.2.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/reduce_into.md b/docs/description/reduce_into.md index 10cfac8..c705e5d 100755 --- a/docs/description/reduce_into.md +++ b/docs/description/reduce_into.md @@ -3,11 +3,11 @@ Prefer `reduce(into:_:)` over `reduce(_:_:)` for copy-on-write types * **Identifier:** reduce_into -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -71,6 +71,14 @@ values.↓reduce(Array()) { result, value in } ``` +```swift +[1, 2, 3].↓reduce(Set()) { acc, value in + var result = acc + result.insert(value) + return result +} +``` + ```swift let rows = violations.enumerated().↓reduce("") { rows, indexAndViolation in return rows + generateSingleRow(for: indexAndViolation.1, at: indexAndViolation.0 + 1) @@ -103,4 +111,14 @@ let bar = values.↓reduce(Dictionary.init()) { result, value in let bar = values.↓reduce([Int](repeating: 0, count: 10)) { result, value in return result + [value] } +``` + +```swift +extension Data { + var hexString: String { + return ↓reduce("") { (output, byte) -> String in + output + String(format: "%02x", byte) + } + } +} ``` \ No newline at end of file diff --git a/docs/description/redundant_discardable_let.md b/docs/description/redundant_discardable_let.md index 2b0212c..c0d4591 100755 --- a/docs/description/redundant_discardable_let.md +++ b/docs/description/redundant_discardable_let.md @@ -3,11 +3,11 @@ Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function. * **Identifier:** redundant_discardable_let -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -36,6 +36,10 @@ while let _ = SplashStyle(rawValue: maxValue) { maxValue += 1 } ``` +```swift +async let _ = await foo() +``` + ## Triggering Examples ```swift diff --git a/docs/description/redundant_nil_coalescing.md b/docs/description/redundant_nil_coalescing.md index 9b18ec4..e3b45be 100755 --- a/docs/description/redundant_nil_coalescing.md +++ b/docs/description/redundant_nil_coalescing.md @@ -3,11 +3,11 @@ nil coalescing operator is only evaluated if the lhs is nil, coalescing operator with nil as rhs is redundant * **Identifier:** redundant_nil_coalescing -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -20,11 +20,6 @@ var myVar: Int?; myVar ?? 0 ## Triggering Examples ```swift -var myVar: Int? = nil; myVar↓ ?? nil - -``` - -```swift -var myVar: Int? = nil; myVar↓??nil +var myVar: Int? = nil; myVar ↓?? nil ``` \ No newline at end of file diff --git a/docs/description/redundant_objc_attribute.md b/docs/description/redundant_objc_attribute.md index 29d173b..ebaa138 100755 --- a/docs/description/redundant_objc_attribute.md +++ b/docs/description/redundant_objc_attribute.md @@ -3,11 +3,11 @@ Objective-C attribute (@objc) is redundant in declaration. * **Identifier:** redundant_objc_attribute -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.1.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -114,6 +114,13 @@ class Foo { } ``` +```swift +extension BlockEditorSettings { + @objc(addElementsObject:) + @NSManaged public func addToElements(_ value: BlockEditorSettingElement) +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/redundant_optional_initialization.md b/docs/description/redundant_optional_initialization.md index 1eac9bd..0d004c6 100755 --- a/docs/description/redundant_optional_initialization.md +++ b/docs/description/redundant_optional_initialization.md @@ -3,11 +3,11 @@ Initializing an optional variable with nil is redundant. * **Identifier:** redundant_optional_initialization -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -99,6 +99,12 @@ var myVar: Optional↓=nil ) ``` +```swift +var myVar: String?↓ = nil { + didSet { print("didSet") } +} +``` + ```swift func funcName() { var myVar: String?↓ = nil diff --git a/docs/description/redundant_set_access_control.md b/docs/description/redundant_set_access_control.md index 1109174..a0b353f 100755 --- a/docs/description/redundant_set_access_control.md +++ b/docs/description/redundant_set_access_control.md @@ -3,11 +3,11 @@ Property setter access level shouldn't be explicit if it's the same as the variable access level. * **Identifier:** redundant_set_access_control -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.1.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -34,6 +34,12 @@ private final class A { } ``` +```swift +extension Color { + public internal(set) static var someColor = Color.anotherColor +} +``` + ## Triggering Examples ```swift @@ -64,6 +70,12 @@ class A { } ``` +```swift +internal class A { + ↓internal(set) var value: Int +} +``` + ```swift fileprivate class A { ↓fileprivate(set) var value: Int diff --git a/docs/description/redundant_string_enum_value.md b/docs/description/redundant_string_enum_value.md index 6a080c2..a537c96 100755 --- a/docs/description/redundant_string_enum_value.md +++ b/docs/description/redundant_string_enum_value.md @@ -3,11 +3,11 @@ String enum values can be omitted when they are equal to the enumcase name. * **Identifier:** redundant_string_enum_value -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/redundant_type_annotation.md b/docs/description/redundant_type_annotation.md index 92ee155..dd150e4 100755 --- a/docs/description/redundant_type_annotation.md +++ b/docs/description/redundant_type_annotation.md @@ -3,11 +3,11 @@ Variables should not have redundant type annotation * **Identifier:** redundant_type_annotation -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/redundant_void_return.md b/docs/description/redundant_void_return.md index e2eb652..cf87639 100755 --- a/docs/description/redundant_void_return.md +++ b/docs/description/redundant_void_return.md @@ -3,11 +3,11 @@ Returning Void in a function declaration is redundant. * **Identifier:** redundant_void_return -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/required_deinit.md b/docs/description/required_deinit.md index 7b7bc67..4332b68 100755 --- a/docs/description/required_deinit.md +++ b/docs/description/required_deinit.md @@ -3,11 +3,11 @@ Classes should have an explicit deinit method. * **Identifier:** required_deinit -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/required_enum_case.md b/docs/description/required_enum_case.md index 5bed980..f57611c 100755 --- a/docs/description/required_enum_case.md +++ b/docs/description/required_enum_case.md @@ -3,11 +3,11 @@ Enums conforming to a specified protocol must implement a specific case(s). * **Identifier:** required_enum_case -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** No protocols configured. In config add 'required_enum_case' to 'opt_in_rules' and config using : 'required_enum_case: @@ -49,26 +49,26 @@ enum MyNetworkResponse: String, NetworkResponsable { ## Triggering Examples ```swift -enum MyNetworkResponse: String, NetworkResponsable { +↓enum MyNetworkResponse: String, NetworkResponsable { case success, error } ``` ```swift -enum MyNetworkResponse: String, NetworkResponsable { +↓enum MyNetworkResponse: String, NetworkResponsable { case success, error } ``` ```swift -enum MyNetworkResponse: String, NetworkResponsable { +↓enum MyNetworkResponse: String, NetworkResponsable { case success case error } ``` ```swift -enum MyNetworkResponse: String, NetworkResponsable { +↓enum MyNetworkResponse: String, NetworkResponsable { case success case error } diff --git a/docs/description/return_arrow_whitespace.md b/docs/description/return_arrow_whitespace.md index a862e5e..d24687c 100755 --- a/docs/description/return_arrow_whitespace.md +++ b/docs/description/return_arrow_whitespace.md @@ -3,11 +3,11 @@ Return arrow and return type should be separated by a single space or on a separate line. * **Identifier:** return_arrow_whitespace -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -44,6 +44,17 @@ func abc() ``` +```swift +func reallyLongFunctionMethods(withParam1: Int, param2: String, param3: Bool) where T: AGenericConstraint + -> Int { + return 1 +} +``` + +```swift +typealias SuccessBlock = ((Data) -> Void) +``` + ## Triggering Examples ```swift @@ -66,6 +77,11 @@ func abc()↓-> Int {} ``` +```swift +func abc()↓-> Int {} + +``` + ```swift func abc()↓ ->Int {} @@ -84,4 +100,32 @@ var abc = {(param: Int)↓ ->Bool in } ```swift var abc = {(param: Int)↓->Bool in } +``` + +```swift +typealias SuccessBlock = ((Data)↓->Void) +``` + +```swift +func abc() + ↓-> Int {} + +``` + +```swift +func abc() + ↓-> Int {} + +``` + +```swift +func abc()↓ -> + Int {} + +``` + +```swift +func abc()↓ -> +Int {} + ``` \ No newline at end of file diff --git a/docs/description/return_value_from_void_function.md b/docs/description/return_value_from_void_function.md new file mode 100755 index 0000000..40a027c --- /dev/null +++ b/docs/description/return_value_from_void_function.md @@ -0,0 +1,275 @@ +# Return Value from Void Function + +Returning values from Void functions should be avoided. + +* **Identifier:** return_value_from_void_function +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +func foo() { + return +} +``` + +```swift +func foo() { + return /* a comment */ +} +``` + +```swift +func foo() -> Int { + return 1 +} +``` + +```swift +func foo() -> Void { + if condition { + return + } + bar() +} +``` + +```swift +func foo() { + return; + bar() +} +``` + +```swift +func test() {} +``` + +```swift +init?() { + guard condition else { + return nil + } +} +``` + +```swift +init?(arg: String?) { + guard arg != nil else { + return nil + } +} +``` + +```swift +func test() { + guard condition else { + return + } +} +``` + +```swift +func test() -> Result { + func other() {} + func otherVoid() -> Void {} +} +``` + +```swift +func test() -> Int? { + return nil +} +``` + +```swift +func test() { + if bar { + print("") + return + } + let foo = [1, 2, 3].filter { return true } + return +} +``` + +```swift +func test() { + guard foo else { + bar() + return + } +} +``` + +```swift +func spec() { + var foo: Int { + return 0 + } +``` + +## Triggering Examples + +```swift +func foo() { + ↓return bar() +} +``` + +```swift +func foo() { + ↓return self.bar() +} +``` + +```swift +func foo() -> Void { + ↓return bar() +} +``` + +```swift +func foo() -> Void { + ↓return /* comment */ bar() +} +``` + +```swift +func foo() { + ↓return + self.bar() +} +``` + +```swift +func foo() { + variable += 1 + ↓return + variable += 1 +} +``` + +```swift +func initThing() { + guard foo else { + ↓return print("") + } +} +``` + +```swift +// Leading comment +func test() { + guard condition else { + ↓return assertionfailure("") + } +} +``` + +```swift +func test() -> Result { + func other() { + guard false else { + ↓return assertionfailure("") + } + } + func otherVoid() -> Void {} +} +``` + +```swift +func test() { + guard conditionIsTrue else { + sideEffects() + return // comment + } + guard otherCondition else { + ↓return assertionfailure("") + } + differentSideEffect() +} +``` + +```swift +func test() { + guard otherCondition else { + ↓return assertionfailure(""); // comment + } + differentSideEffect() +} +``` + +```swift +func test() { + if x { + ↓return foo() + } + bar() +} +``` + +```swift +func test() { + switch x { + case .a: + ↓return foo() // return to skip baz() + case .b: + bar() + } + baz() +} +``` + +```swift +func test() { + if check { + if otherCheck { + ↓return foo() + } + } + bar() +} +``` + +```swift +func test() { + ↓return foo() +} +``` + +```swift +func test() { + ↓return foo({ + return bar() + }) +} +``` + +```swift +func test() { + guard x else { + ↓return foo() + } + bar() +} +``` + +```swift +func test() { + let closure: () -> () = { + return assert() + } + if check { + if otherCheck { + return // comments are fine + } + } + ↓return foo() +} +``` \ No newline at end of file diff --git a/docs/description/self_binding.md b/docs/description/self_binding.md new file mode 100755 index 0000000..352135d --- /dev/null +++ b/docs/description/self_binding.md @@ -0,0 +1,71 @@ +# Self Binding + +Re-bind `self` to a consistent identifier name. + +* **Identifier:** self_binding +* **Enabled by default:** No +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning, bindIdentifier: self + +## Non Triggering Examples + +```swift +if let self = self { return } +``` + +```swift +guard let self = self else else { return } +``` + +```swift +if let this = this { return } +``` + +```swift +guard let this = this else else { return } +``` + +```swift +if let this = self { return } +``` + +```swift +guard let this = self else else { return } +``` + +## Triggering Examples + +```swift +if let ↓`self` = self { return } +``` + +```swift +guard let ↓`self` = self else else { return } +``` + +```swift +if let ↓this = self { return } +``` + +```swift +guard let ↓this = self else else { return } +``` + +```swift +if let ↓self = self { return } +``` + +```swift +guard let ↓self = self else { return } +``` + +```swift +if let ↓self { return } +``` + +```swift +guard let ↓self else { return } +``` \ No newline at end of file diff --git a/docs/description/self_in_property_initialization.md b/docs/description/self_in_property_initialization.md new file mode 100755 index 0000000..306a6c1 --- /dev/null +++ b/docs/description/self_in_property_initialization.md @@ -0,0 +1,75 @@ +# Self in Property Initialization + +`self` refers to the unapplied `NSObject.self()` method, which is likely not expected. Make the variable `lazy` to be able to refer to the current instance or use `ClassName.self`. + +* **Identifier:** self_in_property_initialization +* **Enabled by default:** Yes +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +class View: UIView { + let button: UIButton = { + return UIButton() + }() +} +``` + +```swift +class View: UIView { + lazy var button: UIButton = { + let button = UIButton() + button.addTarget(self, action: #selector(didTapButton), for: .touchUpInside) + return button + }() +} +``` + +```swift +class View: UIView { + var button: UIButton = { + let button = UIButton() + button.addTarget(otherObject, action: #selector(didTapButton), for: .touchUpInside) + return button + }() +} +``` + +```swift +class View: UIView { + private let collectionView: UICollectionView = { + let layout = UICollectionViewFlowLayout() + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) + collectionView.registerReusable(Cell.self) + + return collectionView + }() +} +``` + +## Triggering Examples + +```swift +class View: UIView { + ↓var button: UIButton = { + let button = UIButton() + button.addTarget(self, action: #selector(didTapButton), for: .touchUpInside) + return button + }() +} +``` + +```swift +class View: UIView { + ↓let button: UIButton = { + let button = UIButton() + button.addTarget(self, action: #selector(didTapButton), for: .touchUpInside) + return button + }() +} +``` \ No newline at end of file diff --git a/docs/description/shorthand_operator.md b/docs/description/shorthand_operator.md index a1bfd1b..6b3a834 100755 --- a/docs/description/shorthand_operator.md +++ b/docs/description/shorthand_operator.md @@ -3,11 +3,11 @@ Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning. * **Identifier:** shorthand_operator -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** error ## Non Triggering Examples @@ -256,9 +256,9 @@ seconds = seconds * 60 + value ``` ```swift -n = n + i / outputLength +↓n = n + i / outputLength ``` ```swift -n = n - i / outputLength +↓n = n - i / outputLength ``` \ No newline at end of file diff --git a/docs/description/shorthand_optional_binding.md b/docs/description/shorthand_optional_binding.md new file mode 100755 index 0000000..587fe78 --- /dev/null +++ b/docs/description/shorthand_optional_binding.md @@ -0,0 +1,45 @@ +# Shorthand Optional Binding + +Use shorthand syntax for optional binding + +* **Identifier:** shorthand_optional_binding +* **Enabled by default:** No +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.7.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift + if let i {} + if let i = a {} + guard let i = f() else {} + if var i = i() {} + if let i = i as? Foo {} + guard let `self` = self else {} + while var i { i = nil } +``` + +## Triggering Examples + +```swift + if ↓let i = i {} + if ↓let self = self {} + if ↓var `self` = `self` {} + if i > 0, ↓let j = j {} + if ↓let i = i, ↓var j = j {} +``` + +```swift + guard ↓let i = i else {} + guard ↓let self = self else {} + guard ↓var `self` = `self` else {} + guard i > 0, ↓let j = j else {} + guard ↓let i = i, ↓var j = j else {} +``` + +```swift + while ↓var i = i { i = nil } +``` \ No newline at end of file diff --git a/docs/description/single_test_class.md b/docs/description/single_test_class.md index 139f87f..d26504d 100755 --- a/docs/description/single_test_class.md +++ b/docs/description/single_test_class.md @@ -3,11 +3,11 @@ Test files should contain a single QuickSpec or XCTestCase class. * **Identifier:** single_test_class -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -60,4 +60,10 @@ class FooTests: XCTestCase { } ↓class FooTests: QuickSpec { } ↓class BarTests: XCTestCase { } class TotoTests { } +``` + +```swift +final ↓class FooTests: QuickSpec { } +↓class BarTests: XCTestCase { } +class TotoTests { } ``` \ No newline at end of file diff --git a/docs/description/sorted_first_last.md b/docs/description/sorted_first_last.md index 635b74f..e0aebf1 100755 --- a/docs/description/sorted_first_last.md +++ b/docs/description/sorted_first_last.md @@ -3,11 +3,11 @@ Prefer using `min()` or `max()` over `sorted().first` or `sorted().last` * **Identifier:** sorted_first_last -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** performance * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/sorted_imports.md b/docs/description/sorted_imports.md index c2829cf..b3a1bcc 100755 --- a/docs/description/sorted_imports.md +++ b/docs/description/sorted_imports.md @@ -3,11 +3,11 @@ Imports should be sorted. * **Identifier:** sorted_imports -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/statement_position.md b/docs/description/statement_position.md index aa958c4..890cc17 100755 --- a/docs/description/statement_position.md +++ b/docs/description/statement_position.md @@ -3,11 +3,11 @@ Else and catch should be on the same line, one space after the previous declaration. * **Identifier:** statement_position -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** (statement_mode) default, (severity) warning ## Non Triggering Examples diff --git a/docs/description/static_operator.md b/docs/description/static_operator.md index f67e9d6..aaa499f 100755 --- a/docs/description/static_operator.md +++ b/docs/description/static_operator.md @@ -3,11 +3,11 @@ Operators should be declared as static functions, not free functions. * **Identifier:** static_operator -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/strict_fileprivate.md b/docs/description/strict_fileprivate.md index 9138208..5aa8c30 100755 --- a/docs/description/strict_fileprivate.md +++ b/docs/description/strict_fileprivate.md @@ -3,11 +3,11 @@ `fileprivate` should be avoided. * **Identifier:** strict_fileprivate -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/strong_iboutlet.md b/docs/description/strong_iboutlet.md index 9f5d577..e0f1cea 100755 --- a/docs/description/strong_iboutlet.md +++ b/docs/description/strong_iboutlet.md @@ -3,11 +3,11 @@ @IBOutlets shouldn't be declared as weak. * **Identifier:** strong_iboutlet -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/superfluous_disable_command.md b/docs/description/superfluous_disable_command.md index c6bfb3b..ba8434a 100755 --- a/docs/description/superfluous_disable_command.md +++ b/docs/description/superfluous_disable_command.md @@ -3,9 +3,9 @@ SwiftLint 'disable' commands are superfluous when the disabled rule would not have triggered a violation in the disabled region. Use " - " if you wish to document a command. * **Identifier:** superfluous_disable_command -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning \ No newline at end of file diff --git a/docs/description/switch_case_alignment.md b/docs/description/switch_case_alignment.md index fe8bac0..b16e4fe 100755 --- a/docs/description/switch_case_alignment.md +++ b/docs/description/switch_case_alignment.md @@ -3,11 +3,11 @@ Case statements should vertically align with their enclosing switch statement, or indented if configured otherwise. * **Identifier:** switch_case_alignment -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, indented_cases: false ## Non Triggering Examples diff --git a/docs/description/switch_case_on_newline.md b/docs/description/switch_case_on_newline.md index 6745ec7..9ddc8b1 100755 --- a/docs/description/switch_case_on_newline.md +++ b/docs/description/switch_case_on_newline.md @@ -3,11 +3,11 @@ Cases inside a switch should always be on a newline * **Identifier:** switch_case_on_newline -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/syntactic_sugar.md b/docs/description/syntactic_sugar.md index d824c7f..7caa043 100755 --- a/docs/description/syntactic_sugar.md +++ b/docs/description/syntactic_sugar.md @@ -3,11 +3,11 @@ Shorthand syntactic sugar should be used, i.e. [Int] instead of Array. * **Identifier:** syntactic_sugar -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -60,6 +60,18 @@ func x(a: [Int], b: Int) -> Array.Index unsafeBitCast(nonOptionalT, to: Optional.self) ``` +```swift +unsafeBitCast(someType, to: Swift.Array.self) +``` + +```swift +IndexingIterator>>.self +``` + +```swift +let y = Optional.Type +``` + ```swift type is Optional.Type ``` @@ -68,6 +80,14 @@ type is Optional.Type let x: Foo.Optional ``` +```swift +let x = case Optional.none = obj +``` + +```swift +let a = Swift.Optional.none +``` + ## Triggering Examples ```swift @@ -83,19 +103,51 @@ let x: ↓Optional ``` ```swift -let x: ↓ImplicitlyUnwrappedOptional +let x: ↓Swift.Array ``` ```swift func x(a: ↓Array, b: Int) -> [Int: Any] ``` +```swift +func x(a: ↓Swift.Array, b: Int) -> [Int: Any] +``` + ```swift func x(a: [Int], b: Int) -> ↓Dictionary ``` ```swift -func x(a: ↓Array, b: Int) -> ↓Dictionary +let x = y as? ↓Array<[String: Any]> +``` + +```swift +let x = Box>() +``` + +```swift +func x() -> Box<↓Array> +``` + +```swift +func x() -> ↓Dictionary? +``` + +```swift +typealias Document = ↓Dictionary +``` + +```swift +func x(_ y: inout ↓Array) +``` + +```swift +let x:↓Dictionary> +``` + +```swift +func x() -> Any { return ↓Dictionary()} ``` ```swift @@ -103,5 +155,15 @@ let x = ↓Array.array(of: object) ``` ```swift -let x: ↓Swift.Optional +let x = ↓Swift.Array.array(of: object) +``` + +```swift +@_specialize(where S == ↓Array) +public init(_ elements: S) +``` + +```swift +let dict: [String: Any] = [:] +_ = dict["key"] as? ↓Optional ?? Optional.none ``` \ No newline at end of file diff --git a/docs/description/test_case_accessibility.md b/docs/description/test_case_accessibility.md index d4f0ca8..9da0099 100755 --- a/docs/description/test_case_accessibility.md +++ b/docs/description/test_case_accessibility.md @@ -3,15 +3,19 @@ Test cases should only contain private non-test members. * **Identifier:** test_case_accessibility -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning, allowed_prefixes: [[]] +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning, allowed_prefixes: [[]], test_parent_classes: [["XCTestCase"]] ## Non Triggering Examples +```swift +let foo: String? +``` + ```swift let foo: String? @@ -54,6 +58,18 @@ class FooTests: XCTestCase { func testFoo() { XCTAssertTrue(true) } + + func testBar() { + func nestedFunc() {} + } + + private someFunc(hasParam: Bool) {} +} +``` + +```swift +class FooTests: XCTestCase { + private struct MockSomething: Something {} } ``` @@ -77,6 +93,8 @@ class Foobar { ```swift class FooTests: XCTestCase { + ↓typealias Bar = Foo.Bar + ↓var foo: String? ↓let bar: String? @@ -93,6 +111,8 @@ class FooTests: XCTestCase { ↓static func testFoo() {} ↓static func allTests() {} + + ↓func testFoo(hasParam: Bool) {} } final class BarTests: XCTestCase { diff --git a/docs/description/todo.md b/docs/description/todo.md index b42c3ad..8de86b2 100755 --- a/docs/description/todo.md +++ b/docs/description/todo.md @@ -3,11 +3,11 @@ TODOs and FIXMEs should be resolved. * **Identifier:** todo -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/toggle_bool.md b/docs/description/toggle_bool.md index a0095b8..cad6c6a 100755 --- a/docs/description/toggle_bool.md +++ b/docs/description/toggle_bool.md @@ -3,11 +3,11 @@ Prefer `someBool.toggle()` over `someBool = !someBool`. * **Identifier:** toggle_bool -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.2.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/trailing_closure.md b/docs/description/trailing_closure.md index 822fd2e..13b090b 100755 --- a/docs/description/trailing_closure.md +++ b/docs/description/trailing_closure.md @@ -3,11 +3,11 @@ Trailing closure syntax should be used whenever possible. * **Identifier:** trailing_closure -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, only_single_muted_parameter: false ## Non Triggering Examples diff --git a/docs/description/trailing_comma.md b/docs/description/trailing_comma.md index 11ffd6c..722a94e 100755 --- a/docs/description/trailing_comma.md +++ b/docs/description/trailing_comma.md @@ -3,11 +3,11 @@ Trailing commas in arrays and dictionaries should be avoided/enforced. * **Identifier:** trailing_comma -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, mandatory_comma: false ## Non Triggering Examples @@ -49,6 +49,11 @@ foo([1: "\(error)"]) ``` +```swift +let foo = [Int]() + +``` + ## Triggering Examples ```swift diff --git a/docs/description/trailing_newline.md b/docs/description/trailing_newline.md index 4847ce7..9712571 100755 --- a/docs/description/trailing_newline.md +++ b/docs/description/trailing_newline.md @@ -3,11 +3,11 @@ Files should have a single trailing newline. * **Identifier:** trailing_newline -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/trailing_semicolon.md b/docs/description/trailing_semicolon.md index 7147019..e51fd58 100755 --- a/docs/description/trailing_semicolon.md +++ b/docs/description/trailing_semicolon.md @@ -3,11 +3,11 @@ Lines should not have trailing semicolons. * **Identifier:** trailing_semicolon -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/trailing_whitespace.md b/docs/description/trailing_whitespace.md index 4771282..280ba44 100755 --- a/docs/description/trailing_whitespace.md +++ b/docs/description/trailing_whitespace.md @@ -3,11 +3,11 @@ Lines should not have trailing whitespace. * **Identifier:** trailing_whitespace -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, ignores_empty_lines: false, ignores_comments: true ## Non Triggering Examples diff --git a/docs/description/type_body_length.md b/docs/description/type_body_length.md index eaba6b7..ce014e8 100755 --- a/docs/description/type_body_length.md +++ b/docs/description/type_body_length.md @@ -3,12 +3,12 @@ Type bodies should not span too many lines. * **Identifier:** type_body_length -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** metrics * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** warning: 200, error: 350 +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning: 250, error: 350 ## Non Triggering Examples @@ -213,6 +213,56 @@ let abc = 0 let abc = 0 let abc = 0 let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 } ``` @@ -399,6 +449,56 @@ class Abc { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -627,6 +727,56 @@ class Abc { // this is a comment // this is a comment // this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment } ``` @@ -832,6 +982,56 @@ let abc = 0 let abc = 0 let abc = 0 let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 /* this is a multiline comment @@ -1041,6 +1241,56 @@ let abc = 0 let abc = 0 let abc = 0 let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 } ``` @@ -1248,14 +1498,114 @@ struct Abc { -} -``` -```swift -struct Abc { -// this is a comment -// this is a comment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +``` + +```swift +struct Abc { +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment // this is a comment // this is a comment // this is a comment @@ -1660,6 +2010,56 @@ let abc = 0 let abc = 0 let abc = 0 let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 /* this is a multiline comment @@ -1869,6 +2269,56 @@ let abc = 0 let abc = 0 let abc = 0 let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 } ``` @@ -2055,6 +2505,56 @@ enum Abc { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2283,12 +2783,1403 @@ enum Abc { // this is a comment // this is a comment // this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +} + +``` + +```swift +enum Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 + +/* this is +a multiline comment +*/ +} + +``` + +```swift +actor Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +} + +``` + +```swift +actor Abc { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +``` + +```swift +actor Abc { +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +// this is a comment +} + +``` + +```swift +actor Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 + +/* this is +a multiline comment +*/ } ``` +## Triggering Examples + ```swift -enum Abc { +↓class Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 let abc = 0 let abc = 0 let abc = 0 @@ -2488,18 +4379,62 @@ let abc = 0 let abc = 0 let abc = 0 let abc = 0 - -/* this is -a multiline comment -*/ } ``` -## Triggering Examples - ```swift -↓class Abc { +↓struct Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 let abc = 0 let abc = 0 let abc = 0 @@ -2706,7 +4641,57 @@ let abc = 0 ``` ```swift -↓struct Abc { +↓enum Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 let abc = 0 let abc = 0 let abc = 0 @@ -2913,7 +4898,57 @@ let abc = 0 ``` ```swift -↓enum Abc { +↓actor Abc { +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 +let abc = 0 let abc = 0 let abc = 0 let abc = 0 diff --git a/docs/description/type_contents_order.md b/docs/description/type_contents_order.md index 93dfc54..fe43bf0 100755 --- a/docs/description/type_contents_order.md +++ b/docs/description/type_contents_order.md @@ -3,11 +3,11 @@ Specifies the order of subtypes, properties, methods & more within a type. * **Identifier:** type_contents_order -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, order: [[SwiftLintFramework.TypeContent.case], [SwiftLintFramework.TypeContent.typeAlias, SwiftLintFramework.TypeContent.associatedType], [SwiftLintFramework.TypeContent.subtype], [SwiftLintFramework.TypeContent.typeProperty], [SwiftLintFramework.TypeContent.instanceProperty], [SwiftLintFramework.TypeContent.ibInspectable], [SwiftLintFramework.TypeContent.ibOutlet], [SwiftLintFramework.TypeContent.initializer], [SwiftLintFramework.TypeContent.typeMethod], [SwiftLintFramework.TypeContent.viewLifeCycleMethod], [SwiftLintFramework.TypeContent.ibAction], [SwiftLintFramework.TypeContent.otherMethod], [SwiftLintFramework.TypeContent.subscript], [SwiftLintFramework.TypeContent.deinitializer]] ## Non Triggering Examples @@ -70,6 +70,13 @@ class TestViewController: UIViewController { hasLayoutedView1 = true } + override func willMove(toParent parent: UIViewController?) { + super.willMove(toParent: parent) + if parent == nil { + viewModel.willMoveToParent() + } + } + override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() diff --git a/docs/description/type_name.md b/docs/description/type_name.md index 84d6649..75b81e3 100755 --- a/docs/description/type_name.md +++ b/docs/description/type_name.md @@ -1,14 +1,15 @@ # Type Name Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 40 characters in length. +Private types may start with an underscore. * **Identifier:** type_name -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** (min_length) w/e: 3/0, (max_length) w/e: 40/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** (min_length) w/e: 3/0, (max_length) w/e: 40/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true, validate_protocols: true ## Non Triggering Examples @@ -16,62 +17,14 @@ Type name should only contain alphanumeric characters, start with an uppercase c class MyType {} ``` -```swift -private class _MyType {} -``` - -```swift -class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} -``` - -```swift -class MyView_Previews: PreviewProvider -``` - -```swift -private class _MyView_Previews: PreviewProvider -``` - -```swift -struct MyType {} -``` - ```swift private struct _MyType {} ``` -```swift -struct AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} -``` - -```swift -struct MyView_Previews: PreviewProvider -``` - -```swift -private struct _MyView_Previews: PreviewProvider -``` - -```swift -enum MyType {} -``` - -```swift -private enum _MyType {} -``` - ```swift enum AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} ``` -```swift -enum MyView_Previews: PreviewProvider -``` - -```swift -private enum _MyView_Previews: PreviewProvider -``` - ```swift typealias Foo = Void ``` @@ -98,46 +51,26 @@ case value } ``` -## Triggering Examples - -```swift -class ↓myType {} -``` - ```swift -class ↓_MyType {} +protocol P {} ``` ```swift -private class ↓MyType_ {} -``` - -```swift -class ↓My {} -``` - -```swift -class ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} -``` - -```swift -class ↓MyView_Previews -``` - -```swift -private class ↓_MyView_Previews +struct SomeStruct { + enum `Type` { + case x, y, z + } +} ``` -```swift -class ↓MyView_Previews_Previews: PreviewProvider -``` +## Triggering Examples ```swift -struct ↓myType {} +class ↓myType {} ``` ```swift -struct ↓_MyType {} +enum ↓_MyType {} ``` ```swift @@ -153,49 +86,13 @@ struct ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} ``` ```swift -struct ↓MyView_Previews +class ↓MyView_Previews ``` ```swift private struct ↓_MyView_Previews ``` -```swift -struct ↓MyView_Previews_Previews: PreviewProvider -``` - -```swift -enum ↓myType {} -``` - -```swift -enum ↓_MyType {} -``` - -```swift -private enum ↓MyType_ {} -``` - -```swift -enum ↓My {} -``` - -```swift -enum ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {} -``` - -```swift -enum ↓MyView_Previews -``` - -```swift -private enum ↓_MyView_Previews -``` - -```swift -enum ↓MyView_Previews_Previews: PreviewProvider -``` - ```swift typealias ↓X = Void ``` @@ -228,4 +125,8 @@ protocol Foo { protocol Foo { associatedtype ↓AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA } +``` + +```swift +protocol ↓X {} ``` \ No newline at end of file diff --git a/docs/description/typesafe_array_init.md b/docs/description/typesafe_array_init.md new file mode 100755 index 0000000..c9a978c --- /dev/null +++ b/docs/description/typesafe_array_init.md @@ -0,0 +1,55 @@ +# Type-safe Array Init + +Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array. + +* **Identifier:** typesafe_array_init +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** Yes +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift + enum MyError: Error {} + let myResult: Result = .success("") + let result: Result = myResult.map { $0 } +``` + +```swift + struct IntArray { + let elements = [1, 2, 3] + func map(_ transformer: (Int) throws -> T) rethrows -> [T] { + try elements.map(transformer) + } + } + let ints = IntArray() + let intsCopy = ints.map { $0 } +``` + +## Triggering Examples + +```swift + func f(s: Seq) -> [Seq.Element] { + s.↓map({ $0 }) + } +``` + +```swift + func f(array: [Int]) -> [Int] { + array.↓map { $0 } + } +``` + +```swift + let myInts = [1, 2, 3].↓map { return $0 } +``` + +```swift + struct Generator: Sequence, IteratorProtocol { + func next() -> Int? { nil } + } + let array = Generator().↓map { i in i } +``` \ No newline at end of file diff --git a/docs/description/unavailable_condition.md b/docs/description/unavailable_condition.md new file mode 100755 index 0000000..eac96fb --- /dev/null +++ b/docs/description/unavailable_condition.md @@ -0,0 +1,67 @@ +# Unavailable Condition + +Use #unavailable/#available instead of #available/#unavailable with an empty body. + +* **Identifier:** unavailable_condition +* **Enabled by default:** Yes +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.6.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +if #unavailable(iOS 13) { + loadMainWindow() +} +``` + +```swift +if #available(iOS 9.0, *) { + doSomething() +} else { + legacyDoSomething() +} +``` + +```swift +if #available(macOS 11.0, *) { + // Do nothing +} else if #available(macOS 10.15, *) { + print("do some stuff") +} +``` + +## Triggering Examples + +```swift +if ↓#available(iOS 14.0) { + +} else { + oldIos13TrackingLogic(isEnabled: ASIdentifierManager.shared().isAdvertisingTrackingEnabled) +} +``` + +```swift +if ↓#available(iOS 14.0) { + // we don't need to do anything here +} else { + oldIos13TrackingLogic(isEnabled: ASIdentifierManager.shared().isAdvertisingTrackingEnabled) +} +``` + +```swift +if ↓#available(iOS 13, *) {} else { + loadMainWindow() +} +``` + +```swift +if ↓#unavailable(iOS 13) { + // Do nothing +} else if i < 2 { + loadMainWindow() +} +``` \ No newline at end of file diff --git a/docs/description/unavailable_function.md b/docs/description/unavailable_function.md index 5e22a1d..8bac9d1 100755 --- a/docs/description/unavailable_function.md +++ b/docs/description/unavailable_function.md @@ -3,11 +3,11 @@ Unimplemented functions should be marked as unavailable. * **Identifier:** unavailable_function -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.1.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -70,7 +70,7 @@ class ViewController: UIViewController { ``` ```swift -func resetOnboardingStateAndCrash() { +↓func resetOnboardingStateAndCrash() { resetUserDefaults() // Crash the app to re-start the onboarding flow. fatalError("Onboarding re-start crash.") diff --git a/docs/description/unneeded_break_in_switch.md b/docs/description/unneeded_break_in_switch.md index 21f4e4e..da0c4b4 100755 --- a/docs/description/unneeded_break_in_switch.md +++ b/docs/description/unneeded_break_in_switch.md @@ -3,11 +3,11 @@ Avoid using unneeded break statements. * **Identifier:** unneeded_break_in_switch -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -47,6 +47,20 @@ case .bar: } ``` +```swift +let items = [Int]() +for item in items { + if bar() { + do { + try foo() + } catch { + bar() + break + } + } +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/unneeded_parentheses_in_closure_argument.md b/docs/description/unneeded_parentheses_in_closure_argument.md index 1e357fc..b3f2cee 100755 --- a/docs/description/unneeded_parentheses_in_closure_argument.md +++ b/docs/description/unneeded_parentheses_in_closure_argument.md @@ -3,11 +3,11 @@ Parentheses are not needed when declaring closure arguments. * **Identifier:** unneeded_parentheses_in_closure_argument -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -32,6 +32,12 @@ let foo = { bar -> Bool in return true } ``` +```swift +DispatchQueue.main.async { () -> Void in + doSomething() +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/unowned_variable_capture.md b/docs/description/unowned_variable_capture.md index 4b446ce..e619289 100755 --- a/docs/description/unowned_variable_capture.md +++ b/docs/description/unowned_variable_capture.md @@ -3,7 +3,7 @@ Prefer capturing references as weak to avoid potential crashes. * **Identifier:** unowned_variable_capture -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No diff --git a/docs/description/untyped_error_in_catch.md b/docs/description/untyped_error_in_catch.md index 669fd66..3cc3111 100755 --- a/docs/description/untyped_error_in_catch.md +++ b/docs/description/untyped_error_in_catch.md @@ -3,11 +3,11 @@ Catch statements should not declare error variables without type casting. * **Identifier:** untyped_error_in_catch -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -39,6 +39,16 @@ do { } catch {} ``` +```swift +do { + try something() +} catch let e where e.code == .fileError { + // can be ignored +} catch { + print(error) +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/unused_capture_list.md b/docs/description/unused_capture_list.md index 48a27ea..9d57c15 100755 --- a/docs/description/unused_capture_list.md +++ b/docs/description/unused_capture_list.md @@ -3,11 +3,11 @@ Unused reference in a capture list should be removed. * **Identifier:** unused_capture_list -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.2.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -127,7 +127,7 @@ numbers.forEach({ ```swift numbers.forEach({ - [self, weak handler] in + [self, ↓weak handler] in print($0) }) ``` diff --git a/docs/description/unused_closure_parameter.md b/docs/description/unused_closure_parameter.md index 3164dd9..bbc6c07 100755 --- a/docs/description/unused_closure_parameter.md +++ b/docs/description/unused_closure_parameter.md @@ -3,11 +3,11 @@ Unused parameter in a closure should be replaced with _. * **Identifier:** unused_closure_parameter -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.2.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -109,6 +109,30 @@ let failure: Failure = { task, error in } ``` +```swift +List($names) { $name in + Text(name) +} +``` + +```swift +List($names) { $name in + TextField($name) +} +``` + +```swift +_ = ["a"].filter { `class` in `class`.hasPrefix("a") } +``` + +```swift +let closure: (Int) -> Void = { `foo` in _ = foo } +``` + +```swift +let closure: (Int) -> Void = { foo in _ = `foo` } +``` + ## Triggering Examples ```swift @@ -181,4 +205,15 @@ viewModel?.profileImage.didSet(weak: self) { (↓self, profileImage) in let failure: Failure = { ↓task, error in observer.sendFailed(error) } +``` + +```swift +List($names) { ↓$name in + Text("Foo") +} +``` + +```swift +let class1 = "a" +_ = ["a"].filter { ↓`class` in `class1`.hasPrefix("a") } ``` \ No newline at end of file diff --git a/docs/description/unused_control_flow_label.md b/docs/description/unused_control_flow_label.md index 79c68cf..5335866 100755 --- a/docs/description/unused_control_flow_label.md +++ b/docs/description/unused_control_flow_label.md @@ -3,11 +3,11 @@ Unused control flow label should be removed. * **Identifier:** unused_control_flow_label -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/unused_declaration.md b/docs/description/unused_declaration.md index 07faffd..7114eb3 100755 --- a/docs/description/unused_declaration.md +++ b/docs/description/unused_declaration.md @@ -3,11 +3,11 @@ Declarations should be referenced at least once within all files linted. * **Identifier:** unused_declaration -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** Yes -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** severity: error, include_public_and_open: false, related_usrs_to_skip: ["s:7SwiftUI15PreviewProviderP"] ## Non Triggering Examples @@ -36,11 +36,11 @@ extension Sequence { } let changes = [Change.insert(0), .delete(0)] -changes.deletes() +_ = changes.deletes() ``` ```swift -struct Item {} +struct Item: Codable {} struct ResponseModel: Codable { let items: [Item] @@ -97,18 +97,46 @@ enum Component { indirect case optional(Component?) } -@_functionBuilder +@resultBuilder struct ComponentBuilder { + static func buildBlock(_ components: Component...) -> Component { + return .array(components) + } + static func buildExpression(_ string: StaticString) -> Component { return .string(string) } - static func buildBlock(_ components: Component...) -> Component { + static func buildOptional(_ component: Component?) -> Component { + return .optional(component) + } + + static func buildEither(first component: Component) -> Component { + return component + } + + static func buildEither(second component: Component) -> Component { + return component + } + + static func buildArray(_ components: [Component]) -> Component { return .array(components) } - static func buildIf(_ value: Component?) -> Component { - return .optional(value) + static func buildLimitedAvailability(_ component: Component) -> Component { + return component + } + + static func buildFinalResult(_ component: Component) -> Component { + return component + } + + static func buildPartialBlock(first component: Component) -> Component { + return component + } + + static func buildPartialBlock(accumulated component: Component, next: Component) -> Component { + return component } } diff --git a/docs/description/unused_enumerated.md b/docs/description/unused_enumerated.md index 3afb742..e15d678 100755 --- a/docs/description/unused_enumerated.md +++ b/docs/description/unused_enumerated.md @@ -3,11 +3,11 @@ When the index or the item is not used, `.enumerated()` can be removed. * **Identifier:** unused_enumerated -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/unused_import.md b/docs/description/unused_import.md index 2fed7d2..89cfcda 100755 --- a/docs/description/unused_import.md +++ b/docs/description/unused_import.md @@ -3,11 +3,11 @@ All imported modules should be required to make the file compile. * **Identifier:** unused_import -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** lint * **Analyzer rule:** Yes -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** severity: warning, require_explicit_imports: false, allowed_transitive_imports: [], always_keep_imports: [] ## Non Triggering Examples @@ -75,4 +75,10 @@ class A {} ↓import Foundation import UnknownModule func foo(error: Swift.Error) {} +``` + +```swift +↓import Swift +↓import SwiftShims +func foo(error: Swift.Error) {} ``` \ No newline at end of file diff --git a/docs/description/unused_optional_binding.md b/docs/description/unused_optional_binding.md index 2d27f7e..4206e54 100755 --- a/docs/description/unused_optional_binding.md +++ b/docs/description/unused_optional_binding.md @@ -3,11 +3,11 @@ Prefer `!= nil` over `let _ =` * **Identifier:** unused_optional_binding -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, ignore_optional_try: false ## Non Triggering Examples @@ -97,8 +97,4 @@ func foo() { if let ↓_ = bar { } -``` - -```swift -if case .some(let ↓_) = self {} ``` \ No newline at end of file diff --git a/docs/description/unused_setter_value.md b/docs/description/unused_setter_value.md index ed07a1a..03b79a8 100755 --- a/docs/description/unused_setter_value.md +++ b/docs/description/unused_setter_value.md @@ -3,11 +3,11 @@ Setter value is not used. * **Identifier:** unused_setter_value -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -45,6 +45,15 @@ var aValue: String { } ``` +```swift +override var aValue: String { + get { + return Persister.shared.aValue + } + set { } +} +``` + ## Triggering Examples ```swift @@ -101,4 +110,15 @@ var aValue: String { Persister.shared.aValue = aValue } } +``` + +```swift +override var aValue: String { + get { + return Persister.shared.aValue + } + ↓set { + Persister.shared.aValue = aValue + } +} ``` \ No newline at end of file diff --git a/docs/description/valid_ibinspectable.md b/docs/description/valid_ibinspectable.md index 964ae53..97a750f 100755 --- a/docs/description/valid_ibinspectable.md +++ b/docs/description/valid_ibinspectable.md @@ -3,11 +3,11 @@ @IBInspectable should be applied to variables only, have its type explicit and be of a supported type * **Identifier:** valid_ibinspectable -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -68,6 +68,16 @@ extension Foo { } ``` +```swift +class Foo { + @IBInspectable var borderColor: UIColor? = nil { + didSet { + updateAppearance() + } + } +} +``` + ## Triggering Examples ```swift @@ -100,12 +110,6 @@ class Foo { } ``` -```swift -class Foo { - @IBInspectable private ↓var x: ImplicitlyUnwrappedOptional -} -``` - ```swift class Foo { @IBInspectable private ↓var count: Optional @@ -116,10 +120,4 @@ class Foo { class Foo { @IBInspectable private ↓var x: Optional } -``` - -```swift -class Foo { - @IBInspectable private ↓var x: ImplicitlyUnwrappedOptional -} ``` \ No newline at end of file diff --git a/docs/description/vertical_parameter_alignment.md b/docs/description/vertical_parameter_alignment.md index 745c6e3..e8a54bb 100755 --- a/docs/description/vertical_parameter_alignment.md +++ b/docs/description/vertical_parameter_alignment.md @@ -3,11 +3,11 @@ Function parameters should be aligned vertically if they're in multiple lines in a declaration. * **Identifier:** vertical_parameter_alignment -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -72,6 +72,19 @@ func foo(data: Data, @ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {} ``` +```swift +class A { + init(bar: Int) +} +``` + +```swift +class A { + init(foo: Int, + bar: String) +} +``` + ## Triggering Examples ```swift @@ -93,4 +106,11 @@ func validateFunction(_ file: SwiftLintFile, ```swift func foo(data: Data, ↓@ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {} +``` + +```swift +class A { + init(data: Data, + ↓@ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {} +} ``` \ No newline at end of file diff --git a/docs/description/vertical_parameter_alignment_on_call.md b/docs/description/vertical_parameter_alignment_on_call.md index 253064b..1b52fcf 100755 --- a/docs/description/vertical_parameter_alignment_on_call.md +++ b/docs/description/vertical_parameter_alignment_on_call.md @@ -3,11 +3,11 @@ Function parameters should be aligned vertically if they're in multiple lines in a method call. * **Identifier:** vertical_parameter_alignment_on_call -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/vertical_whitespace.md b/docs/description/vertical_whitespace.md index f51b322..03df82f 100755 --- a/docs/description/vertical_whitespace.md +++ b/docs/description/vertical_whitespace.md @@ -3,11 +3,11 @@ Limit vertical whitespace to a single empty line. * **Identifier:** vertical_whitespace -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning, max_empty_lines: 1 ## Non Triggering Examples diff --git a/docs/description/vertical_whitespace_between_cases.md b/docs/description/vertical_whitespace_between_cases.md index eb9f5ef..5e77b5b 100755 --- a/docs/description/vertical_whitespace_between_cases.md +++ b/docs/description/vertical_whitespace_between_cases.md @@ -3,11 +3,11 @@ Include a single empty line between switch cases. * **Identifier:** vertical_whitespace_between_cases -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/vertical_whitespace_closing_braces.md b/docs/description/vertical_whitespace_closing_braces.md index 6600927..bc93e6d 100755 --- a/docs/description/vertical_whitespace_closing_braces.md +++ b/docs/description/vertical_whitespace_closing_braces.md @@ -3,39 +3,32 @@ Don't include vertical whitespace (empty line) before closing braces. * **Identifier:** vertical_whitespace_closing_braces -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** N/A +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning, only_enforce_before_trivial_lines: false ## Non Triggering Examples ```swift -/* - class X { - - let x = 5 - - } -*/ +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum + +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul +}]) ``` ```swift -[ -1, -2, -3 -] -``` - -```swift -[1, 2].map { $0 }.filter { num in true } -``` - -```swift -[1, 2].map { $0 }.filter { true } +print([ + 1 +]) ``` ```swift @@ -51,9 +44,11 @@ do { ``` ```swift -do { - print("x is 5") -} +[ +1, +2, +3 +] ``` ```swift @@ -63,6 +58,12 @@ foo( ) ``` +```swift +do { + print("x is 5") +} +``` + ```swift func foo() { run(5) { x in @@ -71,23 +72,61 @@ func foo() { } ``` +```swift +[1, 2].map { $0 }.filter { true } +``` + +```swift +[1, 2].map { $0 }.filter { num in true } +``` + +```swift +/* + class X { + + let x = 5 + + } +*/ +``` + +```swift +if bool1 { + // do something + // do something + +} else if bool2 { + // do something + // do something + // do something + +} else { + // do something + // do something +} +``` + ## Triggering Examples ```swift -[ -1, -2, -3 +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum + +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul ↓ -] +}]) ``` ```swift -do { - print("x is 5") +print([ + 1 ↓ - -} +]) ``` ```swift @@ -105,6 +144,15 @@ do { } ``` +```swift +[ +1, +2, +3 +↓ +] +``` + ```swift foo( x: 5, @@ -113,6 +161,14 @@ foo( ) ``` +```swift +do { + print("x is 5") +↓ + +} +``` + ```swift func foo() { run(5) { x in diff --git a/docs/description/vertical_whitespace_opening_braces.md b/docs/description/vertical_whitespace_opening_braces.md index 4bbf0ad..35c4e99 100755 --- a/docs/description/vertical_whitespace_opening_braces.md +++ b/docs/description/vertical_whitespace_opening_braces.md @@ -3,12 +3,12 @@ Don't include vertical whitespace (empty line) after opening braces. * **Identifier:** vertical_whitespace_opening_braces -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 -* **Default configuration:** N/A +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/void_function_in_ternary.md b/docs/description/void_function_in_ternary.md new file mode 100755 index 0000000..842b14e --- /dev/null +++ b/docs/description/void_function_in_ternary.md @@ -0,0 +1,130 @@ +# Void Function in Ternary + +Using ternary to call Void functions should be avoided. + +* **Identifier:** void_function_in_ternary +* **Enabled by default:** Yes +* **Supports autocorrection:** No +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.1.0 +* **Default configuration:** warning + +## Non Triggering Examples + +```swift +let result = success ? foo() : bar() +``` + +```swift +if success { + askQuestion() +} else { + exit() +} +``` + +```swift +var price: Double { + return hasDiscount ? calculatePriceWithDiscount() : calculateRegularPrice() +} +``` + +```swift +foo(x == 2 ? a() : b()) +``` + +```swift +chevronView.image = collapsed ? .icon(.mediumChevronDown) : .icon(.mediumChevronUp) +``` + +```swift +array.map { elem in + elem.isEmpty() ? .emptyValue() : .number(elem) +} +``` + +```swift +func compute(data: [Int]) -> Int { + data.isEmpty ? 0 : expensiveComputation(data) +} +``` + +```swift +var value: Int { + mode == .fast ? fastComputation() : expensiveComputation() +} +``` + +```swift +var value: Int { + get { + mode == .fast ? fastComputation() : expensiveComputation() + } +} +``` + +```swift +subscript(index: Int) -> Int { + get { + index == 0 ? defaultValue() : compute(index) + } +``` + +```swift +subscript(index: Int) -> Int { + index == 0 ? defaultValue() : compute(index) +``` + +## Triggering Examples + +```swift +success ↓? askQuestion() : exit() +``` + +```swift +perform { elem in + elem.isEmpty() ↓? .emptyValue() : .number(elem) + return 1 +} +``` + +```swift +DispatchQueue.main.async { + self.sectionViewModels[section].collapsed.toggle() + self.sectionViewModels[section].collapsed + ↓? self.tableView.deleteRows(at: [IndexPath(row: 0, section: section)], with: .automatic) + : self.tableView.insertRows(at: [IndexPath(row: 0, section: section)], with: .automatic) + self.tableView.scrollToRow(at: IndexPath(row: NSNotFound, section: section), at: .top, animated: true) +} +``` + +```swift +subscript(index: Int) -> Int { + index == 0 ↓? something() : somethingElse(index) + return index +``` + +```swift +var value: Int { + mode == .fast ↓? something() : somethingElse() + return 0 +} +``` + +```swift +var value: Int { + get { + mode == .fast ↓? something() : somethingElse() + return 0 + } +} +``` + +```swift +subscript(index: Int) -> Int { + get { + index == 0 ↓? something() : somethingElse(index) + return index + } +``` \ No newline at end of file diff --git a/docs/description/void_return.md b/docs/description/void_return.md index a8a1943..6e31883 100755 --- a/docs/description/void_return.md +++ b/docs/description/void_return.md @@ -3,11 +3,11 @@ Prefer `-> Void` over `-> ()`. * **Identifier:** void_return -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** Yes * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/weak_delegate.md b/docs/description/weak_delegate.md index 81cf4ce..47ceee6 100755 --- a/docs/description/weak_delegate.md +++ b/docs/description/weak_delegate.md @@ -3,11 +3,11 @@ Delegates should be weak to avoid reference cycles. * **Identifier:** weak_delegate -* **Enabled by default:** Enabled -* **Supports autocorrection:** Yes +* **Enabled by default:** No +* **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -78,12 +78,42 @@ class Foo { } ``` +```swift +class Foo { + var computedDelegate: ComputedDelegate { + get { + return bar() + } + } +``` + ```swift struct Foo { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate } ``` +```swift +struct Foo { + @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate +} +``` + +```swift +struct Foo { + @WKExtensionDelegateAdaptor(ExtensionDelegate.self) var extensionDelegate +} +``` + +```swift +class Foo { + func makeDelegate() -> SomeDelegate { + let delegate = SomeDelegate() + return delegate + } +} +``` + ## Triggering Examples ```swift @@ -98,4 +128,13 @@ class Foo { ↓var scrollDelegate: ScrollDelegate? } +``` + +```swift +class Foo { + ↓var delegate: SomeProtocol? { + didSet { + print("Updated delegate") + } + } ``` \ No newline at end of file diff --git a/docs/description/xct_specific_matcher.md b/docs/description/xct_specific_matcher.md index ad52c98..93366ea 100755 --- a/docs/description/xct_specific_matcher.md +++ b/docs/description/xct_specific_matcher.md @@ -3,11 +3,11 @@ Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual` * **Identifier:** xct_specific_matcher -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 4.1.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/xctfail_message.md b/docs/description/xctfail_message.md index 85f408f..7d2453a 100755 --- a/docs/description/xctfail_message.md +++ b/docs/description/xctfail_message.md @@ -3,11 +3,11 @@ An XCTFail call should include a description of the assertion. * **Identifier:** xctfail_message -* **Enabled by default:** Enabled +* **Enabled by default:** Yes * **Supports autocorrection:** No * **Kind:** idiomatic * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples diff --git a/docs/description/yoda_condition.md b/docs/description/yoda_condition.md index bfa6cb0..2fc5ecd 100755 --- a/docs/description/yoda_condition.md +++ b/docs/description/yoda_condition.md @@ -1,13 +1,13 @@ # Yoda condition rule -The variable should be placed on the left, the constant on the right of a comparison operator. +The constant literal should be placed on the right-hand side of the comparison operator. * **Identifier:** yoda_condition -* **Enabled by default:** Disabled +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No -* **Minimum Swift compiler version:** 3.0.0 +* **Minimum Swift compiler version:** 5.0.0 * **Default configuration:** warning ## Non Triggering Examples @@ -53,35 +53,47 @@ if optionalValue?.property ?? 0 == 2 {} if foo == nil {} ``` +```swift +if flags & 1 == 1 {} +``` + ## Triggering Examples ```swift -↓if 42 == foo {} +if ↓42 == foo {} ``` ```swift -↓if 42.42 >= foo {} +if ↓42.42 >= foo {} ``` ```swift -↓guard 42 <= foo else { return } +guard ↓42 <= foo else { return } + +``` +```swift +guard ↓"str str" != foo else { return } +``` + +```swift +while ↓10 > foo { } ``` ```swift -↓guard "str str" != foo else { return } +while ↓1 < foo { } ``` ```swift -↓while 10 > foo { } +if ↓nil == foo {} ``` ```swift -↓while 1 < foo { } +while ↓1 > i + 5 {} ``` ```swift -↓if nil == foo {} +if ↓200 <= i && i <= 299 || ↓600 <= i {} ``` \ No newline at end of file diff --git a/docs/patterns.json b/docs/patterns.json index 4fd787c..3a0b6ea 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -1,7 +1,28 @@ { "name" : "swiftlint", - "version" : "0.43.1", + "version" : "0.50.1", "patterns" : [ { + "patternId" : "accessibility_label_for_image", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "accessibility_trait_for_button", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "anonymous_argument_in_multiline_closure", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { "patternId" : "anyobject_protocol", "level" : "Warning", "category" : "ErrorProne", @@ -106,6 +127,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "comma_inheritance", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "comment_spacing", "level" : "Warning", @@ -218,6 +246,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "discouraged_none_name", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "discouraged_object_literal", "level" : "Info", @@ -253,6 +288,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "duplicated_key_in_dictionary_literal", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true }, { "patternId" : "dynamic_inline", "level" : "Error", @@ -437,7 +479,7 @@ "enabled" : false }, { "patternId" : "for_where", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -644,7 +686,7 @@ "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], - "enabled" : false + "enabled" : true }, { "patternId" : "let_var_whitespace", "level" : "Warning", @@ -666,6 +708,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "local_doc_comment", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "lower_acl_than_parent", "level" : "Warning", @@ -778,6 +827,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "no_magic_numbers", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "no_space_in_method_call", "level" : "Warning", @@ -792,6 +848,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "ns_number_init_as_function_reference", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true }, { "patternId" : "nslocalizedstring_key", "level" : "Warning", @@ -890,6 +953,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "prefer_self_in_static_references", + "level" : "Warning", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "prefer_self_type_over_type_of_self", "level" : "Warning", @@ -1086,6 +1156,27 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "return_value_from_void_function", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "self_binding", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "self_in_property_initialization", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true }, { "patternId" : "shorthand_operator", "level" : "Error", @@ -1093,6 +1184,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "shorthand_optional_binding", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "single_test_class", "level" : "Warning", @@ -1247,6 +1345,20 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "typesafe_array_init", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "unavailable_condition", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true }, { "patternId" : "unavailable_function", "level" : "Warning", @@ -1382,11 +1494,18 @@ "enabled" : false }, { "patternId" : "vertical_whitespace_opening_braces", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "void_function_in_ternary", + "level" : "Warning", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true }, { "patternId" : "void_return", "level" : "Warning", @@ -1400,7 +1519,7 @@ "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], - "enabled" : true + "enabled" : false }, { "patternId" : "xct_specific_matcher", "level" : "Warning", From 00f77a00b1867c8c50da1c2f1e68bf67fd79eec0 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 5 Jan 2023 13:17:33 +0100 Subject: [PATCH 070/119] Change CI to use staged doc-generator --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 37ce028..5f9ad2f 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,9 +25,12 @@ workflows: - run: name: Build Docker image for doc-generator command: docker build -t $CIRCLE_PROJECT_REPONAME:latest . + - run: + name: Build Documentation generator + command: sbt doc-generator/stage - run: name: Run Documentation generator - command: SBT_NATIVE_CLIENT=false sudo sbt doc-generator/run + command: doc-generator/target/universal/stage/bin/doc-generator - run: name: Build release Docker image command: docker build -t $CIRCLE_PROJECT_REPONAME:latest . From 3c13f4949b9b8b7960044157b37e230bb23a4652 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 5 Jan 2023 13:55:54 +0100 Subject: [PATCH 071/119] Use swiftlint image in doc-generator --- .circleci/config.yml | 9 +++------ doc-generator/src/main/scala/doc-generator.scala | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5f9ad2f..9b3f380 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,18 +19,15 @@ workflows: - run: name: Check Scalafmt on Sbt sources command: sbt scalafmtSbtCheck - - run: - name: Build Graalvm native-image - command: sbt graalvm-native-image:packageBin - - run: - name: Build Docker image for doc-generator - command: docker build -t $CIRCLE_PROJECT_REPONAME:latest . - run: name: Build Documentation generator command: sbt doc-generator/stage - run: name: Run Documentation generator command: doc-generator/target/universal/stage/bin/doc-generator + - run: + name: Build Graalvm native-image + command: sbt graalvm-native-image:packageBin - run: name: Build release Docker image command: docker build -t $CIRCLE_PROJECT_REPONAME:latest . diff --git a/doc-generator/src/main/scala/doc-generator.scala b/doc-generator/src/main/scala/doc-generator.scala index df96c39..2c730f1 100644 --- a/doc-generator/src/main/scala/doc-generator.scala +++ b/doc-generator/src/main/scala/doc-generator.scala @@ -14,7 +14,7 @@ object Main extends App { s"-w=$workdir", s"--user=root", "--entrypoint=swiftlint", - "codacy-swiftlint" + "norionomura/swiftlint:0.50.1_swift-5.7.0" ) os.proc(baseCommand :+ "generate-docs").call() From 23de83d052c098bb26e97e21896a793b72bed242 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 5 Jan 2023 14:00:47 +0100 Subject: [PATCH 072/119] Change docker command --- doc-generator/src/main/scala/doc-generator.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc-generator/src/main/scala/doc-generator.scala b/doc-generator/src/main/scala/doc-generator.scala index 2c730f1..c6baec4 100644 --- a/doc-generator/src/main/scala/doc-generator.scala +++ b/doc-generator/src/main/scala/doc-generator.scala @@ -13,8 +13,8 @@ object Main extends App { s"--volume=$tempDir:$workdir", s"-w=$workdir", s"--user=root", - "--entrypoint=swiftlint", - "norionomura/swiftlint:0.50.1_swift-5.7.0" + "norionomura/swiftlint:0.50.1_swift-5.7.0", + "swiftlint" ) os.proc(baseCommand :+ "generate-docs").call() From f195a5d01147d06508c31f6baf46ce4922eaf2bf Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 5 Jan 2023 14:58:13 +0100 Subject: [PATCH 073/119] run docker without root --- doc-generator/src/main/scala/doc-generator.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/doc-generator/src/main/scala/doc-generator.scala b/doc-generator/src/main/scala/doc-generator.scala index c6baec4..63331ab 100644 --- a/doc-generator/src/main/scala/doc-generator.scala +++ b/doc-generator/src/main/scala/doc-generator.scala @@ -12,7 +12,6 @@ object Main extends App { "run", s"--volume=$tempDir:$workdir", s"-w=$workdir", - s"--user=root", "norionomura/swiftlint:0.50.1_swift-5.7.0", "swiftlint" ) From c00bd7c0bc4639080f71b34d28c4395b35296882 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 5 Jan 2023 15:02:43 +0100 Subject: [PATCH 074/119] Update Swiftlint to 0.50.3 --- Dockerfile | 2 +- Dockerfile.dev | 2 +- .../src/main/scala/doc-generator.scala | 2 +- docs/description/balanced_xctest_lifecycle.md | 2 +- docs/description/comma.md | 4 + docs/description/empty_enum_arguments.md | 24 ++++ docs/description/empty_xctest_method.md | 2 +- docs/description/shorthand_operator.md | 24 ++++ docs/description/single_test_class.md | 2 +- docs/description/test_case_accessibility.md | 2 +- .../vertical_whitespace_closing_braces.md | 104 +++++++++--------- docs/patterns.json | 8 +- 12 files changed, 115 insertions(+), 63 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8cc1813..a34398e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM norionomura/swiftlint:0.50.1_swift-5.7.0 as builder +FROM norionomura/swiftlint:0.50.3_swift-5.7.0 as builder FROM swift:5.7.0-jammy-slim diff --git a/Dockerfile.dev b/Dockerfile.dev index 96654ca..9bbf037 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM norionomura/swiftlint:0.50.1_swift-5.7.0 as builder +FROM norionomura/swiftlint:0.50.3_swift-5.7.0 as builder FROM swift:5.7.0-jammy-slim diff --git a/doc-generator/src/main/scala/doc-generator.scala b/doc-generator/src/main/scala/doc-generator.scala index 63331ab..a438f0e 100644 --- a/doc-generator/src/main/scala/doc-generator.scala +++ b/doc-generator/src/main/scala/doc-generator.scala @@ -12,7 +12,7 @@ object Main extends App { "run", s"--volume=$tempDir:$workdir", s"-w=$workdir", - "norionomura/swiftlint:0.50.1_swift-5.7.0", + "norionomura/swiftlint:0.50.3_swift-5.7.0", "swiftlint" ) diff --git a/docs/description/balanced_xctest_lifecycle.md b/docs/description/balanced_xctest_lifecycle.md index 821f0d1..5fb938f 100755 --- a/docs/description/balanced_xctest_lifecycle.md +++ b/docs/description/balanced_xctest_lifecycle.md @@ -8,7 +8,7 @@ Test classes must implement balanced setUp and tearDown methods. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** warning, test_parent_classes: ["QuickSpec", "XCTestCase"] ## Non Triggering Examples diff --git a/docs/description/comma.md b/docs/description/comma.md index 04494c1..c6d25b9 100755 --- a/docs/description/comma.md +++ b/docs/description/comma.md @@ -91,4 +91,8 @@ return Foo(bar: .baz, title: fuzz, message: My.Custom.message↓ , another: parameter, doIt: true, alignment: .center) +``` + +```swift +Logger.logError("Hat is too large"↓, info: []) ``` \ No newline at end of file diff --git a/docs/description/empty_enum_arguments.md b/docs/description/empty_enum_arguments.md index 564c2cd..4babd33 100755 --- a/docs/description/empty_enum_arguments.md +++ b/docs/description/empty_enum_arguments.md @@ -54,6 +54,18 @@ case (let f as () -> String)?: break } ``` +```swift +switch foo { +case .bar(Baz()): break +} +``` + +```swift +switch foo { +case .bar(.init()): break +} +``` + ```swift switch foo { default: break @@ -119,6 +131,18 @@ case .bar↓() where method() > 2: break } ``` +```swift +switch foo { +case .bar(.baz↓()): break +} +``` + +```swift +switch foo { +case .bar(.baz↓(_)): break +} +``` + ```swift func example(foo: Foo) { switch foo { diff --git a/docs/description/empty_xctest_method.md b/docs/description/empty_xctest_method.md index 0cdcadf..fd6304e 100755 --- a/docs/description/empty_xctest_method.md +++ b/docs/description/empty_xctest_method.md @@ -8,7 +8,7 @@ Empty XCTest method should be avoided. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** warning, test_parent_classes: ["QuickSpec", "XCTestCase"] ## Non Triggering Examples diff --git a/docs/description/shorthand_operator.md b/docs/description/shorthand_operator.md index 6b3a834..cac88a2 100755 --- a/docs/description/shorthand_operator.md +++ b/docs/description/shorthand_operator.md @@ -44,6 +44,12 @@ foo = aMethod(foo - bar) foo = aMethod(bar - foo) ``` +```swift +public func -= (lhs: inout Foo, rhs: Int) { + lhs = lhs - rhs +} +``` + ```swift foo /= 1 ``` @@ -76,6 +82,12 @@ foo = aMethod(foo / bar) foo = aMethod(bar / foo) ``` +```swift +public func /= (lhs: inout Foo, rhs: Int) { + lhs = lhs / rhs +} +``` + ```swift foo += 1 ``` @@ -108,6 +120,12 @@ foo = aMethod(foo + bar) foo = aMethod(bar + foo) ``` +```swift +public func += (lhs: inout Foo, rhs: Int) { + lhs = lhs + rhs +} +``` + ```swift foo *= 1 ``` @@ -140,6 +158,12 @@ foo = aMethod(foo * bar) foo = aMethod(bar * foo) ``` +```swift +public func *= (lhs: inout Foo, rhs: Int) { + lhs = lhs * rhs +} +``` + ```swift var helloWorld = "world!" helloWorld = "Hello, " + helloWorld diff --git a/docs/description/single_test_class.md b/docs/description/single_test_class.md index d26504d..2671186 100755 --- a/docs/description/single_test_class.md +++ b/docs/description/single_test_class.md @@ -8,7 +8,7 @@ Test files should contain a single QuickSpec or XCTestCase class. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** warning, test_parent_classes: ["QuickSpec", "XCTestCase"] ## Non Triggering Examples diff --git a/docs/description/test_case_accessibility.md b/docs/description/test_case_accessibility.md index 9da0099..4c31c3f 100755 --- a/docs/description/test_case_accessibility.md +++ b/docs/description/test_case_accessibility.md @@ -8,7 +8,7 @@ Test cases should only contain private non-test members. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, allowed_prefixes: [[]], test_parent_classes: [["XCTestCase"]] +* **Default configuration:** warning, allowed_prefixes: [], test_parent_classes: ["QuickSpec", "XCTestCase"] ## Non Triggering Examples diff --git a/docs/description/vertical_whitespace_closing_braces.md b/docs/description/vertical_whitespace_closing_braces.md index bc93e6d..aced085 100755 --- a/docs/description/vertical_whitespace_closing_braces.md +++ b/docs/description/vertical_whitespace_closing_braces.md @@ -13,22 +13,11 @@ Don't include vertical whitespace (empty line) before closing braces. ## Non Triggering Examples ```swift -print([foo { - var sum = 0 - for i in 1...5 { sum += i } - return sum - -}, foo { - var mul = 1 - for i in 1...5 { mul *= i } - return mul -}]) -``` - -```swift -print([ - 1 -]) +func foo() { + run(5) { x in + print(x) + } +} ``` ```swift @@ -51,6 +40,25 @@ do { ] ``` +```swift +print([ + 1 +]) +``` + +```swift +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum + +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul +}]) +``` + ```swift foo( x: 5, @@ -64,14 +72,6 @@ do { } ``` -```swift -func foo() { - run(5) { x in - print(x) - } -} -``` - ```swift [1, 2].map { $0 }.filter { true } ``` @@ -109,31 +109,19 @@ if bool1 { ## Triggering Examples ```swift -print([foo { - var sum = 0 - for i in 1...5 { sum += i } - return sum - -}, foo { - var mul = 1 - for i in 1...5 { mul *= i } - return mul -↓ -}]) -``` - -```swift -print([ - 1 +func foo() { + run(5) { x in + print(x) + } ↓ -]) +} ``` ```swift do { print("x is 5") ↓ - + } ``` @@ -153,6 +141,27 @@ do { ] ``` +```swift +print([ + 1 +↓ +]) +``` + +```swift +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum + +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul +↓ +}]) +``` + ```swift foo( x: 5, @@ -165,15 +174,6 @@ foo( do { print("x is 5") ↓ - -} -``` - -```swift -func foo() { - run(5) { x in - print(x) - } -↓ + } ``` \ No newline at end of file diff --git a/docs/patterns.json b/docs/patterns.json index 3a0b6ea..f7c2004 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -1,6 +1,6 @@ { "name" : "swiftlint", - "version" : "0.50.1", + "version" : "0.50.3", "patterns" : [ { "patternId" : "accessibility_label_for_image", "level" : "Warning", @@ -45,7 +45,7 @@ "enabled" : false }, { "patternId" : "balanced_xctest_lifecycle", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -346,7 +346,7 @@ "enabled" : false }, { "patternId" : "empty_xctest_method", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1193,7 +1193,7 @@ "enabled" : false }, { "patternId" : "single_test_class", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], From a1ab0ec3aa527f7bcb542ad54b404220ac21e7e6 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 5 Jan 2023 15:04:18 +0100 Subject: [PATCH 075/119] Disable doc-generator in CI --- .circleci/config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9b3f380..dbc1eb0 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,9 +22,10 @@ workflows: - run: name: Build Documentation generator command: sbt doc-generator/stage - - run: - name: Run Documentation generator - command: doc-generator/target/universal/stage/bin/doc-generator + # Hangs when run in CI + # - run: + # name: Run Documentation generator + # command: doc-generator/target/universal/stage/bin/doc-generator - run: name: Build Graalvm native-image command: sbt graalvm-native-image:packageBin From 82731e9a8c17fbc111a1298e37187a43c9ed6fe3 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 5 Jan 2023 15:04:27 +0100 Subject: [PATCH 076/119] Update README on how to update docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f6889d..3be48d4 100755 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ docker run -it -v $srcDir:/src : ``` ## Generate docs -Run `amm doc-generator.sc` +Run `sbt doc-generator/run` ## Test From 9867135d6d26cdce4cbae3ba6e9ccb3c548c0f6b Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 5 Jan 2023 15:28:33 +0100 Subject: [PATCH 077/119] fix: Fix doc generation --- .../src/main/scala/doc-generator.scala | 4 +- docs/description/Swift Syntax Dashboard.md | 240 ------------------ docs/description/description.json | 5 - .../vertical_whitespace_closing_braces.md | 106 ++++---- 4 files changed, 56 insertions(+), 299 deletions(-) delete mode 100755 docs/description/Swift Syntax Dashboard.md diff --git a/doc-generator/src/main/scala/doc-generator.scala b/doc-generator/src/main/scala/doc-generator.scala index a438f0e..806d4da 100644 --- a/doc-generator/src/main/scala/doc-generator.scala +++ b/doc-generator/src/main/scala/doc-generator.scala @@ -25,7 +25,9 @@ object Main extends App { val version = os.proc(baseCommand :+ "version").call().out.text().trim - val mdFiles = os.list(tempDir / "rule_docs").filter(_.last != "Rule Directory.md") + val excludeList = Set("Rule Directory.md", "Swift Syntax Dashboard.md") + + val mdFiles = os.list(tempDir / "rule_docs").filterNot(file => excludeList.contains(file.last)) val docsDirectory = os.pwd / "docs" val descriptionDirectory = docsDirectory / "description" diff --git a/docs/description/Swift Syntax Dashboard.md b/docs/description/Swift Syntax Dashboard.md deleted file mode 100755 index d328b2e..0000000 --- a/docs/description/Swift Syntax Dashboard.md +++ /dev/null @@ -1,240 +0,0 @@ -# Swift Syntax Dashboard - -Efforts are actively under way to migrate most rules off SourceKit to use SwiftSyntax instead. - -Rules written using SwiftSyntax tend to be significantly faster and have fewer false positives -than rules that use SourceKit to get source structure information. - -47 out of 215 (21%) -of SwiftLint's linter rules use SourceKit. - -## Rules Using SourceKit - -### Enabled By Default (16) - -* `control_statement`: Control Statement -* `custom_rules`: Custom Rules -* `cyclomatic_complexity`: Cyclomatic Complexity -* `duplicate_imports`: Duplicate Imports -* `file_length`: File Length -* `identifier_name`: Identifier Name -* `line_length`: Line Length -* `mark`: Mark -* `nesting`: Nesting -* `opening_brace`: Opening Brace Spacing -* `redundant_void_return`: Redundant Void Return -* `statement_position`: Statement Position -* `todo`: Todo -* `trailing_whitespace`: Trailing Whitespace -* `vertical_whitespace`: Vertical Whitespace -* `void_return`: Void Return - -### Opt-In (31) - -* `accessibility_label_for_image`: Accessibility Label for Image -* `accessibility_trait_for_button`: Accessibility Trait for Button -* `closure_end_indentation`: Closure End Indentation -* `discouraged_optional_collection`: Discouraged Optional Collection -* `expiring_todo`: Expiring Todo -* `explicit_acl`: Explicit ACL -* `explicit_type_interface`: Explicit Type Interface -* `extension_access_modifier`: Extension Access Modifier -* `file_header`: File Header -* `file_types_order`: File Types Order -* `implicit_return`: Implicit Return -* `indentation_width`: Indentation Width -* `let_var_whitespace`: Variable Declaration Whitespace -* `literal_expression_end_indentation`: Literal Expression End Indentation -* `missing_docs`: Missing Docs -* `modifier_order`: Modifier Order -* `multiline_arguments`: Multiline Arguments -* `multiline_function_chains`: Multiline Function Chains -* `multiline_literal_brackets`: Multiline Literal Brackets -* `multiline_parameters_brackets`: Multiline Parameters Brackets -* `nimble_operator`: Nimble Operator -* `no_grouping_extension`: No Grouping Extension -* `quick_discouraged_call`: Quick Discouraged Call -* `redundant_type_annotation`: Redundant Type Annotation -* `sorted_imports`: Sorted Imports -* `trailing_closure`: Trailing Closure -* `type_contents_order`: Type Contents Order -* `vertical_parameter_alignment_on_call`: Vertical Parameter Alignment On Call -* `vertical_whitespace_between_cases`: Vertical Whitespace Between Cases -* `vertical_whitespace_closing_braces`: Vertical Whitespace before Closing Braces -* `vertical_whitespace_opening_braces`: Vertical Whitespace after Opening Braces - -## Rules Not Using SourceKit - -### Enabled By Default (75) - -* `block_based_kvo`: Block Based KVO -* `class_delegate_protocol`: Class Delegate Protocol -* `closing_brace`: Closing Brace Spacing -* `closure_parameter_position`: Closure Parameter Position -* `colon`: Colon Spacing -* `comma`: Comma Spacing -* `comment_spacing`: Comment Spacing -* `compiler_protocol_init`: Compiler Protocol Init -* `computed_accessors_order`: Computed Accessors Order -* `deployment_target`: Deployment Target -* `discouraged_direct_init`: Discouraged Direct Initialization -* `duplicate_enum_cases`: Duplicate Enum Cases -* `duplicated_key_in_dictionary_literal`: Duplicated Key in Dictionary Literal -* `dynamic_inline`: Dynamic Inline -* `empty_enum_arguments`: Empty Enum Arguments -* `empty_parameters`: Empty Parameters -* `empty_parentheses_with_trailing_closure`: Empty Parentheses with Trailing Closure -* `for_where`: For Where -* `force_cast`: Force Cast -* `force_try`: Force Try -* `function_body_length`: Function Body Length -* `function_parameter_count`: Function Parameter Count -* `generic_type_name`: Generic Type Name -* `implicit_getter`: Implicit Getter -* `inclusive_language`: Inclusive Language -* `inert_defer`: Inert Defer -* `is_disjoint`: Is Disjoint -* `large_tuple`: Large Tuple -* `leading_whitespace`: Leading Whitespace -* `legacy_cggeometry_functions`: Legacy CGGeometry Functions -* `legacy_constant`: Legacy Constant -* `legacy_constructor`: Legacy Constructor -* `legacy_hashing`: Legacy Hashing -* `legacy_nsgeometry_functions`: Legacy NSGeometry Functions -* `legacy_random`: Legacy Random -* `multiple_closures_with_trailing_closure`: Multiple Closures with Trailing Closure -* `no_fallthrough_only`: No Fallthrough Only -* `no_space_in_method_call`: No Space in Method Call -* `notification_center_detachment`: Notification Center Detachment -* `ns_number_init_as_function_reference`: NSNumber Init as Function Reference -* `nsobject_prefer_isequal`: NSObject Prefer isEqual -* `operator_whitespace`: Operator Function Whitespace -* `orphaned_doc_comment`: Orphaned Doc Comment -* `private_over_fileprivate`: Private over fileprivate -* `private_unit_test`: Private Unit Test -* `protocol_property_accessors_order`: Protocol Property Accessors Order -* `reduce_boolean`: Reduce Boolean -* `redundant_discardable_let`: Redundant Discardable Let -* `redundant_objc_attribute`: Redundant @objc Attribute -* `redundant_optional_initialization`: Redundant Optional Initialization -* `redundant_set_access_control`: Redundant Set Access Control Rule -* `redundant_string_enum_value`: Redundant String Enum Value -* `return_arrow_whitespace`: Returning Whitespace -* `self_in_property_initialization`: Self in Property Initialization -* `shorthand_operator`: Shorthand Operator -* `superfluous_disable_command`: Superfluous Disable Command -* `switch_case_alignment`: Switch and Case Statement Alignment -* `syntactic_sugar`: Syntactic Sugar -* `trailing_comma`: Trailing Comma -* `trailing_newline`: Trailing Newline -* `trailing_semicolon`: Trailing Semicolon -* `type_body_length`: Type Body Length -* `type_name`: Type Name -* `unavailable_condition`: Unavailable Condition -* `unneeded_break_in_switch`: Unneeded Break in Switch -* `unused_capture_list`: Unused Capture List -* `unused_closure_parameter`: Unused Closure Parameter -* `unused_control_flow_label`: Unused Control Flow Label -* `unused_enumerated`: Unused Enumerated -* `unused_optional_binding`: Unused Optional Binding -* `unused_setter_value`: Unused Setter Value -* `valid_ibinspectable`: Valid IBInspectable -* `vertical_parameter_alignment`: Vertical Parameter Alignment -* `void_function_in_ternary`: Void Function in Ternary -* `xctfail_message`: XCTFail Message - -### Opt-In (93) - -* `anonymous_argument_in_multiline_closure`: Anonymous Argument in Multiline Closure -* `anyobject_protocol`: AnyObject Protocol -* `array_init`: Array Init -* `attributes`: Attributes -* `balanced_xctest_lifecycle`: Balanced XCTest life-cycle -* `closure_body_length`: Closure Body Length -* `closure_spacing`: Closure Spacing -* `collection_alignment`: Collection Element Alignment -* `comma_inheritance`: Comma Inheritance Rule -* `conditional_returns_on_newline`: Conditional Returns on Newline -* `contains_over_filter_count`: Contains Over Filter Count -* `contains_over_filter_is_empty`: Contains Over Filter Is Empty -* `contains_over_first_not_nil`: Contains over first not nil -* `contains_over_range_nil_comparison`: Contains over range(of:) comparison to nil -* `convenience_type`: Convenience Type -* `discarded_notification_center_observer`: Discarded Notification Center Observer -* `discouraged_assert`: Discouraged Assert -* `discouraged_none_name`: Discouraged None Name -* `discouraged_object_literal`: Discouraged Object Literal -* `discouraged_optional_boolean`: Discouraged Optional Boolean -* `empty_collection_literal`: Empty Collection Literal -* `empty_count`: Empty Count -* `empty_string`: Empty String -* `empty_xctest_method`: Empty XCTest Method -* `enum_case_associated_values_count`: Enum Case Associated Values Count -* `explicit_enum_raw_value`: Explicit Enum Raw Value -* `explicit_init`: Explicit Init -* `explicit_top_level_acl`: Explicit Top Level ACL -* `fallthrough`: Fallthrough -* `fatal_error_message`: Fatal Error Message -* `file_name`: File Name -* `file_name_no_space`: File Name No Space -* `first_where`: First Where -* `flatmap_over_map_reduce`: FlatMap over map and reduce -* `force_unwrapping`: Force Unwrapping -* `function_default_parameter_at_end`: Function Default Parameter at End -* `ibinspectable_in_extension`: IBInspectable in Extension -* `identical_operands`: Identical Operands -* `implicitly_unwrapped_optional`: Implicitly Unwrapped Optional -* `joined_default_parameter`: Joined Default Parameter -* `last_where`: Last Where -* `legacy_multiple`: Legacy Multiple -* `legacy_objc_type`: Legacy Objective-C Reference Type -* `local_doc_comment`: Local Doc Comment -* `lower_acl_than_parent`: Lower ACL than parent -* `multiline_arguments_brackets`: Multiline Arguments Brackets -* `multiline_parameters`: Multiline Parameters -* `no_extension_access_modifier`: No Extension Access Modifier -* `no_magic_numbers`: No Magic Numbers -* `nslocalizedstring_key`: NSLocalizedString Key -* `nslocalizedstring_require_bundle`: NSLocalizedString Require Bundle -* `number_separator`: Number Separator -* `object_literal`: Object Literal -* `operator_usage_whitespace`: Operator Usage Whitespace -* `optional_enum_case_matching`: Optional Enum Case Match -* `overridden_super_call`: Overridden methods call super -* `override_in_extension`: Override in Extension -* `pattern_matching_keywords`: Pattern Matching Keywords -* `prefer_nimble`: Prefer Nimble -* `prefer_self_in_static_references`: Prefer Self in Static References -* `prefer_self_type_over_type_of_self`: Prefer Self Type Over Type of Self -* `prefer_zero_over_explicit_init`: Prefer Zero Over Explicit Init -* `prefixed_toplevel_constant`: Prefixed Top-Level Constant -* `private_action`: Private Actions -* `private_outlet`: Private Outlets -* `private_subject`: Private Combine Subject -* `prohibited_interface_builder`: Prohibited Interface Builder -* `prohibited_super_call`: Prohibited calls to super -* `quick_discouraged_focused_test`: Quick Discouraged Focused Test -* `quick_discouraged_pending_test`: Quick Discouraged Pending Test -* `raw_value_for_camel_cased_codable_enum`: Raw Value For Camel Cased Codable Enum -* `reduce_into`: Reduce Into -* `redundant_nil_coalescing`: Redundant Nil Coalescing -* `required_deinit`: Required Deinit -* `required_enum_case`: Required Enum Case -* `return_value_from_void_function`: Return Value from Void Function -* `self_binding`: Self Binding -* `shorthand_optional_binding`: Shorthand Optional Binding -* `single_test_class`: Single Test Class -* `sorted_first_last`: Min or Max over Sorted First or Last -* `static_operator`: Static Operator -* `strict_fileprivate`: Strict fileprivate -* `strong_iboutlet`: Strong IBOutlet -* `switch_case_on_newline`: Switch Case on Newline -* `test_case_accessibility`: Test case accessibility -* `toggle_bool`: Toggle Bool -* `unavailable_function`: Unavailable Function -* `unneeded_parentheses_in_closure_argument`: Unneeded Parentheses in Closure Argument -* `unowned_variable_capture`: Unowned Variable Capture -* `untyped_error_in_catch`: Untyped Error in Catch -* `weak_delegate`: Weak Delegate -* `xct_specific_matcher`: XCTest Specific Matcher -* `yoda_condition`: Yoda condition rule diff --git a/docs/description/description.json b/docs/description/description.json index 30bea49..7b22d6d 100644 --- a/docs/description/description.json +++ b/docs/description/description.json @@ -1,9 +1,4 @@ [ { - "patternId" : "Swift Syntax Dashboard", - "title" : "Swift Syntax Dashboard", - "description" : "Efforts are actively under way to migrate most rules off SourceKit to use SwiftSyntax instead.", - "parameters" : [ ] -}, { "patternId" : "accessibility_label_for_image", "title" : "Accessibility Label for Image", "description" : "All Images that provide context should have an accessibility label. Purely decorative images can be hidden from accessibility.", diff --git a/docs/description/vertical_whitespace_closing_braces.md b/docs/description/vertical_whitespace_closing_braces.md index aced085..d89731e 100755 --- a/docs/description/vertical_whitespace_closing_braces.md +++ b/docs/description/vertical_whitespace_closing_braces.md @@ -13,10 +13,21 @@ Don't include vertical whitespace (empty line) before closing braces. ## Non Triggering Examples ```swift -func foo() { - run(5) { x in - print(x) - } +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum + +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul +}]) +``` + +```swift +do { + print("x is 5") } ``` @@ -40,25 +51,6 @@ do { ] ``` -```swift -print([ - 1 -]) -``` - -```swift -print([foo { - var sum = 0 - for i in 1...5 { sum += i } - return sum - -}, foo { - var mul = 1 - for i in 1...5 { mul *= i } - return mul -}]) -``` - ```swift foo( x: 5, @@ -67,8 +59,16 @@ foo( ``` ```swift -do { - print("x is 5") +print([ + 1 +]) +``` + +```swift +func foo() { + run(5) { x in + print(x) + } } ``` @@ -109,10 +109,22 @@ if bool1 { ## Triggering Examples ```swift -func foo() { - run(5) { x in - print(x) - } +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum + +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul +↓ +}]) +``` + +```swift +do { + print("x is 5") ↓ } ``` @@ -129,6 +141,7 @@ do { do { print("x is 5") ↓ + } ``` @@ -141,27 +154,6 @@ do { ] ``` -```swift -print([ - 1 -↓ -]) -``` - -```swift -print([foo { - var sum = 0 - for i in 1...5 { sum += i } - return sum - -}, foo { - var mul = 1 - for i in 1...5 { mul *= i } - return mul -↓ -}]) -``` - ```swift foo( x: 5, @@ -171,9 +163,17 @@ foo( ``` ```swift -do { - print("x is 5") +print([ + 1 +↓ +]) +``` + +```swift +func foo() { + run(5) { x in + print(x) + } ↓ - } ``` \ No newline at end of file From c5ad83942cf3e1646a812133f00d8928c22417d2 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 9 Jan 2023 11:44:18 +0100 Subject: [PATCH 078/119] Update doc-generator to run inside docker --- .circleci/config.yml | 7 +++--- .dockerignore | 1 + Dockerfile | 4 ++-- Dockerfile.dev | 9 +++---- build.sbt | 2 +- .../src/main/scala/doc-generator.scala | 24 +++++-------------- 6 files changed, 16 insertions(+), 31 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dbc1eb0..77e0aa6 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,10 +22,9 @@ workflows: - run: name: Build Documentation generator command: sbt doc-generator/stage - # Hangs when run in CI - # - run: - # name: Run Documentation generator - # command: doc-generator/target/universal/stage/bin/doc-generator + - run: + name: Build DEV image (runs doc-generator) + command: docker build -t codacy-swiftlint-dev -f Dockerfile.dev . - run: name: Build Graalvm native-image command: sbt graalvm-native-image:packageBin diff --git a/.dockerignore b/.dockerignore index 45c2e43..7d9f0bb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,6 +4,7 @@ # Allow files and directories !/target/graalvm-native-image/codacy-swiftlint !/target/universal/stage/ +!/doc-generator/target/universal/stage/ !/docs # Ignore unnecessary files inside allowed directories diff --git a/Dockerfile b/Dockerfile index a34398e..410b28f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM norionomura/swiftlint:0.50.3_swift-5.7.0 as builder +FROM codacy-swiftlint-dev as builder FROM swift:5.7.0-jammy-slim COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so -COPY docs /docs +COPY --from=builder /docs /docs COPY target/graalvm-native-image/codacy-swiftlint /workdir/ RUN adduser --uid 2004 --disabled-password --gecos "" docker USER docker diff --git a/Dockerfile.dev b/Dockerfile.dev index 9bbf037..81d3453 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,14 +1,11 @@ -FROM norionomura/swiftlint:0.50.3_swift-5.7.0 as builder - -FROM swift:5.7.0-jammy-slim +FROM norionomura/swiftlint:0.50.3_swift-5.7.0 RUN apt-get update && apt-get install -y openjdk-8-jre-headless -COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint -COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so - COPY docs /docs COPY target/universal/stage/ /workdir/ +COPY doc-generator/target/universal/stage/ /doc-generator +RUN (cd workdir && /doc-generator/bin/doc-generator) RUN chmod +x /workdir/bin/codacy-swiftlint RUN adduser --uid 2004 --disabled-password --gecos "" docker USER docker diff --git a/build.sbt b/build.sbt index f8f80c3..fa78d26 100755 --- a/build.sbt +++ b/build.sbt @@ -7,7 +7,7 @@ ThisBuild / scalaVersion := "2.13.10" enablePlugins(GraalVMNativeImagePlugin) libraryDependencies ++= Seq( - "com.codacy" %% "codacy-engine-scala-seed" % "5.0.1", + "com.codacy" %% "codacy-engine-scala-seed" % "6.0.1", "org.scalameta" %% "svm-subs" % "20.2.0" ) diff --git a/doc-generator/src/main/scala/doc-generator.scala b/doc-generator/src/main/scala/doc-generator.scala index 806d4da..0375b6b 100644 --- a/doc-generator/src/main/scala/doc-generator.scala +++ b/doc-generator/src/main/scala/doc-generator.scala @@ -3,33 +3,21 @@ import com.codacy.plugins.api.results._ import play.api.libs.json.Json object Main extends App { - val tempDir = os.temp.dir(dir = os.pwd / "target") + val tempDir = os.temp.dir() - val workdir = "/workdir" + os.proc("swiftlint", "generate-docs").call(cwd = tempDir) - val baseCommand = Seq( - "docker", - "run", - s"--volume=$tempDir:$workdir", - s"-w=$workdir", - "norionomura/swiftlint:0.50.3_swift-5.7.0", - "swiftlint" - ) - - os.proc(baseCommand :+ "generate-docs").call() -// Hack: docker in CircleCI makes files only available to the root user - os.proc("sudo", "chmod", "-R", "777", tempDir).call() println("Generated docs using swiftlint generate-docs") - val rulesOutput = os.proc(baseCommand :+ "rules").call().out.lines().map(_.split('|').map(_.trim).toList.tail).tail + val rulesOutput = os.proc("swiftlint", "rules").call().out.lines().map(_.split('|').map(_.trim).toList.tail).tail - val version = os.proc(baseCommand :+ "version").call().out.text().trim + val version = os.proc("swiftlint", "version").call().out.text().trim val excludeList = Set("Rule Directory.md", "Swift Syntax Dashboard.md") val mdFiles = os.list(tempDir / "rule_docs").filterNot(file => excludeList.contains(file.last)) - val docsDirectory = os.pwd / "docs" + val docsDirectory = os.root / "docs" val descriptionDirectory = docsDirectory / "description" val patternDescriptions = mdFiles.map { file => @@ -93,7 +81,7 @@ object Main extends App { val specification = Tool.Specification(Tool.Name("swiftlint"), Some(Tool.Version(version)), patternSpecifications.toSet) - os.write.over(os.pwd / "docs" / "patterns.json", Json.prettyPrint(Json.toJson(specification)) + "\n") + os.write.over(docsDirectory / "patterns.json", Json.prettyPrint(Json.toJson(specification)) + "\n") os.remove.all(descriptionDirectory) mdFiles.foreach(os.copy.into(_, descriptionDirectory, replaceExisting = true, createFolders = true)) os.write.over(descriptionDirectory / "description.json", Json.prettyPrint(Json.toJson(patternDescriptions)) + "\n") From e3e69704490f3d71faf990ff5cf12a860a5a953d Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 9 Jan 2023 11:46:02 +0100 Subject: [PATCH 079/119] Use sbt_docker CircleCI job --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 77e0aa6..8cc7b49 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ workflows: jobs: - codacy/checkout_and_version: write_sbt_version: true - - codacy/sbt: + - codacy/sbt_docker: name: publish_docker_local steps: - run: From a986fbaf9acf4a49332c909a5b1123a5ca8a936b Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 9 Jan 2023 11:50:14 +0100 Subject: [PATCH 080/119] build DEV tool --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8cc7b49..03a7bd3 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,6 +19,9 @@ workflows: - run: name: Check Scalafmt on Sbt sources command: sbt scalafmtSbtCheck + - run: + name: Build DEV java tool + command: sbt stage - run: name: Build Documentation generator command: sbt doc-generator/stage From c4d37d9816497d30b5d9638a92f0541c3b87d1a0 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 9 Jan 2023 15:25:49 +0100 Subject: [PATCH 081/119] Migrate to sbt-native-image --- .circleci/config.yml | 2 +- build.sbt | 12 +++++------- project/plugins.sbt | 1 + 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 03a7bd3..2605840 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,7 +30,7 @@ workflows: command: docker build -t codacy-swiftlint-dev -f Dockerfile.dev . - run: name: Build Graalvm native-image - command: sbt graalvm-native-image:packageBin + command: sbt nativeImage - run: name: Build release Docker image command: docker build -t $CIRCLE_PROJECT_REPONAME:latest . diff --git a/build.sbt b/build.sbt index fa78d26..f5b0f6c 100755 --- a/build.sbt +++ b/build.sbt @@ -4,15 +4,13 @@ name := "codacy-swiftlint" ThisBuild / scalaVersion := "2.13.10" -enablePlugins(GraalVMNativeImagePlugin) +enablePlugins(NativeImagePlugin) -libraryDependencies ++= Seq( - "com.codacy" %% "codacy-engine-scala-seed" % "6.0.1", - "org.scalameta" %% "svm-subs" % "20.2.0" -) +libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "6.0.1") + +Compile / mainClass := Some("codacy.Engine") -graalVMNativeImageGraalVersion := Some("21.0.0") -graalVMNativeImageOptions ++= Seq( +nativeImageOptions ++= Seq( "-O1", "-H:+ReportExceptionStackTraces", "--no-fallback", diff --git a/project/plugins.sbt b/project/plugins.sbt index 27833dc..2aebbc7 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,3 @@ addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "24.0.0") addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1") +addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.1") From c971d9f988a80c83b2b4424a9fd8d6bee9d589c6 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 9 Jan 2023 15:36:19 +0100 Subject: [PATCH 082/119] clean circle cache --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2605840..5be5786 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,7 +38,7 @@ workflows: name: Save Docker image to workspace command: docker save --output docker-image.tar $CIRCLE_PROJECT_REPONAME:latest persist_to_workspace: true - cache_prefix: sbt-cache-27102021-3 + cache_prefix: sbt-cache-09012023 requires: - codacy/checkout_and_version - codacy_plugins_test/run: From 2fd52395fb3462ba5cdbbe8be08267a5b22c43d0 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 9 Jan 2023 15:39:09 +0100 Subject: [PATCH 083/119] Add again JavaAppPackaging --- build.sbt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.sbt b/build.sbt index f5b0f6c..3c53f2c 100755 --- a/build.sbt +++ b/build.sbt @@ -6,6 +6,8 @@ ThisBuild / scalaVersion := "2.13.10" enablePlugins(NativeImagePlugin) +enablePlugins(JavaAppPackaging) + libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "6.0.1") Compile / mainClass := Some("codacy.Engine") From 593f0d5f08c2ef8d3ab5a3b59839aebb5073722a Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 9 Jan 2023 15:45:04 +0100 Subject: [PATCH 084/119] Update docs from Docekr --- .../accessibility_label_for_image.md | 0 .../accessibility_trait_for_button.md | 0 ...anonymous_argument_in_multiline_closure.md | 0 docs/description/anyobject_protocol.md | 0 docs/description/array_init.md | 0 docs/description/attributes.md | 0 docs/description/balanced_xctest_lifecycle.md | 0 docs/description/block_based_kvo.md | 0 docs/description/capture_variable.md | 0 docs/description/class_delegate_protocol.md | 0 docs/description/closing_brace.md | 0 docs/description/closure_body_length.md | 0 docs/description/closure_end_indentation.md | 0 .../description/closure_parameter_position.md | 0 docs/description/closure_spacing.md | 0 docs/description/collection_alignment.md | 0 docs/description/colon.md | 0 docs/description/comma.md | 0 docs/description/comma_inheritance.md | 0 docs/description/comment_spacing.md | 0 docs/description/compiler_protocol_init.md | 0 docs/description/computed_accessors_order.md | 0 .../conditional_returns_on_newline.md | 0 .../description/contains_over_filter_count.md | 0 .../contains_over_filter_is_empty.md | 0 .../contains_over_first_not_nil.md | 0 .../contains_over_range_nil_comparison.md | 0 docs/description/control_statement.md | 0 docs/description/convenience_type.md | 0 docs/description/custom_rules.md | 0 docs/description/cyclomatic_complexity.md | 0 docs/description/deployment_target.md | 0 .../discarded_notification_center_observer.md | 0 docs/description/discouraged_assert.md | 0 docs/description/discouraged_direct_init.md | 0 docs/description/discouraged_none_name.md | 0 .../description/discouraged_object_literal.md | 0 .../discouraged_optional_boolean.md | 0 .../discouraged_optional_collection.md | 0 docs/description/duplicate_enum_cases.md | 0 docs/description/duplicate_imports.md | 0 .../duplicated_key_in_dictionary_literal.md | 0 docs/description/dynamic_inline.md | 0 docs/description/empty_collection_literal.md | 0 docs/description/empty_count.md | 0 docs/description/empty_enum_arguments.md | 0 docs/description/empty_parameters.md | 0 ...empty_parentheses_with_trailing_closure.md | 0 docs/description/empty_string.md | 0 docs/description/empty_xctest_method.md | 0 .../enum_case_associated_values_count.md | 0 docs/description/expiring_todo.md | 0 docs/description/explicit_acl.md | 0 docs/description/explicit_enum_raw_value.md | 0 docs/description/explicit_init.md | 0 docs/description/explicit_self.md | 0 docs/description/explicit_top_level_acl.md | 0 docs/description/explicit_type_interface.md | 0 docs/description/extension_access_modifier.md | 0 docs/description/fallthrough.md | 0 docs/description/fatal_error_message.md | 0 docs/description/file_header.md | 0 docs/description/file_length.md | 0 docs/description/file_name.md | 0 docs/description/file_name_no_space.md | 0 docs/description/file_types_order.md | 0 docs/description/first_where.md | 0 docs/description/flatmap_over_map_reduce.md | 0 docs/description/for_where.md | 0 docs/description/force_cast.md | 0 docs/description/force_try.md | 0 docs/description/force_unwrapping.md | 0 docs/description/function_body_length.md | 0 .../function_default_parameter_at_end.md | 0 docs/description/function_parameter_count.md | 0 docs/description/generic_type_name.md | 0 .../description/ibinspectable_in_extension.md | 0 docs/description/identical_operands.md | 0 docs/description/identifier_name.md | 0 docs/description/implicit_getter.md | 0 docs/description/implicit_return.md | 0 .../implicitly_unwrapped_optional.md | 0 docs/description/inclusive_language.md | 0 docs/description/indentation_width.md | 0 docs/description/inert_defer.md | 0 docs/description/is_disjoint.md | 0 docs/description/joined_default_parameter.md | 0 docs/description/large_tuple.md | 0 docs/description/last_where.md | 0 docs/description/leading_whitespace.md | 0 .../legacy_cggeometry_functions.md | 0 docs/description/legacy_constant.md | 0 docs/description/legacy_constructor.md | 0 docs/description/legacy_hashing.md | 0 docs/description/legacy_multiple.md | 0 .../legacy_nsgeometry_functions.md | 0 docs/description/legacy_objc_type.md | 0 docs/description/legacy_random.md | 0 docs/description/let_var_whitespace.md | 0 docs/description/line_length.md | 0 .../literal_expression_end_indentation.md | 0 docs/description/local_doc_comment.md | 0 docs/description/lower_acl_than_parent.md | 0 docs/description/mark.md | 0 docs/description/missing_docs.md | 0 docs/description/modifier_order.md | 0 docs/description/multiline_arguments.md | 0 .../multiline_arguments_brackets.md | 0 docs/description/multiline_function_chains.md | 0 .../description/multiline_literal_brackets.md | 0 docs/description/multiline_parameters.md | 0 .../multiline_parameters_brackets.md | 0 ...multiple_closures_with_trailing_closure.md | 0 docs/description/nesting.md | 0 docs/description/nimble_operator.md | 0 .../no_extension_access_modifier.md | 0 docs/description/no_fallthrough_only.md | 0 docs/description/no_grouping_extension.md | 0 docs/description/no_magic_numbers.md | 0 docs/description/no_space_in_method_call.md | 0 .../notification_center_detachment.md | 0 .../ns_number_init_as_function_reference.md | 0 docs/description/nslocalizedstring_key.md | 0 .../nslocalizedstring_require_bundle.md | 0 docs/description/nsobject_prefer_isequal.md | 0 docs/description/number_separator.md | 0 docs/description/object_literal.md | 0 docs/description/opening_brace.md | 0 docs/description/operator_usage_whitespace.md | 0 docs/description/operator_whitespace.md | 0 .../optional_enum_case_matching.md | 0 docs/description/orphaned_doc_comment.md | 0 docs/description/overridden_super_call.md | 0 docs/description/override_in_extension.md | 0 docs/description/pattern_matching_keywords.md | 0 docs/description/prefer_nimble.md | 0 .../prefer_self_in_static_references.md | 0 .../prefer_self_type_over_type_of_self.md | 0 .../prefer_zero_over_explicit_init.md | 0 .../description/prefixed_toplevel_constant.md | 0 docs/description/private_action.md | 0 docs/description/private_outlet.md | 0 docs/description/private_over_fileprivate.md | 0 docs/description/private_subject.md | 0 docs/description/private_unit_test.md | 0 .../prohibited_interface_builder.md | 0 docs/description/prohibited_super_call.md | 0 .../protocol_property_accessors_order.md | 0 docs/description/quick_discouraged_call.md | 0 .../quick_discouraged_focused_test.md | 0 .../quick_discouraged_pending_test.md | 0 .../raw_value_for_camel_cased_codable_enum.md | 0 docs/description/reduce_boolean.md | 0 docs/description/reduce_into.md | 0 docs/description/redundant_discardable_let.md | 0 docs/description/redundant_nil_coalescing.md | 0 docs/description/redundant_objc_attribute.md | 0 .../redundant_optional_initialization.md | 0 .../redundant_set_access_control.md | 0 .../redundant_string_enum_value.md | 0 docs/description/redundant_type_annotation.md | 0 docs/description/redundant_void_return.md | 0 docs/description/required_deinit.md | 0 docs/description/required_enum_case.md | 0 docs/description/return_arrow_whitespace.md | 0 .../return_value_from_void_function.md | 0 docs/description/self_binding.md | 0 .../self_in_property_initialization.md | 0 docs/description/shorthand_operator.md | 0 .../description/shorthand_optional_binding.md | 0 docs/description/single_test_class.md | 0 docs/description/sorted_first_last.md | 0 docs/description/sorted_imports.md | 0 docs/description/statement_position.md | 0 docs/description/static_operator.md | 0 docs/description/strict_fileprivate.md | 0 docs/description/strong_iboutlet.md | 0 .../superfluous_disable_command.md | 0 docs/description/switch_case_alignment.md | 0 docs/description/switch_case_on_newline.md | 0 docs/description/syntactic_sugar.md | 0 docs/description/test_case_accessibility.md | 0 docs/description/todo.md | 0 docs/description/toggle_bool.md | 0 docs/description/trailing_closure.md | 0 docs/description/trailing_comma.md | 0 docs/description/trailing_newline.md | 0 docs/description/trailing_semicolon.md | 0 docs/description/trailing_whitespace.md | 0 docs/description/type_body_length.md | 0 docs/description/type_contents_order.md | 0 docs/description/type_name.md | 0 docs/description/typesafe_array_init.md | 0 docs/description/unavailable_condition.md | 0 docs/description/unavailable_function.md | 0 docs/description/unneeded_break_in_switch.md | 0 ...nneeded_parentheses_in_closure_argument.md | 0 docs/description/unowned_variable_capture.md | 0 docs/description/untyped_error_in_catch.md | 0 docs/description/unused_capture_list.md | 0 docs/description/unused_closure_parameter.md | 0 docs/description/unused_control_flow_label.md | 0 docs/description/unused_declaration.md | 0 docs/description/unused_enumerated.md | 0 docs/description/unused_import.md | 0 docs/description/unused_optional_binding.md | 0 docs/description/unused_setter_value.md | 0 docs/description/valid_ibinspectable.md | 0 .../vertical_parameter_alignment.md | 0 .../vertical_parameter_alignment_on_call.md | 0 docs/description/vertical_whitespace.md | 0 .../vertical_whitespace_between_cases.md | 0 .../vertical_whitespace_closing_braces.md | 118 +++++++++--------- .../vertical_whitespace_opening_braces.md | 0 docs/description/void_function_in_ternary.md | 0 docs/description/void_return.md | 0 docs/description/weak_delegate.md | 0 docs/description/xct_specific_matcher.md | 0 docs/description/xctfail_message.md | 0 docs/description/yoda_condition.md | 0 220 files changed, 59 insertions(+), 59 deletions(-) mode change 100755 => 100644 docs/description/accessibility_label_for_image.md mode change 100755 => 100644 docs/description/accessibility_trait_for_button.md mode change 100755 => 100644 docs/description/anonymous_argument_in_multiline_closure.md mode change 100755 => 100644 docs/description/anyobject_protocol.md mode change 100755 => 100644 docs/description/array_init.md mode change 100755 => 100644 docs/description/attributes.md mode change 100755 => 100644 docs/description/balanced_xctest_lifecycle.md mode change 100755 => 100644 docs/description/block_based_kvo.md mode change 100755 => 100644 docs/description/capture_variable.md mode change 100755 => 100644 docs/description/class_delegate_protocol.md mode change 100755 => 100644 docs/description/closing_brace.md mode change 100755 => 100644 docs/description/closure_body_length.md mode change 100755 => 100644 docs/description/closure_end_indentation.md mode change 100755 => 100644 docs/description/closure_parameter_position.md mode change 100755 => 100644 docs/description/closure_spacing.md mode change 100755 => 100644 docs/description/collection_alignment.md mode change 100755 => 100644 docs/description/colon.md mode change 100755 => 100644 docs/description/comma.md mode change 100755 => 100644 docs/description/comma_inheritance.md mode change 100755 => 100644 docs/description/comment_spacing.md mode change 100755 => 100644 docs/description/compiler_protocol_init.md mode change 100755 => 100644 docs/description/computed_accessors_order.md mode change 100755 => 100644 docs/description/conditional_returns_on_newline.md mode change 100755 => 100644 docs/description/contains_over_filter_count.md mode change 100755 => 100644 docs/description/contains_over_filter_is_empty.md mode change 100755 => 100644 docs/description/contains_over_first_not_nil.md mode change 100755 => 100644 docs/description/contains_over_range_nil_comparison.md mode change 100755 => 100644 docs/description/control_statement.md mode change 100755 => 100644 docs/description/convenience_type.md mode change 100755 => 100644 docs/description/custom_rules.md mode change 100755 => 100644 docs/description/cyclomatic_complexity.md mode change 100755 => 100644 docs/description/deployment_target.md mode change 100755 => 100644 docs/description/discarded_notification_center_observer.md mode change 100755 => 100644 docs/description/discouraged_assert.md mode change 100755 => 100644 docs/description/discouraged_direct_init.md mode change 100755 => 100644 docs/description/discouraged_none_name.md mode change 100755 => 100644 docs/description/discouraged_object_literal.md mode change 100755 => 100644 docs/description/discouraged_optional_boolean.md mode change 100755 => 100644 docs/description/discouraged_optional_collection.md mode change 100755 => 100644 docs/description/duplicate_enum_cases.md mode change 100755 => 100644 docs/description/duplicate_imports.md mode change 100755 => 100644 docs/description/duplicated_key_in_dictionary_literal.md mode change 100755 => 100644 docs/description/dynamic_inline.md mode change 100755 => 100644 docs/description/empty_collection_literal.md mode change 100755 => 100644 docs/description/empty_count.md mode change 100755 => 100644 docs/description/empty_enum_arguments.md mode change 100755 => 100644 docs/description/empty_parameters.md mode change 100755 => 100644 docs/description/empty_parentheses_with_trailing_closure.md mode change 100755 => 100644 docs/description/empty_string.md mode change 100755 => 100644 docs/description/empty_xctest_method.md mode change 100755 => 100644 docs/description/enum_case_associated_values_count.md mode change 100755 => 100644 docs/description/expiring_todo.md mode change 100755 => 100644 docs/description/explicit_acl.md mode change 100755 => 100644 docs/description/explicit_enum_raw_value.md mode change 100755 => 100644 docs/description/explicit_init.md mode change 100755 => 100644 docs/description/explicit_self.md mode change 100755 => 100644 docs/description/explicit_top_level_acl.md mode change 100755 => 100644 docs/description/explicit_type_interface.md mode change 100755 => 100644 docs/description/extension_access_modifier.md mode change 100755 => 100644 docs/description/fallthrough.md mode change 100755 => 100644 docs/description/fatal_error_message.md mode change 100755 => 100644 docs/description/file_header.md mode change 100755 => 100644 docs/description/file_length.md mode change 100755 => 100644 docs/description/file_name.md mode change 100755 => 100644 docs/description/file_name_no_space.md mode change 100755 => 100644 docs/description/file_types_order.md mode change 100755 => 100644 docs/description/first_where.md mode change 100755 => 100644 docs/description/flatmap_over_map_reduce.md mode change 100755 => 100644 docs/description/for_where.md mode change 100755 => 100644 docs/description/force_cast.md mode change 100755 => 100644 docs/description/force_try.md mode change 100755 => 100644 docs/description/force_unwrapping.md mode change 100755 => 100644 docs/description/function_body_length.md mode change 100755 => 100644 docs/description/function_default_parameter_at_end.md mode change 100755 => 100644 docs/description/function_parameter_count.md mode change 100755 => 100644 docs/description/generic_type_name.md mode change 100755 => 100644 docs/description/ibinspectable_in_extension.md mode change 100755 => 100644 docs/description/identical_operands.md mode change 100755 => 100644 docs/description/identifier_name.md mode change 100755 => 100644 docs/description/implicit_getter.md mode change 100755 => 100644 docs/description/implicit_return.md mode change 100755 => 100644 docs/description/implicitly_unwrapped_optional.md mode change 100755 => 100644 docs/description/inclusive_language.md mode change 100755 => 100644 docs/description/indentation_width.md mode change 100755 => 100644 docs/description/inert_defer.md mode change 100755 => 100644 docs/description/is_disjoint.md mode change 100755 => 100644 docs/description/joined_default_parameter.md mode change 100755 => 100644 docs/description/large_tuple.md mode change 100755 => 100644 docs/description/last_where.md mode change 100755 => 100644 docs/description/leading_whitespace.md mode change 100755 => 100644 docs/description/legacy_cggeometry_functions.md mode change 100755 => 100644 docs/description/legacy_constant.md mode change 100755 => 100644 docs/description/legacy_constructor.md mode change 100755 => 100644 docs/description/legacy_hashing.md mode change 100755 => 100644 docs/description/legacy_multiple.md mode change 100755 => 100644 docs/description/legacy_nsgeometry_functions.md mode change 100755 => 100644 docs/description/legacy_objc_type.md mode change 100755 => 100644 docs/description/legacy_random.md mode change 100755 => 100644 docs/description/let_var_whitespace.md mode change 100755 => 100644 docs/description/line_length.md mode change 100755 => 100644 docs/description/literal_expression_end_indentation.md mode change 100755 => 100644 docs/description/local_doc_comment.md mode change 100755 => 100644 docs/description/lower_acl_than_parent.md mode change 100755 => 100644 docs/description/mark.md mode change 100755 => 100644 docs/description/missing_docs.md mode change 100755 => 100644 docs/description/modifier_order.md mode change 100755 => 100644 docs/description/multiline_arguments.md mode change 100755 => 100644 docs/description/multiline_arguments_brackets.md mode change 100755 => 100644 docs/description/multiline_function_chains.md mode change 100755 => 100644 docs/description/multiline_literal_brackets.md mode change 100755 => 100644 docs/description/multiline_parameters.md mode change 100755 => 100644 docs/description/multiline_parameters_brackets.md mode change 100755 => 100644 docs/description/multiple_closures_with_trailing_closure.md mode change 100755 => 100644 docs/description/nesting.md mode change 100755 => 100644 docs/description/nimble_operator.md mode change 100755 => 100644 docs/description/no_extension_access_modifier.md mode change 100755 => 100644 docs/description/no_fallthrough_only.md mode change 100755 => 100644 docs/description/no_grouping_extension.md mode change 100755 => 100644 docs/description/no_magic_numbers.md mode change 100755 => 100644 docs/description/no_space_in_method_call.md mode change 100755 => 100644 docs/description/notification_center_detachment.md mode change 100755 => 100644 docs/description/ns_number_init_as_function_reference.md mode change 100755 => 100644 docs/description/nslocalizedstring_key.md mode change 100755 => 100644 docs/description/nslocalizedstring_require_bundle.md mode change 100755 => 100644 docs/description/nsobject_prefer_isequal.md mode change 100755 => 100644 docs/description/number_separator.md mode change 100755 => 100644 docs/description/object_literal.md mode change 100755 => 100644 docs/description/opening_brace.md mode change 100755 => 100644 docs/description/operator_usage_whitespace.md mode change 100755 => 100644 docs/description/operator_whitespace.md mode change 100755 => 100644 docs/description/optional_enum_case_matching.md mode change 100755 => 100644 docs/description/orphaned_doc_comment.md mode change 100755 => 100644 docs/description/overridden_super_call.md mode change 100755 => 100644 docs/description/override_in_extension.md mode change 100755 => 100644 docs/description/pattern_matching_keywords.md mode change 100755 => 100644 docs/description/prefer_nimble.md mode change 100755 => 100644 docs/description/prefer_self_in_static_references.md mode change 100755 => 100644 docs/description/prefer_self_type_over_type_of_self.md mode change 100755 => 100644 docs/description/prefer_zero_over_explicit_init.md mode change 100755 => 100644 docs/description/prefixed_toplevel_constant.md mode change 100755 => 100644 docs/description/private_action.md mode change 100755 => 100644 docs/description/private_outlet.md mode change 100755 => 100644 docs/description/private_over_fileprivate.md mode change 100755 => 100644 docs/description/private_subject.md mode change 100755 => 100644 docs/description/private_unit_test.md mode change 100755 => 100644 docs/description/prohibited_interface_builder.md mode change 100755 => 100644 docs/description/prohibited_super_call.md mode change 100755 => 100644 docs/description/protocol_property_accessors_order.md mode change 100755 => 100644 docs/description/quick_discouraged_call.md mode change 100755 => 100644 docs/description/quick_discouraged_focused_test.md mode change 100755 => 100644 docs/description/quick_discouraged_pending_test.md mode change 100755 => 100644 docs/description/raw_value_for_camel_cased_codable_enum.md mode change 100755 => 100644 docs/description/reduce_boolean.md mode change 100755 => 100644 docs/description/reduce_into.md mode change 100755 => 100644 docs/description/redundant_discardable_let.md mode change 100755 => 100644 docs/description/redundant_nil_coalescing.md mode change 100755 => 100644 docs/description/redundant_objc_attribute.md mode change 100755 => 100644 docs/description/redundant_optional_initialization.md mode change 100755 => 100644 docs/description/redundant_set_access_control.md mode change 100755 => 100644 docs/description/redundant_string_enum_value.md mode change 100755 => 100644 docs/description/redundant_type_annotation.md mode change 100755 => 100644 docs/description/redundant_void_return.md mode change 100755 => 100644 docs/description/required_deinit.md mode change 100755 => 100644 docs/description/required_enum_case.md mode change 100755 => 100644 docs/description/return_arrow_whitespace.md mode change 100755 => 100644 docs/description/return_value_from_void_function.md mode change 100755 => 100644 docs/description/self_binding.md mode change 100755 => 100644 docs/description/self_in_property_initialization.md mode change 100755 => 100644 docs/description/shorthand_operator.md mode change 100755 => 100644 docs/description/shorthand_optional_binding.md mode change 100755 => 100644 docs/description/single_test_class.md mode change 100755 => 100644 docs/description/sorted_first_last.md mode change 100755 => 100644 docs/description/sorted_imports.md mode change 100755 => 100644 docs/description/statement_position.md mode change 100755 => 100644 docs/description/static_operator.md mode change 100755 => 100644 docs/description/strict_fileprivate.md mode change 100755 => 100644 docs/description/strong_iboutlet.md mode change 100755 => 100644 docs/description/superfluous_disable_command.md mode change 100755 => 100644 docs/description/switch_case_alignment.md mode change 100755 => 100644 docs/description/switch_case_on_newline.md mode change 100755 => 100644 docs/description/syntactic_sugar.md mode change 100755 => 100644 docs/description/test_case_accessibility.md mode change 100755 => 100644 docs/description/todo.md mode change 100755 => 100644 docs/description/toggle_bool.md mode change 100755 => 100644 docs/description/trailing_closure.md mode change 100755 => 100644 docs/description/trailing_comma.md mode change 100755 => 100644 docs/description/trailing_newline.md mode change 100755 => 100644 docs/description/trailing_semicolon.md mode change 100755 => 100644 docs/description/trailing_whitespace.md mode change 100755 => 100644 docs/description/type_body_length.md mode change 100755 => 100644 docs/description/type_contents_order.md mode change 100755 => 100644 docs/description/type_name.md mode change 100755 => 100644 docs/description/typesafe_array_init.md mode change 100755 => 100644 docs/description/unavailable_condition.md mode change 100755 => 100644 docs/description/unavailable_function.md mode change 100755 => 100644 docs/description/unneeded_break_in_switch.md mode change 100755 => 100644 docs/description/unneeded_parentheses_in_closure_argument.md mode change 100755 => 100644 docs/description/unowned_variable_capture.md mode change 100755 => 100644 docs/description/untyped_error_in_catch.md mode change 100755 => 100644 docs/description/unused_capture_list.md mode change 100755 => 100644 docs/description/unused_closure_parameter.md mode change 100755 => 100644 docs/description/unused_control_flow_label.md mode change 100755 => 100644 docs/description/unused_declaration.md mode change 100755 => 100644 docs/description/unused_enumerated.md mode change 100755 => 100644 docs/description/unused_import.md mode change 100755 => 100644 docs/description/unused_optional_binding.md mode change 100755 => 100644 docs/description/unused_setter_value.md mode change 100755 => 100644 docs/description/valid_ibinspectable.md mode change 100755 => 100644 docs/description/vertical_parameter_alignment.md mode change 100755 => 100644 docs/description/vertical_parameter_alignment_on_call.md mode change 100755 => 100644 docs/description/vertical_whitespace.md mode change 100755 => 100644 docs/description/vertical_whitespace_between_cases.md mode change 100755 => 100644 docs/description/vertical_whitespace_closing_braces.md mode change 100755 => 100644 docs/description/vertical_whitespace_opening_braces.md mode change 100755 => 100644 docs/description/void_function_in_ternary.md mode change 100755 => 100644 docs/description/void_return.md mode change 100755 => 100644 docs/description/weak_delegate.md mode change 100755 => 100644 docs/description/xct_specific_matcher.md mode change 100755 => 100644 docs/description/xctfail_message.md mode change 100755 => 100644 docs/description/yoda_condition.md diff --git a/docs/description/accessibility_label_for_image.md b/docs/description/accessibility_label_for_image.md old mode 100755 new mode 100644 diff --git a/docs/description/accessibility_trait_for_button.md b/docs/description/accessibility_trait_for_button.md old mode 100755 new mode 100644 diff --git a/docs/description/anonymous_argument_in_multiline_closure.md b/docs/description/anonymous_argument_in_multiline_closure.md old mode 100755 new mode 100644 diff --git a/docs/description/anyobject_protocol.md b/docs/description/anyobject_protocol.md old mode 100755 new mode 100644 diff --git a/docs/description/array_init.md b/docs/description/array_init.md old mode 100755 new mode 100644 diff --git a/docs/description/attributes.md b/docs/description/attributes.md old mode 100755 new mode 100644 diff --git a/docs/description/balanced_xctest_lifecycle.md b/docs/description/balanced_xctest_lifecycle.md old mode 100755 new mode 100644 diff --git a/docs/description/block_based_kvo.md b/docs/description/block_based_kvo.md old mode 100755 new mode 100644 diff --git a/docs/description/capture_variable.md b/docs/description/capture_variable.md old mode 100755 new mode 100644 diff --git a/docs/description/class_delegate_protocol.md b/docs/description/class_delegate_protocol.md old mode 100755 new mode 100644 diff --git a/docs/description/closing_brace.md b/docs/description/closing_brace.md old mode 100755 new mode 100644 diff --git a/docs/description/closure_body_length.md b/docs/description/closure_body_length.md old mode 100755 new mode 100644 diff --git a/docs/description/closure_end_indentation.md b/docs/description/closure_end_indentation.md old mode 100755 new mode 100644 diff --git a/docs/description/closure_parameter_position.md b/docs/description/closure_parameter_position.md old mode 100755 new mode 100644 diff --git a/docs/description/closure_spacing.md b/docs/description/closure_spacing.md old mode 100755 new mode 100644 diff --git a/docs/description/collection_alignment.md b/docs/description/collection_alignment.md old mode 100755 new mode 100644 diff --git a/docs/description/colon.md b/docs/description/colon.md old mode 100755 new mode 100644 diff --git a/docs/description/comma.md b/docs/description/comma.md old mode 100755 new mode 100644 diff --git a/docs/description/comma_inheritance.md b/docs/description/comma_inheritance.md old mode 100755 new mode 100644 diff --git a/docs/description/comment_spacing.md b/docs/description/comment_spacing.md old mode 100755 new mode 100644 diff --git a/docs/description/compiler_protocol_init.md b/docs/description/compiler_protocol_init.md old mode 100755 new mode 100644 diff --git a/docs/description/computed_accessors_order.md b/docs/description/computed_accessors_order.md old mode 100755 new mode 100644 diff --git a/docs/description/conditional_returns_on_newline.md b/docs/description/conditional_returns_on_newline.md old mode 100755 new mode 100644 diff --git a/docs/description/contains_over_filter_count.md b/docs/description/contains_over_filter_count.md old mode 100755 new mode 100644 diff --git a/docs/description/contains_over_filter_is_empty.md b/docs/description/contains_over_filter_is_empty.md old mode 100755 new mode 100644 diff --git a/docs/description/contains_over_first_not_nil.md b/docs/description/contains_over_first_not_nil.md old mode 100755 new mode 100644 diff --git a/docs/description/contains_over_range_nil_comparison.md b/docs/description/contains_over_range_nil_comparison.md old mode 100755 new mode 100644 diff --git a/docs/description/control_statement.md b/docs/description/control_statement.md old mode 100755 new mode 100644 diff --git a/docs/description/convenience_type.md b/docs/description/convenience_type.md old mode 100755 new mode 100644 diff --git a/docs/description/custom_rules.md b/docs/description/custom_rules.md old mode 100755 new mode 100644 diff --git a/docs/description/cyclomatic_complexity.md b/docs/description/cyclomatic_complexity.md old mode 100755 new mode 100644 diff --git a/docs/description/deployment_target.md b/docs/description/deployment_target.md old mode 100755 new mode 100644 diff --git a/docs/description/discarded_notification_center_observer.md b/docs/description/discarded_notification_center_observer.md old mode 100755 new mode 100644 diff --git a/docs/description/discouraged_assert.md b/docs/description/discouraged_assert.md old mode 100755 new mode 100644 diff --git a/docs/description/discouraged_direct_init.md b/docs/description/discouraged_direct_init.md old mode 100755 new mode 100644 diff --git a/docs/description/discouraged_none_name.md b/docs/description/discouraged_none_name.md old mode 100755 new mode 100644 diff --git a/docs/description/discouraged_object_literal.md b/docs/description/discouraged_object_literal.md old mode 100755 new mode 100644 diff --git a/docs/description/discouraged_optional_boolean.md b/docs/description/discouraged_optional_boolean.md old mode 100755 new mode 100644 diff --git a/docs/description/discouraged_optional_collection.md b/docs/description/discouraged_optional_collection.md old mode 100755 new mode 100644 diff --git a/docs/description/duplicate_enum_cases.md b/docs/description/duplicate_enum_cases.md old mode 100755 new mode 100644 diff --git a/docs/description/duplicate_imports.md b/docs/description/duplicate_imports.md old mode 100755 new mode 100644 diff --git a/docs/description/duplicated_key_in_dictionary_literal.md b/docs/description/duplicated_key_in_dictionary_literal.md old mode 100755 new mode 100644 diff --git a/docs/description/dynamic_inline.md b/docs/description/dynamic_inline.md old mode 100755 new mode 100644 diff --git a/docs/description/empty_collection_literal.md b/docs/description/empty_collection_literal.md old mode 100755 new mode 100644 diff --git a/docs/description/empty_count.md b/docs/description/empty_count.md old mode 100755 new mode 100644 diff --git a/docs/description/empty_enum_arguments.md b/docs/description/empty_enum_arguments.md old mode 100755 new mode 100644 diff --git a/docs/description/empty_parameters.md b/docs/description/empty_parameters.md old mode 100755 new mode 100644 diff --git a/docs/description/empty_parentheses_with_trailing_closure.md b/docs/description/empty_parentheses_with_trailing_closure.md old mode 100755 new mode 100644 diff --git a/docs/description/empty_string.md b/docs/description/empty_string.md old mode 100755 new mode 100644 diff --git a/docs/description/empty_xctest_method.md b/docs/description/empty_xctest_method.md old mode 100755 new mode 100644 diff --git a/docs/description/enum_case_associated_values_count.md b/docs/description/enum_case_associated_values_count.md old mode 100755 new mode 100644 diff --git a/docs/description/expiring_todo.md b/docs/description/expiring_todo.md old mode 100755 new mode 100644 diff --git a/docs/description/explicit_acl.md b/docs/description/explicit_acl.md old mode 100755 new mode 100644 diff --git a/docs/description/explicit_enum_raw_value.md b/docs/description/explicit_enum_raw_value.md old mode 100755 new mode 100644 diff --git a/docs/description/explicit_init.md b/docs/description/explicit_init.md old mode 100755 new mode 100644 diff --git a/docs/description/explicit_self.md b/docs/description/explicit_self.md old mode 100755 new mode 100644 diff --git a/docs/description/explicit_top_level_acl.md b/docs/description/explicit_top_level_acl.md old mode 100755 new mode 100644 diff --git a/docs/description/explicit_type_interface.md b/docs/description/explicit_type_interface.md old mode 100755 new mode 100644 diff --git a/docs/description/extension_access_modifier.md b/docs/description/extension_access_modifier.md old mode 100755 new mode 100644 diff --git a/docs/description/fallthrough.md b/docs/description/fallthrough.md old mode 100755 new mode 100644 diff --git a/docs/description/fatal_error_message.md b/docs/description/fatal_error_message.md old mode 100755 new mode 100644 diff --git a/docs/description/file_header.md b/docs/description/file_header.md old mode 100755 new mode 100644 diff --git a/docs/description/file_length.md b/docs/description/file_length.md old mode 100755 new mode 100644 diff --git a/docs/description/file_name.md b/docs/description/file_name.md old mode 100755 new mode 100644 diff --git a/docs/description/file_name_no_space.md b/docs/description/file_name_no_space.md old mode 100755 new mode 100644 diff --git a/docs/description/file_types_order.md b/docs/description/file_types_order.md old mode 100755 new mode 100644 diff --git a/docs/description/first_where.md b/docs/description/first_where.md old mode 100755 new mode 100644 diff --git a/docs/description/flatmap_over_map_reduce.md b/docs/description/flatmap_over_map_reduce.md old mode 100755 new mode 100644 diff --git a/docs/description/for_where.md b/docs/description/for_where.md old mode 100755 new mode 100644 diff --git a/docs/description/force_cast.md b/docs/description/force_cast.md old mode 100755 new mode 100644 diff --git a/docs/description/force_try.md b/docs/description/force_try.md old mode 100755 new mode 100644 diff --git a/docs/description/force_unwrapping.md b/docs/description/force_unwrapping.md old mode 100755 new mode 100644 diff --git a/docs/description/function_body_length.md b/docs/description/function_body_length.md old mode 100755 new mode 100644 diff --git a/docs/description/function_default_parameter_at_end.md b/docs/description/function_default_parameter_at_end.md old mode 100755 new mode 100644 diff --git a/docs/description/function_parameter_count.md b/docs/description/function_parameter_count.md old mode 100755 new mode 100644 diff --git a/docs/description/generic_type_name.md b/docs/description/generic_type_name.md old mode 100755 new mode 100644 diff --git a/docs/description/ibinspectable_in_extension.md b/docs/description/ibinspectable_in_extension.md old mode 100755 new mode 100644 diff --git a/docs/description/identical_operands.md b/docs/description/identical_operands.md old mode 100755 new mode 100644 diff --git a/docs/description/identifier_name.md b/docs/description/identifier_name.md old mode 100755 new mode 100644 diff --git a/docs/description/implicit_getter.md b/docs/description/implicit_getter.md old mode 100755 new mode 100644 diff --git a/docs/description/implicit_return.md b/docs/description/implicit_return.md old mode 100755 new mode 100644 diff --git a/docs/description/implicitly_unwrapped_optional.md b/docs/description/implicitly_unwrapped_optional.md old mode 100755 new mode 100644 diff --git a/docs/description/inclusive_language.md b/docs/description/inclusive_language.md old mode 100755 new mode 100644 diff --git a/docs/description/indentation_width.md b/docs/description/indentation_width.md old mode 100755 new mode 100644 diff --git a/docs/description/inert_defer.md b/docs/description/inert_defer.md old mode 100755 new mode 100644 diff --git a/docs/description/is_disjoint.md b/docs/description/is_disjoint.md old mode 100755 new mode 100644 diff --git a/docs/description/joined_default_parameter.md b/docs/description/joined_default_parameter.md old mode 100755 new mode 100644 diff --git a/docs/description/large_tuple.md b/docs/description/large_tuple.md old mode 100755 new mode 100644 diff --git a/docs/description/last_where.md b/docs/description/last_where.md old mode 100755 new mode 100644 diff --git a/docs/description/leading_whitespace.md b/docs/description/leading_whitespace.md old mode 100755 new mode 100644 diff --git a/docs/description/legacy_cggeometry_functions.md b/docs/description/legacy_cggeometry_functions.md old mode 100755 new mode 100644 diff --git a/docs/description/legacy_constant.md b/docs/description/legacy_constant.md old mode 100755 new mode 100644 diff --git a/docs/description/legacy_constructor.md b/docs/description/legacy_constructor.md old mode 100755 new mode 100644 diff --git a/docs/description/legacy_hashing.md b/docs/description/legacy_hashing.md old mode 100755 new mode 100644 diff --git a/docs/description/legacy_multiple.md b/docs/description/legacy_multiple.md old mode 100755 new mode 100644 diff --git a/docs/description/legacy_nsgeometry_functions.md b/docs/description/legacy_nsgeometry_functions.md old mode 100755 new mode 100644 diff --git a/docs/description/legacy_objc_type.md b/docs/description/legacy_objc_type.md old mode 100755 new mode 100644 diff --git a/docs/description/legacy_random.md b/docs/description/legacy_random.md old mode 100755 new mode 100644 diff --git a/docs/description/let_var_whitespace.md b/docs/description/let_var_whitespace.md old mode 100755 new mode 100644 diff --git a/docs/description/line_length.md b/docs/description/line_length.md old mode 100755 new mode 100644 diff --git a/docs/description/literal_expression_end_indentation.md b/docs/description/literal_expression_end_indentation.md old mode 100755 new mode 100644 diff --git a/docs/description/local_doc_comment.md b/docs/description/local_doc_comment.md old mode 100755 new mode 100644 diff --git a/docs/description/lower_acl_than_parent.md b/docs/description/lower_acl_than_parent.md old mode 100755 new mode 100644 diff --git a/docs/description/mark.md b/docs/description/mark.md old mode 100755 new mode 100644 diff --git a/docs/description/missing_docs.md b/docs/description/missing_docs.md old mode 100755 new mode 100644 diff --git a/docs/description/modifier_order.md b/docs/description/modifier_order.md old mode 100755 new mode 100644 diff --git a/docs/description/multiline_arguments.md b/docs/description/multiline_arguments.md old mode 100755 new mode 100644 diff --git a/docs/description/multiline_arguments_brackets.md b/docs/description/multiline_arguments_brackets.md old mode 100755 new mode 100644 diff --git a/docs/description/multiline_function_chains.md b/docs/description/multiline_function_chains.md old mode 100755 new mode 100644 diff --git a/docs/description/multiline_literal_brackets.md b/docs/description/multiline_literal_brackets.md old mode 100755 new mode 100644 diff --git a/docs/description/multiline_parameters.md b/docs/description/multiline_parameters.md old mode 100755 new mode 100644 diff --git a/docs/description/multiline_parameters_brackets.md b/docs/description/multiline_parameters_brackets.md old mode 100755 new mode 100644 diff --git a/docs/description/multiple_closures_with_trailing_closure.md b/docs/description/multiple_closures_with_trailing_closure.md old mode 100755 new mode 100644 diff --git a/docs/description/nesting.md b/docs/description/nesting.md old mode 100755 new mode 100644 diff --git a/docs/description/nimble_operator.md b/docs/description/nimble_operator.md old mode 100755 new mode 100644 diff --git a/docs/description/no_extension_access_modifier.md b/docs/description/no_extension_access_modifier.md old mode 100755 new mode 100644 diff --git a/docs/description/no_fallthrough_only.md b/docs/description/no_fallthrough_only.md old mode 100755 new mode 100644 diff --git a/docs/description/no_grouping_extension.md b/docs/description/no_grouping_extension.md old mode 100755 new mode 100644 diff --git a/docs/description/no_magic_numbers.md b/docs/description/no_magic_numbers.md old mode 100755 new mode 100644 diff --git a/docs/description/no_space_in_method_call.md b/docs/description/no_space_in_method_call.md old mode 100755 new mode 100644 diff --git a/docs/description/notification_center_detachment.md b/docs/description/notification_center_detachment.md old mode 100755 new mode 100644 diff --git a/docs/description/ns_number_init_as_function_reference.md b/docs/description/ns_number_init_as_function_reference.md old mode 100755 new mode 100644 diff --git a/docs/description/nslocalizedstring_key.md b/docs/description/nslocalizedstring_key.md old mode 100755 new mode 100644 diff --git a/docs/description/nslocalizedstring_require_bundle.md b/docs/description/nslocalizedstring_require_bundle.md old mode 100755 new mode 100644 diff --git a/docs/description/nsobject_prefer_isequal.md b/docs/description/nsobject_prefer_isequal.md old mode 100755 new mode 100644 diff --git a/docs/description/number_separator.md b/docs/description/number_separator.md old mode 100755 new mode 100644 diff --git a/docs/description/object_literal.md b/docs/description/object_literal.md old mode 100755 new mode 100644 diff --git a/docs/description/opening_brace.md b/docs/description/opening_brace.md old mode 100755 new mode 100644 diff --git a/docs/description/operator_usage_whitespace.md b/docs/description/operator_usage_whitespace.md old mode 100755 new mode 100644 diff --git a/docs/description/operator_whitespace.md b/docs/description/operator_whitespace.md old mode 100755 new mode 100644 diff --git a/docs/description/optional_enum_case_matching.md b/docs/description/optional_enum_case_matching.md old mode 100755 new mode 100644 diff --git a/docs/description/orphaned_doc_comment.md b/docs/description/orphaned_doc_comment.md old mode 100755 new mode 100644 diff --git a/docs/description/overridden_super_call.md b/docs/description/overridden_super_call.md old mode 100755 new mode 100644 diff --git a/docs/description/override_in_extension.md b/docs/description/override_in_extension.md old mode 100755 new mode 100644 diff --git a/docs/description/pattern_matching_keywords.md b/docs/description/pattern_matching_keywords.md old mode 100755 new mode 100644 diff --git a/docs/description/prefer_nimble.md b/docs/description/prefer_nimble.md old mode 100755 new mode 100644 diff --git a/docs/description/prefer_self_in_static_references.md b/docs/description/prefer_self_in_static_references.md old mode 100755 new mode 100644 diff --git a/docs/description/prefer_self_type_over_type_of_self.md b/docs/description/prefer_self_type_over_type_of_self.md old mode 100755 new mode 100644 diff --git a/docs/description/prefer_zero_over_explicit_init.md b/docs/description/prefer_zero_over_explicit_init.md old mode 100755 new mode 100644 diff --git a/docs/description/prefixed_toplevel_constant.md b/docs/description/prefixed_toplevel_constant.md old mode 100755 new mode 100644 diff --git a/docs/description/private_action.md b/docs/description/private_action.md old mode 100755 new mode 100644 diff --git a/docs/description/private_outlet.md b/docs/description/private_outlet.md old mode 100755 new mode 100644 diff --git a/docs/description/private_over_fileprivate.md b/docs/description/private_over_fileprivate.md old mode 100755 new mode 100644 diff --git a/docs/description/private_subject.md b/docs/description/private_subject.md old mode 100755 new mode 100644 diff --git a/docs/description/private_unit_test.md b/docs/description/private_unit_test.md old mode 100755 new mode 100644 diff --git a/docs/description/prohibited_interface_builder.md b/docs/description/prohibited_interface_builder.md old mode 100755 new mode 100644 diff --git a/docs/description/prohibited_super_call.md b/docs/description/prohibited_super_call.md old mode 100755 new mode 100644 diff --git a/docs/description/protocol_property_accessors_order.md b/docs/description/protocol_property_accessors_order.md old mode 100755 new mode 100644 diff --git a/docs/description/quick_discouraged_call.md b/docs/description/quick_discouraged_call.md old mode 100755 new mode 100644 diff --git a/docs/description/quick_discouraged_focused_test.md b/docs/description/quick_discouraged_focused_test.md old mode 100755 new mode 100644 diff --git a/docs/description/quick_discouraged_pending_test.md b/docs/description/quick_discouraged_pending_test.md old mode 100755 new mode 100644 diff --git a/docs/description/raw_value_for_camel_cased_codable_enum.md b/docs/description/raw_value_for_camel_cased_codable_enum.md old mode 100755 new mode 100644 diff --git a/docs/description/reduce_boolean.md b/docs/description/reduce_boolean.md old mode 100755 new mode 100644 diff --git a/docs/description/reduce_into.md b/docs/description/reduce_into.md old mode 100755 new mode 100644 diff --git a/docs/description/redundant_discardable_let.md b/docs/description/redundant_discardable_let.md old mode 100755 new mode 100644 diff --git a/docs/description/redundant_nil_coalescing.md b/docs/description/redundant_nil_coalescing.md old mode 100755 new mode 100644 diff --git a/docs/description/redundant_objc_attribute.md b/docs/description/redundant_objc_attribute.md old mode 100755 new mode 100644 diff --git a/docs/description/redundant_optional_initialization.md b/docs/description/redundant_optional_initialization.md old mode 100755 new mode 100644 diff --git a/docs/description/redundant_set_access_control.md b/docs/description/redundant_set_access_control.md old mode 100755 new mode 100644 diff --git a/docs/description/redundant_string_enum_value.md b/docs/description/redundant_string_enum_value.md old mode 100755 new mode 100644 diff --git a/docs/description/redundant_type_annotation.md b/docs/description/redundant_type_annotation.md old mode 100755 new mode 100644 diff --git a/docs/description/redundant_void_return.md b/docs/description/redundant_void_return.md old mode 100755 new mode 100644 diff --git a/docs/description/required_deinit.md b/docs/description/required_deinit.md old mode 100755 new mode 100644 diff --git a/docs/description/required_enum_case.md b/docs/description/required_enum_case.md old mode 100755 new mode 100644 diff --git a/docs/description/return_arrow_whitespace.md b/docs/description/return_arrow_whitespace.md old mode 100755 new mode 100644 diff --git a/docs/description/return_value_from_void_function.md b/docs/description/return_value_from_void_function.md old mode 100755 new mode 100644 diff --git a/docs/description/self_binding.md b/docs/description/self_binding.md old mode 100755 new mode 100644 diff --git a/docs/description/self_in_property_initialization.md b/docs/description/self_in_property_initialization.md old mode 100755 new mode 100644 diff --git a/docs/description/shorthand_operator.md b/docs/description/shorthand_operator.md old mode 100755 new mode 100644 diff --git a/docs/description/shorthand_optional_binding.md b/docs/description/shorthand_optional_binding.md old mode 100755 new mode 100644 diff --git a/docs/description/single_test_class.md b/docs/description/single_test_class.md old mode 100755 new mode 100644 diff --git a/docs/description/sorted_first_last.md b/docs/description/sorted_first_last.md old mode 100755 new mode 100644 diff --git a/docs/description/sorted_imports.md b/docs/description/sorted_imports.md old mode 100755 new mode 100644 diff --git a/docs/description/statement_position.md b/docs/description/statement_position.md old mode 100755 new mode 100644 diff --git a/docs/description/static_operator.md b/docs/description/static_operator.md old mode 100755 new mode 100644 diff --git a/docs/description/strict_fileprivate.md b/docs/description/strict_fileprivate.md old mode 100755 new mode 100644 diff --git a/docs/description/strong_iboutlet.md b/docs/description/strong_iboutlet.md old mode 100755 new mode 100644 diff --git a/docs/description/superfluous_disable_command.md b/docs/description/superfluous_disable_command.md old mode 100755 new mode 100644 diff --git a/docs/description/switch_case_alignment.md b/docs/description/switch_case_alignment.md old mode 100755 new mode 100644 diff --git a/docs/description/switch_case_on_newline.md b/docs/description/switch_case_on_newline.md old mode 100755 new mode 100644 diff --git a/docs/description/syntactic_sugar.md b/docs/description/syntactic_sugar.md old mode 100755 new mode 100644 diff --git a/docs/description/test_case_accessibility.md b/docs/description/test_case_accessibility.md old mode 100755 new mode 100644 diff --git a/docs/description/todo.md b/docs/description/todo.md old mode 100755 new mode 100644 diff --git a/docs/description/toggle_bool.md b/docs/description/toggle_bool.md old mode 100755 new mode 100644 diff --git a/docs/description/trailing_closure.md b/docs/description/trailing_closure.md old mode 100755 new mode 100644 diff --git a/docs/description/trailing_comma.md b/docs/description/trailing_comma.md old mode 100755 new mode 100644 diff --git a/docs/description/trailing_newline.md b/docs/description/trailing_newline.md old mode 100755 new mode 100644 diff --git a/docs/description/trailing_semicolon.md b/docs/description/trailing_semicolon.md old mode 100755 new mode 100644 diff --git a/docs/description/trailing_whitespace.md b/docs/description/trailing_whitespace.md old mode 100755 new mode 100644 diff --git a/docs/description/type_body_length.md b/docs/description/type_body_length.md old mode 100755 new mode 100644 diff --git a/docs/description/type_contents_order.md b/docs/description/type_contents_order.md old mode 100755 new mode 100644 diff --git a/docs/description/type_name.md b/docs/description/type_name.md old mode 100755 new mode 100644 diff --git a/docs/description/typesafe_array_init.md b/docs/description/typesafe_array_init.md old mode 100755 new mode 100644 diff --git a/docs/description/unavailable_condition.md b/docs/description/unavailable_condition.md old mode 100755 new mode 100644 diff --git a/docs/description/unavailable_function.md b/docs/description/unavailable_function.md old mode 100755 new mode 100644 diff --git a/docs/description/unneeded_break_in_switch.md b/docs/description/unneeded_break_in_switch.md old mode 100755 new mode 100644 diff --git a/docs/description/unneeded_parentheses_in_closure_argument.md b/docs/description/unneeded_parentheses_in_closure_argument.md old mode 100755 new mode 100644 diff --git a/docs/description/unowned_variable_capture.md b/docs/description/unowned_variable_capture.md old mode 100755 new mode 100644 diff --git a/docs/description/untyped_error_in_catch.md b/docs/description/untyped_error_in_catch.md old mode 100755 new mode 100644 diff --git a/docs/description/unused_capture_list.md b/docs/description/unused_capture_list.md old mode 100755 new mode 100644 diff --git a/docs/description/unused_closure_parameter.md b/docs/description/unused_closure_parameter.md old mode 100755 new mode 100644 diff --git a/docs/description/unused_control_flow_label.md b/docs/description/unused_control_flow_label.md old mode 100755 new mode 100644 diff --git a/docs/description/unused_declaration.md b/docs/description/unused_declaration.md old mode 100755 new mode 100644 diff --git a/docs/description/unused_enumerated.md b/docs/description/unused_enumerated.md old mode 100755 new mode 100644 diff --git a/docs/description/unused_import.md b/docs/description/unused_import.md old mode 100755 new mode 100644 diff --git a/docs/description/unused_optional_binding.md b/docs/description/unused_optional_binding.md old mode 100755 new mode 100644 diff --git a/docs/description/unused_setter_value.md b/docs/description/unused_setter_value.md old mode 100755 new mode 100644 diff --git a/docs/description/valid_ibinspectable.md b/docs/description/valid_ibinspectable.md old mode 100755 new mode 100644 diff --git a/docs/description/vertical_parameter_alignment.md b/docs/description/vertical_parameter_alignment.md old mode 100755 new mode 100644 diff --git a/docs/description/vertical_parameter_alignment_on_call.md b/docs/description/vertical_parameter_alignment_on_call.md old mode 100755 new mode 100644 diff --git a/docs/description/vertical_whitespace.md b/docs/description/vertical_whitespace.md old mode 100755 new mode 100644 diff --git a/docs/description/vertical_whitespace_between_cases.md b/docs/description/vertical_whitespace_between_cases.md old mode 100755 new mode 100644 diff --git a/docs/description/vertical_whitespace_closing_braces.md b/docs/description/vertical_whitespace_closing_braces.md old mode 100755 new mode 100644 index d89731e..2b8b748 --- a/docs/description/vertical_whitespace_closing_braces.md +++ b/docs/description/vertical_whitespace_closing_braces.md @@ -13,22 +13,18 @@ Don't include vertical whitespace (empty line) before closing braces. ## Non Triggering Examples ```swift -print([foo { - var sum = 0 - for i in 1...5 { sum += i } - return sum - -}, foo { - var mul = 1 - for i in 1...5 { mul *= i } - return mul -}]) +[ +1, +2, +3 +] ``` ```swift -do { - print("x is 5") -} +foo( + x: 5, + y:6 +) ``` ```swift @@ -44,18 +40,11 @@ do { ``` ```swift -[ -1, -2, -3 -] -``` - -```swift -foo( - x: 5, - y:6 -) +func foo() { + run(5) { x in + print(x) + } +} ``` ```swift @@ -65,13 +54,24 @@ print([ ``` ```swift -func foo() { - run(5) { x in - print(x) - } +do { + print("x is 5") } ``` +```swift +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum + +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul +}]) +``` + ```swift [1, 2].map { $0 }.filter { true } ``` @@ -109,24 +109,20 @@ if bool1 { ## Triggering Examples ```swift -print([foo { - var sum = 0 - for i in 1...5 { sum += i } - return sum - -}, foo { - var mul = 1 - for i in 1...5 { mul *= i } - return mul +[ +1, +2, +3 ↓ -}]) +] ``` ```swift -do { - print("x is 5") +foo( + x: 5, + y:6 ↓ -} +) ``` ```swift @@ -146,20 +142,12 @@ do { ``` ```swift -[ -1, -2, -3 -↓ -] -``` - -```swift -foo( - x: 5, - y:6 +func foo() { + run(5) { x in + print(x) + } ↓ -) +} ``` ```swift @@ -170,10 +158,22 @@ print([ ``` ```swift -func foo() { - run(5) { x in - print(x) - } +do { + print("x is 5") ↓ } +``` + +```swift +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum + +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul +↓ +}]) ``` \ No newline at end of file diff --git a/docs/description/vertical_whitespace_opening_braces.md b/docs/description/vertical_whitespace_opening_braces.md old mode 100755 new mode 100644 diff --git a/docs/description/void_function_in_ternary.md b/docs/description/void_function_in_ternary.md old mode 100755 new mode 100644 diff --git a/docs/description/void_return.md b/docs/description/void_return.md old mode 100755 new mode 100644 diff --git a/docs/description/weak_delegate.md b/docs/description/weak_delegate.md old mode 100755 new mode 100644 diff --git a/docs/description/xct_specific_matcher.md b/docs/description/xct_specific_matcher.md old mode 100755 new mode 100644 diff --git a/docs/description/xctfail_message.md b/docs/description/xctfail_message.md old mode 100755 new mode 100644 diff --git a/docs/description/yoda_condition.md b/docs/description/yoda_condition.md old mode 100755 new mode 100644 From fb79e32567082d81b80fd3b96ef70b0960e3657e Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 9 Jan 2023 15:45:34 +0100 Subject: [PATCH 085/119] Update README --- README.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3be48d4..eca09ff 100755 --- a/README.md +++ b/README.md @@ -10,10 +10,18 @@ See the [codacy-engine-scala-seed](https://github.com/codacy/codacy-engine-scala ## Usage -You can create the docker by doing: +You need to create the DEV image: ```bash -sbt graalvm-native-image:packageBin +sbt stage +docker build -t codacy-swiftlint-dev -f Dockerfile.dev . +``` + +then you can create the docker by doing: +**note** The works only on Linux for now, for local test use the DEV image + +```bash +sbt nativeImage docker build -t codacy-swiftlint . ``` @@ -24,7 +32,12 @@ docker run -it -v $srcDir:/src : ``` ## Generate docs -Run `sbt doc-generator/run` +Build the DEV image and then run: +``` +CONTAINER=$(docker run -d --entrypoint sh -it --rm codacy-swiftlint-dev) +docker cp $CONTAINER:/docs . +docker kill $CONTAINER +``` ## Test @@ -32,7 +45,7 @@ For a faster development loop you can create a Docker image based on the JVM ins ```bash sbt universal:stage -docker build -t codacy-swiftlint -f Dockerfile.dev . +docker build -t codacy-swiftlint-dev -f Dockerfile.dev . ``` We use the [codacy-plugins-test](https://github.com/codacy/codacy-plugins-test) to test our external tools integration. From af4798244dcb12f77527e4f14a32511cb13f7a05 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 9 Jan 2023 15:47:06 +0100 Subject: [PATCH 086/119] Update path native-image --- .dockerignore | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index 7d9f0bb..07ff5c6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,7 +2,7 @@ ** # Allow files and directories -!/target/graalvm-native-image/codacy-swiftlint +!target/native-image/codacy-swiftlint !/target/universal/stage/ !/doc-generator/target/universal/stage/ !/docs diff --git a/Dockerfile b/Dockerfile index 410b28f..1127c1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so COPY --from=builder /docs /docs -COPY target/graalvm-native-image/codacy-swiftlint /workdir/ +COPY target/native-image/codacy-swiftlint /workdir/ RUN adduser --uid 2004 --disabled-password --gecos "" docker USER docker WORKDIR /src From d3ea3184fab68ff49c1edc24ed39c6f2c6f7711f Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Tue, 10 Jan 2023 11:04:34 +0100 Subject: [PATCH 087/119] Tweak native-image flags --- build.sbt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 3c53f2c..6e115c0 100755 --- a/build.sbt +++ b/build.sbt @@ -12,14 +12,7 @@ libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "6.0.1" Compile / mainClass := Some("codacy.Engine") -nativeImageOptions ++= Seq( - "-O1", - "-H:+ReportExceptionStackTraces", - "--no-fallback", - "--no-server", - "--report-unsupported-elements-at-runtime", - "--static" -) +nativeImageOptions ++= Seq("-O1", "-H:+ReportExceptionStackTraces", "--no-fallback", "--no-server") lazy val `doc-generator` = project .settings( From 6089ca000b952575cbf553d8b31c5b122b0662f1 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Tue, 10 Jan 2023 11:43:47 +0100 Subject: [PATCH 088/119] clean: Remove old tests --- docs/tests/discouraged_optional_boolean.swift | 445 ------------- docs/tests/empty_enum_arguments.swift | 19 - docs/tests/for_where.swift | 2 +- docs/tests/generic_type_name.swift | 89 --- docs/tests/identifier_name.swift | 35 - .../tests/implicitly_unwrapped_optional.swift | 35 - docs/tests/large_tuple.swift | 49 -- docs/tests/number_separator.swift | 74 --- docs/tests/prefixed_toplevel_constant.swift | 38 -- docs/tests/redundant_nil_coalescing.swift | 9 - docs/tests/redundant_string_enum_value.swift | 21 - docs/tests/single_test_class.swift | 48 -- docs/tests/syntactic_sugar.swift | 30 - docs/tests/type_body_length.swift | 619 ------------------ docs/tests/unused_optional_binding.swift | 46 -- 15 files changed, 1 insertion(+), 1558 deletions(-) delete mode 100644 docs/tests/discouraged_optional_boolean.swift delete mode 100644 docs/tests/empty_enum_arguments.swift delete mode 100644 docs/tests/generic_type_name.swift delete mode 100644 docs/tests/identifier_name.swift delete mode 100644 docs/tests/implicitly_unwrapped_optional.swift delete mode 100644 docs/tests/large_tuple.swift delete mode 100644 docs/tests/number_separator.swift delete mode 100644 docs/tests/prefixed_toplevel_constant.swift delete mode 100644 docs/tests/redundant_nil_coalescing.swift delete mode 100644 docs/tests/redundant_string_enum_value.swift delete mode 100644 docs/tests/single_test_class.swift delete mode 100644 docs/tests/syntactic_sugar.swift delete mode 100644 docs/tests/type_body_length.swift delete mode 100644 docs/tests/unused_optional_binding.swift diff --git a/docs/tests/discouraged_optional_boolean.swift b/docs/tests/discouraged_optional_boolean.swift deleted file mode 100644 index e3617a6..0000000 --- a/docs/tests/discouraged_optional_boolean.swift +++ /dev/null @@ -1,445 +0,0 @@ -//#Patterns: discouraged_optional_boolean - -//#Issue: {"severity": "Warning", "line": 86, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 89, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 92, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 95, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 98, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 101, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 104, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 107, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 110, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 113, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 116, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 119, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 122, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 125, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 128, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 131, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 134, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 137, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 140, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 143, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 146, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 149, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 152, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 155, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 159, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 164, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 169, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 174, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 179, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 184, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 189, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 194, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 199, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 204, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 209, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 214, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 219, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 224, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 229, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 234, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 239, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 244, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 249, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 254, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 259, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 264, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 269, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 274, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 279, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 284, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 289, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 294, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 299, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 304, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 309, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 314, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 319, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 324, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 329, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 334, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 339, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 344, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 349, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 354, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 359, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 364, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 369, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 374, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 379, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 384, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 389, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 394, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 399, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 404, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 409, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 414, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 419, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 424, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 429, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 434, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 439, "patternId": "discouraged_optional_boolean"} -//#Issue: {"severity": "Warning", "line": 444, "patternId": "discouraged_optional_boolean"} - -var foo: Bool? - - -var foo: [String: Bool?] - - -var foo: [Bool?] - - -let foo: Bool? = nil - - -let foo: [String: Bool?] = [:] - - -let foo: [Bool?] = [] - - -let foo = Optional.some(false) - - -let foo = Optional.some(true) - - -var foo: Bool? { return nil } - - -let foo: Bool? { return nil }() - - -func foo() -> Bool? {} - - -func foo() -> [String: Bool?] {} - - -func foo() -> [Bool?] {} - - -static func foo() -> Bool? {} - - -static func foo() -> [String: Bool?] {} - - -static func foo() -> [Bool?] {} - - -func foo() -> (Bool?) -> String {} - - -func foo() -> ([Int]) -> Bool? {} - - -func foo(input: Bool?) {} - - -func foo(input: [String: Bool?]) {} - - -func foo(input: [Bool?]) {} - - -static func foo(input: Bool?) {} - - -static func foo(input: [String: Bool?]) {} - - -static func foo(input: [Bool?]) {} - - -class Foo { - var foo: Bool? -} - - -class Foo { - var foo: [String: Bool?] -} - - -class Foo { - let foo: Bool? = nil -} - - -class Foo { - let foo: [String: Bool?] = [:] -} - - -class Foo { - let foo: [Bool?] = [] -} - - -struct Foo { - var foo: Bool? -} - - -struct Foo { - var foo: [String: Bool?] -} - - -struct Foo { - let foo: Bool? = nil -} - - -struct Foo { - let foo: [String: Bool?] = [:] -} - - -struct Foo { - let foo: [Bool?] = [] -} - - -class Foo { - var foo: Bool? { return nil } -} - - -class Foo { - let foo: Bool? { return nil }() -} - - -struct Foo { - var foo: Bool? { return nil } -} - - -struct Foo { - let foo: Bool? { return nil }() -} - - -enum Foo { - var foo: Bool? { return nil } -} - - -enum Foo { - let foo: Bool? { return nil }() -} - - -class Foo { - func foo() -> Bool? {} -} - - -class Foo { - func foo() -> [String: Bool?] {} -} - - -class Foo { - func foo() -> [Bool?] {} -} - - -class Foo { - static func foo() -> Bool? {} -} - - -class Foo { - static func foo() -> [String: Bool?] {} -} - - -class Foo { - static func foo() -> [Bool?] {} -} - - -class Foo { - func foo() -> (Bool?) -> String {} -} - - -class Foo { - func foo() -> ([Int]) -> Bool? {} -} - - -struct Foo { - func foo() -> Bool? {} -} - - -struct Foo { - func foo() -> [String: Bool?] {} -} - - -struct Foo { - func foo() -> [Bool?] {} -} - - -struct Foo { - static func foo() -> Bool? {} -} - - -struct Foo { - static func foo() -> [String: Bool?] {} -} - - -struct Foo { - static func foo() -> [Bool?] {} -} - - -struct Foo { - func foo() -> (Bool?) -> String {} -} - - -struct Foo { - func foo() -> ([Int]) -> Bool? {} -} - - -enum Foo { - func foo() -> Bool? {} -} - - -enum Foo { - func foo() -> [String: Bool?] {} -} - - -enum Foo { - func foo() -> [Bool?] {} -} - - -enum Foo { - static func foo() -> Bool? {} -} - - -enum Foo { - static func foo() -> [String: Bool?] {} -} - - -enum Foo { - static func foo() -> [Bool?] {} -} - - -enum Foo { - func foo() -> (Bool?) -> String {} -} - - -enum Foo { - func foo() -> ([Int]) -> Bool? {} -} - - -class Foo { - func foo(input: Bool?) {} -} - - -class Foo { - func foo(input: [String: Bool?]) {} -} - - -class Foo { - func foo(input: [Bool?]) {} -} - - -class Foo { - static func foo(input: Bool?) {} -} - - -class Foo { - static func foo(input: [String: Bool?]) {} -} - - -class Foo { - static func foo(input: [Bool?]) {} -} - - -struct Foo { - func foo(input: Bool?) {} -} - - -struct Foo { - func foo(input: [String: Bool?]) {} -} - - -struct Foo { - func foo(input: [Bool?]) {} -} - - -struct Foo { - static func foo(input: Bool?) {} -} - - -struct Foo { - static func foo(input: [String: Bool?]) {} -} - - -struct Foo { - static func foo(input: [Bool?]) {} -} - - -enum Foo { - func foo(input: Bool?) {} -} - - -enum Foo { - func foo(input: [String: Bool?]) {} -} - - -enum Foo { - func foo(input: [Bool?]) {} -} - - -enum Foo { - static func foo(input: Bool?) {} -} - - -enum Foo { - static func foo(input: [String: Bool?]) {} -} - - -enum Foo { - static func foo(input: [Bool?]) {} -} diff --git a/docs/tests/empty_enum_arguments.swift b/docs/tests/empty_enum_arguments.swift deleted file mode 100644 index c5b2f34..0000000 --- a/docs/tests/empty_enum_arguments.swift +++ /dev/null @@ -1,19 +0,0 @@ -//#Patterns: empty_enum_arguments - -//#Issue: {"severity": "Warning", "line": 14, "patternId": "empty_enum_arguments"} - - switch foo { - case .bar(_): break - } - - switch foo { - case .bar(): break - } - - switch foo { - case .bar(_), .bar2↓(_): break - } - - switch foo { - case .bar() where method() > 2: break - } diff --git a/docs/tests/for_where.swift b/docs/tests/for_where.swift index f7fdfae..12b76e4 100644 --- a/docs/tests/for_where.swift +++ b/docs/tests/for_where.swift @@ -1,6 +1,6 @@ //#Patterns: for_where -//#Issue: {"severity": "Warning", "line": 6, "patternId": "for_where"} +//#Issue: {"severity": "Info", "line": 6, "patternId": "for_where"} for user in users { if user.id == 1 { return true } diff --git a/docs/tests/generic_type_name.swift b/docs/tests/generic_type_name.swift deleted file mode 100644 index bacc936..0000000 --- a/docs/tests/generic_type_name.swift +++ /dev/null @@ -1,89 +0,0 @@ -//#Patterns: generic_type_name - -//#Issue: {"severity": "Info", "line": 26, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 53, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 68, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 71, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 74, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 77, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 80, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 83, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 86, "patternId": "generic_type_name"} -//#Issue: {"severity": "Info", "line": 89, "patternId": "generic_type_name"} - - func foo() {} - - - func foo(param: U_Foo) -> T {} - - - func foo() {} - - - func foo() {} - - - typealias StringDictionary = Dictionary - - - typealias BackwardTriple = (T3, T2_Bar, T1) - - - typealias DictionaryOfStrings = Dictionary - - - class Foo {} - - - class Foo {} - - - class Foo {} - - - class Foo {} - - - class Foo {} - - - struct Foo {} - - - struct Foo {} - - - struct Foo {} - - - struct Foo {} - - - struct Foo {} - - - enum Foo {} - - - enum Foo {} - - - enum Foo {} - - - enum Foo {} - - - enum Foo {} diff --git a/docs/tests/identifier_name.swift b/docs/tests/identifier_name.swift deleted file mode 100644 index ff4d478..0000000 --- a/docs/tests/identifier_name.swift +++ /dev/null @@ -1,35 +0,0 @@ -//#Patterns: identifier_name - -//#Issue: {"severity": "Info", "line": 15, "patternId": "identifier_name"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "identifier_name"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "identifier_name"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "identifier_name"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "identifier_name"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "identifier_name"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "identifier_name"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "identifier_name"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "identifier_name"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "identifier_name"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "identifier_name"} - - let MyLet = 0 - - let _myLet = 0 - - private let myLet_ = 0 - - let myExtremelyVeryVeryVeryVeryVeryVeryLongLet = 0 - - var myExtremelyVeryVeryVeryVeryVeryVeryLongVar = 0 - - private let _myExtremelyVeryVeryVeryVeryVeryVeryLongLet = 0 - - let i = 0 - - var id = 0 - - private let _i = 0 - - func IsOperator(name: String) -> Bool - - enum Foo { case MyEnum } diff --git a/docs/tests/implicitly_unwrapped_optional.swift b/docs/tests/implicitly_unwrapped_optional.swift deleted file mode 100644 index 253c693..0000000 --- a/docs/tests/implicitly_unwrapped_optional.swift +++ /dev/null @@ -1,35 +0,0 @@ -//#Patterns: implicitly_unwrapped_optional - -//#Issue: {"severity": "Info", "line": 15, "patternId": "implicitly_unwrapped_optional"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "implicitly_unwrapped_optional"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "implicitly_unwrapped_optional"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "implicitly_unwrapped_optional"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "implicitly_unwrapped_optional"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "implicitly_unwrapped_optional"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "implicitly_unwrapped_optional"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "implicitly_unwrapped_optional"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "implicitly_unwrapped_optional"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "implicitly_unwrapped_optional"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "implicitly_unwrapped_optional"} - - let label: UILabel! - - let IBOutlet: UILabel! - - let labels: [UILabel!] - - var ints: [Int!] = [42, nil, 42] - - let label: IBOutlet! - - let int: Int! = 42 - - let int: Int! = nil - - var int: Int! = 42 - - let int: ImplicitlyUnwrappedOptional - - let collection: AnyCollection - - func foo(int: Int!) {} diff --git a/docs/tests/large_tuple.swift b/docs/tests/large_tuple.swift deleted file mode 100644 index 6b32ebe..0000000 --- a/docs/tests/large_tuple.swift +++ /dev/null @@ -1,49 +0,0 @@ -//#Patterns: large_tuple - -//#Issue: {"severity": "Info", "line": 16, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 43, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "large_tuple"} -//#Issue: {"severity": "Info", "line": 49, "patternId": "large_tuple"} - - let foo: (Int, Int, Int) - - - let foo: (start: Int, end: Int, value: String) - - - let foo: (Int, (Int, Int, Int)) - - - func foo(bar: (Int, Int, Int)) - - - func foo() -> (Int, Int, Int) - - - func foo() -> (Int, Int, Int) {} - - - func foo(bar: String) -> (Int, Int, Int) - - - func foo(bar: String) -> (Int, Int, Int) {} - - - func foo() throws -> (Int, Int, Int) - - - func foo() throws -> (Int, Int, Int) {} - - - func foo() throws -> (Int, ↓(String, String, String), Int) {} - - - func getDictionaryAndInt() -> (Dictionary, Int)? diff --git a/docs/tests/number_separator.swift b/docs/tests/number_separator.swift deleted file mode 100644 index 3f949f5..0000000 --- a/docs/tests/number_separator.swift +++ /dev/null @@ -1,74 +0,0 @@ -//#Patterns: number_separator - -//#Issue: {"severity": "Info", "line": 28, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 48, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 52, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 58, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 60, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 64, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 66, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 68, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 70, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 72, "patternId": "number_separator"} -//#Issue: {"severity": "Info", "line": 74, "patternId": "number_separator"} - - let foo = -10_0 - - let foo = -1000 - - let foo = -1000e2 - - let foo = -1000E2 - - let foo = -1__000 - - let foo = -1.0001 - - let foo = -1_000_000.000000_1 - - let foo = -1000000.000000_1 - - let foo = +10_0 - - let foo = +1000 - - let foo = +1000e2 - - let foo = +1000E2 - - let foo = +1__000 - - let foo = +1.0001 - - let foo = +1_000_000.000000_1 - - let foo = +1000000.000000_1 - - let foo = 10_0 - - let foo = 1000 - - let foo = 1000e2 - - let foo = 1000E2 - - let foo = 1__000 - - let foo = 1.0001 - - let foo = 1_000_000.000000_1 - - let foo = 1000000.000000_1 diff --git a/docs/tests/prefixed_toplevel_constant.swift b/docs/tests/prefixed_toplevel_constant.swift deleted file mode 100644 index b73c8be..0000000 --- a/docs/tests/prefixed_toplevel_constant.swift +++ /dev/null @@ -1,38 +0,0 @@ -//#Patterns: prefixed_toplevel_constant - -//#Issue: {"severity": "Info", "line": 14, "patternId": "prefixed_toplevel_constant"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "prefixed_toplevel_constant"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "prefixed_toplevel_constant"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "prefixed_toplevel_constant"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "prefixed_toplevel_constant"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "prefixed_toplevel_constant"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "prefixed_toplevel_constant"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "prefixed_toplevel_constant"} - - - -private let Foo = 20.0 - - -public let Foo = false - - -internal let Foo = "Foo" - - -let Foo = true - - -let foo = 2, ↓bar = true - - -var foo = true, let Foo = true - - -let -foo = true - - -let foo = { - return a + b -}() diff --git a/docs/tests/redundant_nil_coalescing.swift b/docs/tests/redundant_nil_coalescing.swift deleted file mode 100644 index c04d03b..0000000 --- a/docs/tests/redundant_nil_coalescing.swift +++ /dev/null @@ -1,9 +0,0 @@ -//#Patterns: redundant_nil_coalescing - -//#Issue: {"severity": "Warning", "line": 6, "patternId": "redundant_nil_coalescing"} -//#Issue: {"severity": "Warning", "line": 9, "patternId": "redundant_nil_coalescing"} - - var myVar: Int? = nil; myVar ?? nil - - - var myVar: Int? = nil; myVar??nil diff --git a/docs/tests/redundant_string_enum_value.swift b/docs/tests/redundant_string_enum_value.swift deleted file mode 100644 index 07e0c3d..0000000 --- a/docs/tests/redundant_string_enum_value.swift +++ /dev/null @@ -1,21 +0,0 @@ -//#Patterns: redundant_string_enum_value - -//#Issue: {"severity": "Warning", "line": 9, "patternId": "redundant_string_enum_value"} -//#Issue: {"severity": "Warning", "line": 10, "patternId": "redundant_string_enum_value"} -//#Issue: {"severity": "Warning", "line": 15, "patternId": "redundant_string_enum_value"} -//#Issue: {"severity": "Warning", "line": 20, "patternId": "redundant_string_enum_value"} - - enum Numbers: String { - case one = "one" - case two = "two" - } - - - enum Numbers: String { - case one = "one", two = ↓"two" - } - - - enum Numbers: String { - case one, two = "two" - } diff --git a/docs/tests/single_test_class.swift b/docs/tests/single_test_class.swift deleted file mode 100644 index a7f607b..0000000 --- a/docs/tests/single_test_class.swift +++ /dev/null @@ -1,48 +0,0 @@ -//#Patterns: single_test_class - -//#Issue: {"severity": "Warning", "line": 19, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 20, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 24, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 25, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 31, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 35, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 36, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 37, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 41, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 42, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 46, "patternId": "single_test_class"} -//#Issue: {"severity": "Warning", "line": 47, "patternId": "single_test_class"} - - -class FooTests: QuickSpec { } -class BarTests: QuickSpec { } - - - -class FooTests: QuickSpec { } -class BarTests: QuickSpec { } -class TotoTests: QuickSpec { } - - - -class FooTests: XCTestCase { } -class BarTests: XCTestCase { } - - - -class FooTests: XCTestCase { } -class BarTests: XCTestCase { } -class TotoTests: XCTestCase { } - - - -class FooTests: QuickSpec { } -class BarTests: XCTestCase { } - - - -class FooTests: QuickSpec { } -class BarTests: XCTestCase { } -class TotoTests { } diff --git a/docs/tests/syntactic_sugar.swift b/docs/tests/syntactic_sugar.swift deleted file mode 100644 index b9e2a02..0000000 --- a/docs/tests/syntactic_sugar.swift +++ /dev/null @@ -1,30 +0,0 @@ -//#Patterns: syntactic_sugar - -//#Issue: {"severity": "Warning", "line": 14, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Warning", "line": 16, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Warning", "line": 20, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Warning", "line": 24, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Warning", "line": 28, "patternId": "syntactic_sugar"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "syntactic_sugar"} - - let x: Array - - let x: Dictionary - - let x: Optional - - let x: ImplicitlyUnwrappedOptional - - func x(a: Array, b: Int) -> [Int: Any] - - func x(a: [Int], b: Int) -> Dictionary - - func x(a: Array, b: Int) -> ↓Dictionary - - let x = Array.array(of: object) - - let x: Swift.Optional diff --git a/docs/tests/type_body_length.swift b/docs/tests/type_body_length.swift deleted file mode 100644 index eb144ce..0000000 --- a/docs/tests/type_body_length.swift +++ /dev/null @@ -1,619 +0,0 @@ -//#Patterns: type_body_length - -//#Issue: {"severity": "Info", "line": 7, "patternId": "type_body_length"} -//#Issue: {"severity": "Info", "line": 212, "patternId": "type_body_length"} -//#Issue: {"severity": "Info", "line": 417, "patternId": "type_body_length"} - - class Abc { - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - } - - - struct Abc { - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - } - - - enum Abc { - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - let abc = 0 - } diff --git a/docs/tests/unused_optional_binding.swift b/docs/tests/unused_optional_binding.swift deleted file mode 100644 index f0ca217..0000000 --- a/docs/tests/unused_optional_binding.swift +++ /dev/null @@ -1,46 +0,0 @@ -//#Patterns: unused_optional_binding - -//#Issue: {"severity": "Info", "line": 13, "patternId": "unused_optional_binding"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "unused_optional_binding"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "unused_optional_binding"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "unused_optional_binding"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "unused_optional_binding"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "unused_optional_binding"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "unused_optional_binding"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "unused_optional_binding"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "unused_optional_binding"} - - if let _ = Foo.optionalValue { - } - - - if let a = Foo.optionalValue, let _ = Foo.optionalValue2 { - } - - - guard let a = Foo.optionalValue, let _ = Foo.optionalValue2 { - } - - - if let (first, second) = getOptionalTuple(), let _ = Foo.optionalValue { - } - - - if let (first, _) = getOptionalTuple(), let _ = Foo.optionalValue { - } - - - if let (_, second) = getOptionalTuple(), let _ = Foo.optionalValue { - } - - - if let (_, _, _) = getOptionalTuple(), let bar = Foo.optionalValue { - } - - - func foo() { - if let _ = bar { - } - - - if case .some(let _) = self {} From ab3ab8e71ca40d5fe0f8234f1293522342485270 Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Tue, 10 Jan 2023 18:30:18 +0100 Subject: [PATCH 089/119] bump: Bump swift base image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1127c1f..2aae8e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM codacy-swiftlint-dev as builder -FROM swift:5.7.0-jammy-slim +FROM swift:5.7.2-jammy-slim COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so From 8eae998fe99c3f7bfa3c87ab75f6f437586eb142 Mon Sep 17 00:00:00 2001 From: Nicola Klemenc Date: Mon, 13 Mar 2023 11:50:45 +0100 Subject: [PATCH 090/119] doc: Update tool description --- docs/tool-description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tool-description.md b/docs/tool-description.md index 67926bc..513e4cf 100644 --- a/docs/tool-description.md +++ b/docs/tool-description.md @@ -1 +1 @@ -A tool to enforce Swift style and conventions, loosely based on GitHub's Swift Style Guide. [Learn more](https://github.com/realm/SwiftLint) \ No newline at end of file +SwiftLint enforces Swift style and conventions, loosely based on GitHub's Swift Style Guide. [Learn more](https://github.com/realm/SwiftLint) \ No newline at end of file From 22ff380ca1ca8aabe893db6d02e1a9dffcf569b6 Mon Sep 17 00:00:00 2001 From: Stefan Vacareanu Date: Wed, 20 Sep 2023 10:45:16 +0200 Subject: [PATCH 091/119] Bump to version 0.52.4 TS-573 --- .circleci/config.yml | 2 +- Dockerfile | 2 +- Dockerfile.dev | 2 +- .../accessibility_label_for_image.md | 19 +- .../accessibility_trait_for_button.md | 19 +- ...anonymous_argument_in_multiline_closure.md | 17 +- docs/description/anyobject_protocol.md | 19 +- docs/description/array_init.md | 19 +- docs/description/attributes.md | 51 ++- docs/description/balanced_xctest_lifecycle.md | 29 +- docs/description/blanket_disable_command.md | 88 ++++ docs/description/block_based_kvo.md | 19 +- docs/description/capture_variable.md | 19 +- docs/description/class_delegate_protocol.md | 19 +- docs/description/closing_brace.md | 19 +- docs/description/closure_body_length.md | 27 +- docs/description/closure_end_indentation.md | 17 +- .../description/closure_parameter_position.md | 19 +- docs/description/closure_spacing.md | 19 +- docs/description/collection_alignment.md | 25 +- docs/description/colon.md | 35 +- docs/description/comma.md | 19 +- docs/description/comma_inheritance.md | 17 +- docs/description/comment_spacing.md | 19 +- docs/description/compiler_protocol_init.md | 17 +- docs/description/computed_accessors_order.md | 25 +- .../conditional_returns_on_newline.md | 25 +- .../description/contains_over_filter_count.md | 21 +- .../contains_over_filter_is_empty.md | 19 +- .../contains_over_first_not_nil.md | 19 +- .../contains_over_range_nil_comparison.md | 21 +- docs/description/control_statement.md | 19 +- docs/description/convenience_type.md | 19 +- docs/description/custom_rules.md | 3 +- docs/description/cyclomatic_complexity.md | 33 +- docs/description/deployment_target.md | 81 +++- docs/description/description.json | 418 ++++++++++-------- docs/description/direct_return.md | 110 +++++ .../discarded_notification_center_observer.md | 19 +- docs/description/discouraged_assert.md | 17 +- docs/description/discouraged_direct_init.md | 27 +- docs/description/discouraged_none_name.md | 19 +- .../description/discouraged_object_literal.md | 35 +- .../discouraged_optional_boolean.md | 19 +- .../discouraged_optional_collection.md | 19 +- docs/description/duplicate_conditions.md | 190 ++++++++ docs/description/duplicate_enum_cases.md | 19 +- docs/description/duplicate_imports.md | 19 +- .../duplicated_key_in_dictionary_literal.md | 19 +- docs/description/dynamic_inline.md | 19 +- docs/description/empty_collection_literal.md | 19 +- docs/description/empty_count.md | 27 +- docs/description/empty_enum_arguments.md | 19 +- docs/description/empty_parameters.md | 19 +- ...empty_parentheses_with_trailing_closure.md | 19 +- docs/description/empty_string.md | 19 +- docs/description/empty_xctest_method.md | 27 +- .../enum_case_associated_values_count.md | 27 +- docs/description/expiring_todo.md | 87 +++- docs/description/explicit_acl.md | 19 +- docs/description/explicit_enum_raw_value.md | 19 +- docs/description/explicit_init.md | 19 +- docs/description/explicit_self.md | 19 +- docs/description/explicit_top_level_acl.md | 19 +- docs/description/explicit_type_interface.md | 47 +- docs/description/extension_access_modifier.md | 17 +- docs/description/fallthrough.md | 19 +- docs/description/fatal_error_message.md | 19 +- docs/description/file_header.md | 17 +- docs/description/file_length.md | 33 +- docs/description/file_name.md | 51 ++- docs/description/file_name_no_space.md | 29 +- docs/description/file_types_order.md | 25 +- docs/description/first_where.md | 19 +- docs/description/flatmap_over_map_reduce.md | 21 +- docs/description/for_where.md | 29 +- docs/description/force_cast.md | 19 +- docs/description/force_try.md | 19 +- docs/description/force_unwrapping.md | 19 +- docs/description/function_body_length.md | 27 +- .../function_default_parameter_at_end.md | 19 +- docs/description/function_parameter_count.md | 33 +- docs/description/generic_type_name.md | 101 ++++- .../description/ibinspectable_in_extension.md | 19 +- docs/description/identical_operands.md | 21 +- docs/description/identifier_name.md | 123 +++++- docs/description/implicit_getter.md | 17 +- docs/description/implicit_return.md | 27 +- .../implicitly_unwrapped_optional.md | 53 ++- docs/description/inclusive_language.md | 19 +- docs/description/indentation_width.md | 49 +- docs/description/inert_defer.md | 21 +- docs/description/invalid_swiftlint_command.md | 106 +++++ docs/description/is_disjoint.md | 19 +- docs/description/joined_default_parameter.md | 19 +- docs/description/large_tuple.md | 25 +- docs/description/last_where.md | 19 +- docs/description/leading_whitespace.md | 19 +- .../legacy_cggeometry_functions.md | 17 +- docs/description/legacy_constant.md | 19 +- docs/description/legacy_constructor.md | 19 +- docs/description/legacy_hashing.md | 17 +- docs/description/legacy_multiple.md | 19 +- .../legacy_nsgeometry_functions.md | 17 +- docs/description/legacy_objc_type.md | 17 +- docs/description/legacy_random.md | 23 +- docs/description/let_var_whitespace.md | 19 +- docs/description/line_length.md | 57 ++- .../literal_expression_end_indentation.md | 19 +- docs/description/local_doc_comment.md | 19 +- docs/description/lower_acl_than_parent.md | 19 +- docs/description/mark.md | 17 +- docs/description/missing_docs.md | 41 +- docs/description/modifier_order.md | 25 +- docs/description/multiline_arguments.md | 65 ++- .../multiline_arguments_brackets.md | 19 +- docs/description/multiline_function_chains.md | 19 +- .../description/multiline_literal_brackets.md | 19 +- docs/description/multiline_parameters.md | 27 +- .../multiline_parameters_brackets.md | 19 +- ...multiple_closures_with_trailing_closure.md | 19 +- docs/description/nesting.md | 69 ++- docs/description/nimble_operator.md | 19 +- .../no_extension_access_modifier.md | 17 +- docs/description/no_fallthrough_only.md | 21 +- docs/description/no_grouping_extension.md | 19 +- docs/description/no_magic_numbers.md | 50 ++- docs/description/no_space_in_method_call.md | 19 +- .../notification_center_detachment.md | 19 +- .../ns_number_init_as_function_reference.md | 19 +- docs/description/nslocalizedstring_key.md | 19 +- .../nslocalizedstring_require_bundle.md | 19 +- docs/description/nsobject_prefer_isequal.md | 19 +- docs/description/number_separator.md | 27 +- docs/description/object_literal.md | 35 +- docs/description/opening_brace.md | 41 +- docs/description/operator_usage_whitespace.md | 47 +- docs/description/operator_whitespace.md | 19 +- .../optional_enum_case_matching.md | 19 +- docs/description/orphaned_doc_comment.md | 19 +- docs/description/overridden_super_call.md | 37 +- docs/description/override_in_extension.md | 19 +- docs/description/pattern_matching_keywords.md | 19 +- docs/description/period_spacing.md | 91 ++++ docs/description/prefer_nimble.md | 19 +- .../prefer_self_in_static_references.md | 48 +- .../prefer_self_type_over_type_of_self.md | 19 +- .../prefer_zero_over_explicit_init.md | 17 +- .../description/prefixed_toplevel_constant.md | 27 +- docs/description/private_action.md | 19 +- docs/description/private_outlet.md | 27 +- docs/description/private_over_fileprivate.md | 29 +- docs/description/private_subject.md | 45 +- docs/description/private_unit_test.md | 27 +- .../prohibited_interface_builder.md | 19 +- docs/description/prohibited_super_call.md | 37 +- .../protocol_property_accessors_order.md | 19 +- docs/description/quick_discouraged_call.md | 62 ++- .../quick_discouraged_focused_test.md | 19 +- .../quick_discouraged_pending_test.md | 19 +- .../raw_value_for_camel_cased_codable_enum.md | 21 +- docs/description/reduce_boolean.md | 27 +- docs/description/reduce_into.md | 19 +- docs/description/redundant_discardable_let.md | 19 +- docs/description/redundant_nil_coalescing.md | 17 +- docs/description/redundant_objc_attribute.md | 90 +++- .../redundant_optional_initialization.md | 19 +- docs/description/redundant_self_in_closure.md | 195 ++++++++ .../redundant_set_access_control.md | 21 +- .../redundant_string_enum_value.md | 19 +- docs/description/redundant_type_annotation.md | 17 +- docs/description/redundant_void_return.md | 19 +- docs/description/required_deinit.md | 19 +- docs/description/required_enum_case.md | 45 +- docs/description/return_arrow_whitespace.md | 19 +- .../return_value_from_void_function.md | 19 +- docs/description/self_binding.md | 35 +- .../self_in_property_initialization.md | 19 +- docs/description/shorthand_operator.md | 19 +- .../description/shorthand_optional_binding.md | 17 +- docs/description/single_test_class.md | 25 +- docs/description/sorted_enum_cases.md | 102 +++++ docs/description/sorted_first_last.md | 33 +- docs/description/sorted_imports.md | 27 +- docs/description/statement_position.md | 27 +- docs/description/static_operator.md | 19 +- docs/description/strict_fileprivate.md | 78 ++-- docs/description/strong_iboutlet.md | 19 +- .../superfluous_disable_command.md | 17 +- docs/description/superfluous_else.md | 103 +++++ docs/description/switch_case_alignment.md | 32 +- docs/description/switch_case_on_newline.md | 19 +- docs/description/syntactic_sugar.md | 17 +- docs/description/test_case_accessibility.md | 61 ++- docs/description/todo.md | 17 +- docs/description/toggle_bool.md | 19 +- docs/description/trailing_closure.md | 27 +- docs/description/trailing_comma.md | 25 +- docs/description/trailing_newline.md | 19 +- docs/description/trailing_semicolon.md | 24 +- docs/description/trailing_whitespace.md | 35 +- docs/description/type_body_length.md | 27 +- docs/description/type_contents_order.md | 25 +- docs/description/type_name.md | 109 ++++- docs/description/typesafe_array_init.md | 19 +- docs/description/unavailable_condition.md | 17 +- docs/description/unavailable_function.md | 19 +- docs/description/unhandled_throwing_task.md | 220 +++++++++ docs/description/unneeded_break_in_switch.md | 19 +- ...nneeded_parentheses_in_closure_argument.md | 19 +- .../unneeded_synthesized_initializer.md | 373 ++++++++++++++++ docs/description/unowned_variable_capture.md | 29 +- docs/description/untyped_error_in_catch.md | 19 +- docs/description/unused_capture_list.md | 40 +- docs/description/unused_closure_parameter.md | 19 +- docs/description/unused_control_flow_label.md | 19 +- docs/description/unused_declaration.md | 35 +- docs/description/unused_enumerated.md | 17 +- docs/description/unused_import.md | 44 +- docs/description/unused_optional_binding.md | 25 +- docs/description/unused_setter_value.md | 19 +- docs/description/valid_ibinspectable.md | 17 +- .../vertical_parameter_alignment.md | 19 +- .../vertical_parameter_alignment_on_call.md | 21 +- docs/description/vertical_whitespace.md | 25 +- .../vertical_whitespace_between_cases.md | 21 +- .../vertical_whitespace_closing_braces.md | 113 +++-- .../vertical_whitespace_opening_braces.md | 19 +- docs/description/void_function_in_ternary.md | 19 +- docs/description/void_return.md | 54 ++- docs/description/weak_delegate.md | 19 +- docs/description/xct_specific_matcher.md | 99 ++++- docs/description/xctfail_message.md | 19 +- docs/description/yoda_condition.md | 21 +- docs/patterns.json | 384 +++++++++------- project/build.properties | 2 +- 236 files changed, 7438 insertions(+), 900 deletions(-) create mode 100644 docs/description/blanket_disable_command.md create mode 100644 docs/description/direct_return.md create mode 100644 docs/description/duplicate_conditions.md create mode 100644 docs/description/invalid_swiftlint_command.md create mode 100644 docs/description/period_spacing.md create mode 100644 docs/description/redundant_self_in_closure.md create mode 100644 docs/description/sorted_enum_cases.md create mode 100644 docs/description/superfluous_else.md create mode 100644 docs/description/unhandled_throwing_task.md create mode 100644 docs/description/unneeded_synthesized_initializer.md diff --git a/.circleci/config.yml b/.circleci/config.yml index 5be5786..07a942f 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codacy: codacy/base@10.0.2 + codacy: codacy/base@10.8.0 codacy_plugins_test: codacy/plugins-test@1.1.1 workflows: diff --git a/Dockerfile b/Dockerfile index 2aae8e9..0601d6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM codacy-swiftlint-dev as builder -FROM swift:5.7.2-jammy-slim +FROM swift:5.8.1-jammy-slim COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so diff --git a/Dockerfile.dev b/Dockerfile.dev index 81d3453..b1281c8 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM norionomura/swiftlint:0.50.3_swift-5.7.0 +FROM norionomura/swiftlint:0.52.4_swift-5.8.1 RUN apt-get update && apt-get install -y openjdk-8-jre-headless diff --git a/docs/description/accessibility_label_for_image.md b/docs/description/accessibility_label_for_image.md index 0e58523..1aeb4f0 100644 --- a/docs/description/accessibility_label_for_image.md +++ b/docs/description/accessibility_label_for_image.md @@ -1,6 +1,6 @@ # Accessibility Label for Image -All Images that provide context should have an accessibility label. Purely decorative images can be hidden from accessibility. +Images that provide context should have an accessibility label or should be explicitly hidden from accessibility * **Identifier:** accessibility_label_for_image * **Enabled by default:** No @@ -8,7 +8,22 @@ All Images that provide context should have an accessibility label. Purely decor * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.1.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/accessibility_trait_for_button.md b/docs/description/accessibility_trait_for_button.md index b3baaa9..5cad209 100644 --- a/docs/description/accessibility_trait_for_button.md +++ b/docs/description/accessibility_trait_for_button.md @@ -1,6 +1,6 @@ # Accessibility Trait for Button -All views with tap gestures added should include the .isButton accessibility trait. If a tap opens an external link the .isLink trait should be used instead. +All views with tap gestures added should include the .isButton or the .isLink accessibility traits * **Identifier:** accessibility_trait_for_button * **Enabled by default:** No @@ -8,7 +8,22 @@ All views with tap gestures added should include the .isButton accessibility tra * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.1.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/anonymous_argument_in_multiline_closure.md b/docs/description/anonymous_argument_in_multiline_closure.md index 65ac7fc..535ada2 100644 --- a/docs/description/anonymous_argument_in_multiline_closure.md +++ b/docs/description/anonymous_argument_in_multiline_closure.md @@ -8,7 +8,22 @@ Use named arguments in multiline closures * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/anyobject_protocol.md b/docs/description/anyobject_protocol.md index bf4b554..33cb871 100644 --- a/docs/description/anyobject_protocol.md +++ b/docs/description/anyobject_protocol.md @@ -1,6 +1,6 @@ # AnyObject Protocol -Prefer using `AnyObject` over `class` for class-only protocols. +Prefer using `AnyObject` over `class` for class-only protocols * **Identifier:** anyobject_protocol * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer using `AnyObject` over `class` for class-only protocols. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/array_init.md b/docs/description/array_init.md index 9946525..d6304a1 100644 --- a/docs/description/array_init.md +++ b/docs/description/array_init.md @@ -1,6 +1,6 @@ # Array Init -Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array. +Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array * **Identifier:** array_init * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Ar * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/attributes.md b/docs/description/attributes.md index d1683c9..be1ffa0 100644 --- a/docs/description/attributes.md +++ b/docs/description/attributes.md @@ -1,6 +1,6 @@ # Attributes -Attributes should be on their own lines in functions and types, but on the same line as variables and imports. +Attributes should be on their own lines in functions and types, but on the same line as variables and imports * **Identifier:** attributes * **Enabled by default:** No @@ -8,7 +8,46 @@ Attributes should be on their own lines in functions and types, but on the same * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, always_on_same_line: ["@IBAction", "@NSManaged"], always_on_line_above: [] +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ attributes_with_arguments_always_on_line_above + + true +
+ always_on_same_line + + ["@IBAction", "@NSManaged"] +
+ always_on_line_above + + [] +
## Non Triggering Examples @@ -225,6 +264,14 @@ func refreshable(action: @escaping @Sendable () async -> Void) -> some View { } ``` +```swift +import AppKit + +@NSApplicationMain +@MainActor +final class AppDelegate: NSAppDelegate {} +``` + ## Triggering Examples ```swift diff --git a/docs/description/balanced_xctest_lifecycle.md b/docs/description/balanced_xctest_lifecycle.md index 5fb938f..6643655 100644 --- a/docs/description/balanced_xctest_lifecycle.md +++ b/docs/description/balanced_xctest_lifecycle.md @@ -1,6 +1,6 @@ -# Balanced XCTest life-cycle +# Balanced XCTest Life Cycle -Test classes must implement balanced setUp and tearDown methods. +Test classes must implement balanced setUp and tearDown methods * **Identifier:** balanced_xctest_lifecycle * **Enabled by default:** No @@ -8,7 +8,30 @@ Test classes must implement balanced setUp and tearDown methods. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, test_parent_classes: ["QuickSpec", "XCTestCase"] +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ test_parent_classes + + ["QuickSpec", "XCTestCase"] +
## Non Triggering Examples diff --git a/docs/description/blanket_disable_command.md b/docs/description/blanket_disable_command.md new file mode 100644 index 0000000..f1594f9 --- /dev/null +++ b/docs/description/blanket_disable_command.md @@ -0,0 +1,88 @@ +# Blanket Disable Command + +swiftlint:disable commands should be re-enabled before the end of the file + +* **Identifier:** blanket_disable_command +* **Enabled by default:** Yes +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ allowed_rules + + ["file_header", "file_length", "file_name", "file_name_no_space", "single_test_class"] +
+ always_blanket_disable + + [] +
+ +## Non Triggering Examples + +```swift +// swiftlint:disable unused_import +// swiftlint:enable unused_import +``` + +```swift +// swiftlint:disable unused_import unused_declaration +// swiftlint:enable unused_import +// swiftlint:enable unused_declaration +``` + +```swift +// swiftlint:disable:this unused_import +``` + +```swift +// swiftlint:disable:next unused_import +``` + +```swift +// swiftlint:disable:previous unused_import +``` + +## Triggering Examples + +```swift +// swiftlint:disable ↓unused_import +``` + +```swift +// swiftlint:disable unused_import ↓unused_declaration +// swiftlint:enable unused_import +``` + +```swift +// swiftlint:disable unused_import +// swiftlint:disable ↓unused_import +// swiftlint:enable unused_import +``` + +```swift +// swiftlint:enable ↓unused_import +``` \ No newline at end of file diff --git a/docs/description/block_based_kvo.md b/docs/description/block_based_kvo.md index c693fb1..92c9b86 100644 --- a/docs/description/block_based_kvo.md +++ b/docs/description/block_based_kvo.md @@ -1,6 +1,6 @@ # Block Based KVO -Prefer the new block based KVO API with keypaths when using Swift 3.2 or later. +Prefer the new block based KVO API with keypaths when using Swift 3.2 or later * **Identifier:** block_based_kvo * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Prefer the new block based KVO API with keypaths when using Swift 3.2 or later. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/capture_variable.md b/docs/description/capture_variable.md index da63b6d..75692d7 100644 --- a/docs/description/capture_variable.md +++ b/docs/description/capture_variable.md @@ -1,6 +1,6 @@ # Capture Variable -Non-constant variables should not be listed in a closure's capture list to avoid confusion about closures capturing variables at creation time. +Non-constant variables should not be listed in a closure's capture list to avoid confusion about closures capturing variables at creation time * **Identifier:** capture_variable * **Enabled by default:** No @@ -8,7 +8,22 @@ Non-constant variables should not be listed in a closure's capture list to avoid * **Kind:** lint * **Analyzer rule:** Yes * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/class_delegate_protocol.md b/docs/description/class_delegate_protocol.md index a02d8ad..a78254a 100644 --- a/docs/description/class_delegate_protocol.md +++ b/docs/description/class_delegate_protocol.md @@ -1,6 +1,6 @@ # Class Delegate Protocol -Delegate protocols should be class-only so they can be weakly referenced. +Delegate protocols should be class-only so they can be weakly referenced * **Identifier:** class_delegate_protocol * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Delegate protocols should be class-only so they can be weakly referenced. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/closing_brace.md b/docs/description/closing_brace.md index c48922f..e6752b6 100644 --- a/docs/description/closing_brace.md +++ b/docs/description/closing_brace.md @@ -1,6 +1,6 @@ # Closing Brace Spacing -Closing brace with closing parenthesis should not have any whitespaces in the middle. +Closing brace with closing parenthesis should not have any whitespaces in the middle * **Identifier:** closing_brace * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Closing brace with closing parenthesis should not have any whitespaces in the mi * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/closure_body_length.md b/docs/description/closure_body_length.md index 545775b..9f9270c 100644 --- a/docs/description/closure_body_length.md +++ b/docs/description/closure_body_length.md @@ -1,6 +1,6 @@ # Closure Body Length -Closure bodies should not span too many lines. +Closure bodies should not span too many lines * **Identifier:** closure_body_length * **Enabled by default:** No @@ -8,7 +8,30 @@ Closure bodies should not span too many lines. * **Kind:** metrics * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning: 30, error: 100 +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ warning + + 30 +
+ error + + 100 +
## Non Triggering Examples diff --git a/docs/description/closure_end_indentation.md b/docs/description/closure_end_indentation.md index 8a0fb5b..c2b456e 100644 --- a/docs/description/closure_end_indentation.md +++ b/docs/description/closure_end_indentation.md @@ -8,7 +8,22 @@ Closure end should have the same indentation as the line that started it. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/closure_parameter_position.md b/docs/description/closure_parameter_position.md index 4e203c0..72cf55c 100644 --- a/docs/description/closure_parameter_position.md +++ b/docs/description/closure_parameter_position.md @@ -1,6 +1,6 @@ # Closure Parameter Position -Closure parameters should be on the same line as opening brace. +Closure parameters should be on the same line as opening brace * **Identifier:** closure_parameter_position * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Closure parameters should be on the same line as opening brace. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/closure_spacing.md b/docs/description/closure_spacing.md index 5f61849..9cf56f6 100644 --- a/docs/description/closure_spacing.md +++ b/docs/description/closure_spacing.md @@ -1,6 +1,6 @@ # Closure Spacing -Closure expressions should have a single space inside each brace. +Closure expressions should have a single space inside each brace * **Identifier:** closure_spacing * **Enabled by default:** No @@ -8,7 +8,22 @@ Closure expressions should have a single space inside each brace. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/collection_alignment.md b/docs/description/collection_alignment.md index 8e88405..63d0c20 100644 --- a/docs/description/collection_alignment.md +++ b/docs/description/collection_alignment.md @@ -8,7 +8,30 @@ All elements in a collection literal should be vertically aligned * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, align_colons: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ align_colons + + false +
## Non Triggering Examples diff --git a/docs/description/colon.md b/docs/description/colon.md index b1e6c06..808b7f6 100644 --- a/docs/description/colon.md +++ b/docs/description/colon.md @@ -1,6 +1,6 @@ # Colon Spacing -Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. +Colons should be next to the identifier when specifying a type and next to the key in dictionary literals * **Identifier:** colon * **Enabled by default:** Yes @@ -8,7 +8,38 @@ Colons should be next to the identifier when specifying a type and next to the k * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, flexible_right_spacing: false, apply_to_dictionaries: true +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ flexible_right_spacing + + false +
+ apply_to_dictionaries + + true +
## Non Triggering Examples diff --git a/docs/description/comma.md b/docs/description/comma.md index c6d25b9..7f5a09d 100644 --- a/docs/description/comma.md +++ b/docs/description/comma.md @@ -1,6 +1,6 @@ # Comma Spacing -There should be no space before and one after any comma. +There should be no space before and one after any comma * **Identifier:** comma * **Enabled by default:** Yes @@ -8,7 +8,22 @@ There should be no space before and one after any comma. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/comma_inheritance.md b/docs/description/comma_inheritance.md index 692df72..6c879b3 100644 --- a/docs/description/comma_inheritance.md +++ b/docs/description/comma_inheritance.md @@ -8,7 +8,22 @@ Use commas to separate types in inheritance lists * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/comment_spacing.md b/docs/description/comment_spacing.md index 5f61fb6..47ae9e7 100644 --- a/docs/description/comment_spacing.md +++ b/docs/description/comment_spacing.md @@ -1,6 +1,6 @@ # Comment Spacing -Prefer at least one space after slashes for comments. +Prefer at least one space after slashes for comments * **Identifier:** comment_spacing * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Prefer at least one space after slashes for comments. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/compiler_protocol_init.md b/docs/description/compiler_protocol_init.md index 2b975f1..7fe5d50 100644 --- a/docs/description/compiler_protocol_init.md +++ b/docs/description/compiler_protocol_init.md @@ -8,7 +8,22 @@ The initializers declared in compiler protocols such as `ExpressibleByArrayLiter * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/computed_accessors_order.md b/docs/description/computed_accessors_order.md index 71b1e60..410a92e 100644 --- a/docs/description/computed_accessors_order.md +++ b/docs/description/computed_accessors_order.md @@ -8,7 +8,30 @@ Getter and setters in computed properties and subscripts should be in a consiste * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, order: get_set +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ order + + get_set +
## Non Triggering Examples diff --git a/docs/description/conditional_returns_on_newline.md b/docs/description/conditional_returns_on_newline.md index 693cbfd..455416a 100644 --- a/docs/description/conditional_returns_on_newline.md +++ b/docs/description/conditional_returns_on_newline.md @@ -8,7 +8,30 @@ Conditional statements should always return on the next line * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, if_only: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ if_only + + false +
## Non Triggering Examples diff --git a/docs/description/contains_over_filter_count.md b/docs/description/contains_over_filter_count.md index bf75bbc..aa13654 100644 --- a/docs/description/contains_over_filter_count.md +++ b/docs/description/contains_over_filter_count.md @@ -1,6 +1,6 @@ -# Contains Over Filter Count +# Contains over Filter Count -Prefer `contains` over comparing `filter(where:).count` to 0. +Prefer `contains` over comparing `filter(where:).count` to 0 * **Identifier:** contains_over_filter_count * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer `contains` over comparing `filter(where:).count` to 0. * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/contains_over_filter_is_empty.md b/docs/description/contains_over_filter_is_empty.md index 8286a9e..0a31422 100644 --- a/docs/description/contains_over_filter_is_empty.md +++ b/docs/description/contains_over_filter_is_empty.md @@ -1,4 +1,4 @@ -# Contains Over Filter Is Empty +# Contains over Filter is Empty Prefer `contains` over using `filter(where:).isEmpty` @@ -8,7 +8,22 @@ Prefer `contains` over using `filter(where:).isEmpty` * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/contains_over_first_not_nil.md b/docs/description/contains_over_first_not_nil.md index f95e674..be216f2 100644 --- a/docs/description/contains_over_first_not_nil.md +++ b/docs/description/contains_over_first_not_nil.md @@ -1,4 +1,4 @@ -# Contains over first not nil +# Contains over First not Nil Prefer `contains` over `first(where:) != nil` and `firstIndex(where:) != nil`. @@ -8,7 +8,22 @@ Prefer `contains` over `first(where:) != nil` and `firstIndex(where:) != nil`. * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/contains_over_range_nil_comparison.md b/docs/description/contains_over_range_nil_comparison.md index 39bce08..93be994 100644 --- a/docs/description/contains_over_range_nil_comparison.md +++ b/docs/description/contains_over_range_nil_comparison.md @@ -1,6 +1,6 @@ -# Contains over range(of:) comparison to nil +# Contains over Range Comparision to Nil -Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`. +Prefer `contains` over `range(of:) != nil` and `range(of:) == nil` * **Identifier:** contains_over_range_nil_comparison * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`. * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/control_statement.md b/docs/description/control_statement.md index 2ba2d0c..2be7e2b 100644 --- a/docs/description/control_statement.md +++ b/docs/description/control_statement.md @@ -1,6 +1,6 @@ # Control Statement -`if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses. +`if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses * **Identifier:** control_statement * **Enabled by default:** Yes @@ -8,7 +8,22 @@ * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/convenience_type.md b/docs/description/convenience_type.md index f506bae..15de703 100644 --- a/docs/description/convenience_type.md +++ b/docs/description/convenience_type.md @@ -1,6 +1,6 @@ # Convenience Type -Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation. +Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation * **Identifier:** convenience_type * **Enabled by default:** No @@ -8,7 +8,22 @@ Types used for hosting only static members should be implemented as a caseless e * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/custom_rules.md b/docs/description/custom_rules.md index 8212b90..99a052d 100644 --- a/docs/description/custom_rules.md +++ b/docs/description/custom_rules.md @@ -7,5 +7,4 @@ Create custom rules by providing a regex string. Optionally specify what syntax * **Supports autocorrection:** No * **Kind:** style * **Analyzer rule:** No -* **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** user-defined \ No newline at end of file +* **Minimum Swift compiler version:** 5.0.0 \ No newline at end of file diff --git a/docs/description/cyclomatic_complexity.md b/docs/description/cyclomatic_complexity.md index de6f623..be3d535 100644 --- a/docs/description/cyclomatic_complexity.md +++ b/docs/description/cyclomatic_complexity.md @@ -8,7 +8,38 @@ Complexity of function bodies should be limited. * **Kind:** metrics * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning: 10, error: 20, ignores_case_statements: false +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ warning + + 10 +
+ error + + 20 +
+ ignores_case_statements + + false +
## Non Triggering Examples diff --git a/docs/description/deployment_target.md b/docs/description/deployment_target.md index 49d17d8..741eff0 100644 --- a/docs/description/deployment_target.md +++ b/docs/description/deployment_target.md @@ -8,7 +8,86 @@ Availability checks or attributes shouldn't be using older versions that are sat * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, iOSApplicationExtension_deployment_target: 7.0, iOS_deployment_target: 7.0, macOSApplicationExtension_deployment_target: 10.9, macOS_deployment_target: 10.9, tvOSApplicationExtension_deployment_target: 9.0, tvOS_deployment_target: 9.0, watchOSApplicationExtension_deployment_target: 1.0, watchOS_deployment_target: 1.0 +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ iOSApplicationExtension_deployment_target + + 7.0 +
+ iOS_deployment_target + + 7.0 +
+ macOSApplicationExtension_deployment_target + + 10.9 +
+ macOS_deployment_target + + 10.9 +
+ tvOSApplicationExtension_deployment_target + + 9.0 +
+ tvOS_deployment_target + + 9.0 +
+ watchOSApplicationExtension_deployment_target + + 1.0 +
+ watchOS_deployment_target + + 1.0 +
## Non Triggering Examples diff --git a/docs/description/description.json b/docs/description/description.json index 7b22d6d..4e671bf 100644 --- a/docs/description/description.json +++ b/docs/description/description.json @@ -1,12 +1,12 @@ [ { "patternId" : "accessibility_label_for_image", "title" : "Accessibility Label for Image", - "description" : "All Images that provide context should have an accessibility label. Purely decorative images can be hidden from accessibility.", + "description" : "Images that provide context should have an accessibility label or should be explicitly hidden from accessibility", "parameters" : [ ] }, { "patternId" : "accessibility_trait_for_button", "title" : "Accessibility Trait for Button", - "description" : "All views with tap gestures added should include the .isButton accessibility trait. If a tap opens an external link the .isLink trait should be used instead.", + "description" : "All views with tap gestures added should include the .isButton or the .isLink accessibility traits", "parameters" : [ ] }, { "patternId" : "anonymous_argument_in_multiline_closure", @@ -16,47 +16,52 @@ }, { "patternId" : "anyobject_protocol", "title" : "AnyObject Protocol", - "description" : "Prefer using `AnyObject` over `class` for class-only protocols.", + "description" : "Prefer using `AnyObject` over `class` for class-only protocols", "parameters" : [ ] }, { "patternId" : "array_init", "title" : "Array Init", - "description" : "Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array.", + "description" : "Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array", "parameters" : [ ] }, { "patternId" : "attributes", "title" : "Attributes", - "description" : "Attributes should be on their own lines in functions and types, but on the same line as variables and imports.", + "description" : "Attributes should be on their own lines in functions and types, but on the same line as variables and imports", "parameters" : [ ] }, { "patternId" : "balanced_xctest_lifecycle", - "title" : "Balanced XCTest life-cycle", - "description" : "Test classes must implement balanced setUp and tearDown methods.", + "title" : "Balanced XCTest Life Cycle", + "description" : "Test classes must implement balanced setUp and tearDown methods", + "parameters" : [ ] +}, { + "patternId" : "blanket_disable_command", + "title" : "Blanket Disable Command", + "description" : "swiftlint:disable commands should be re-enabled before the end of the file", "parameters" : [ ] }, { "patternId" : "block_based_kvo", "title" : "Block Based KVO", - "description" : "Prefer the new block based KVO API with keypaths when using Swift 3.2 or later.", + "description" : "Prefer the new block based KVO API with keypaths when using Swift 3.2 or later", "parameters" : [ ] }, { "patternId" : "capture_variable", "title" : "Capture Variable", - "description" : "Non-constant variables should not be listed in a closure's capture list to avoid confusion about closures capturing variables at creation time.", + "description" : "Non-constant variables should not be listed in a closure's capture list to avoid confusion about closures capturing variables at creation time", "parameters" : [ ] }, { "patternId" : "class_delegate_protocol", "title" : "Class Delegate Protocol", - "description" : "Delegate protocols should be class-only so they can be weakly referenced.", + "description" : "Delegate protocols should be class-only so they can be weakly referenced", "parameters" : [ ] }, { "patternId" : "closing_brace", "title" : "Closing Brace Spacing", - "description" : "Closing brace with closing parenthesis should not have any whitespaces in the middle.", + "description" : "Closing brace with closing parenthesis should not have any whitespaces in the middle", "parameters" : [ ] }, { "patternId" : "closure_body_length", "title" : "Closure Body Length", - "description" : "Closure bodies should not span too many lines.", + "description" : "Closure bodies should not span too many lines", "parameters" : [ ] }, { "patternId" : "closure_end_indentation", @@ -66,12 +71,12 @@ }, { "patternId" : "closure_parameter_position", "title" : "Closure Parameter Position", - "description" : "Closure parameters should be on the same line as opening brace.", + "description" : "Closure parameters should be on the same line as opening brace", "parameters" : [ ] }, { "patternId" : "closure_spacing", "title" : "Closure Spacing", - "description" : "Closure expressions should have a single space inside each brace.", + "description" : "Closure expressions should have a single space inside each brace", "parameters" : [ ] }, { "patternId" : "collection_alignment", @@ -81,12 +86,12 @@ }, { "patternId" : "colon", "title" : "Colon Spacing", - "description" : "Colons should be next to the identifier when specifying a type and next to the key in dictionary literals.", + "description" : "Colons should be next to the identifier when specifying a type and next to the key in dictionary literals", "parameters" : [ ] }, { "patternId" : "comma", "title" : "Comma Spacing", - "description" : "There should be no space before and one after any comma.", + "description" : "There should be no space before and one after any comma", "parameters" : [ ] }, { "patternId" : "comma_inheritance", @@ -96,7 +101,7 @@ }, { "patternId" : "comment_spacing", "title" : "Comment Spacing", - "description" : "Prefer at least one space after slashes for comments.", + "description" : "Prefer at least one space after slashes for comments", "parameters" : [ ] }, { "patternId" : "compiler_protocol_init", @@ -115,33 +120,33 @@ "parameters" : [ ] }, { "patternId" : "contains_over_filter_count", - "title" : "Contains Over Filter Count", - "description" : "Prefer `contains` over comparing `filter(where:).count` to 0.", + "title" : "Contains over Filter Count", + "description" : "Prefer `contains` over comparing `filter(where:).count` to 0", "parameters" : [ ] }, { "patternId" : "contains_over_filter_is_empty", - "title" : "Contains Over Filter Is Empty", + "title" : "Contains over Filter is Empty", "description" : "Prefer `contains` over using `filter(where:).isEmpty`", "parameters" : [ ] }, { "patternId" : "contains_over_first_not_nil", - "title" : "Contains over first not nil", + "title" : "Contains over First not Nil", "description" : "Prefer `contains` over `first(where:) != nil` and `firstIndex(where:) != nil`.", "parameters" : [ ] }, { "patternId" : "contains_over_range_nil_comparison", - "title" : "Contains over range(of:) comparison to nil", - "description" : "Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`.", + "title" : "Contains over Range Comparision to Nil", + "description" : "Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`", "parameters" : [ ] }, { "patternId" : "control_statement", "title" : "Control Statement", - "description" : "`if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses.", + "description" : "`if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses", "parameters" : [ ] }, { "patternId" : "convenience_type", "title" : "Convenience Type", - "description" : "Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation.", + "description" : "Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation", "parameters" : [ ] }, { "patternId" : "custom_rules", @@ -158,10 +163,15 @@ "title" : "Deployment Target", "description" : "Availability checks or attributes shouldn't be using older versions that are satisfied by the deployment target.", "parameters" : [ ] +}, { + "patternId" : "direct_return", + "title" : "Direct Return", + "description" : "Directly return the expression instead of assigning it to a variable first", + "parameters" : [ ] }, { "patternId" : "discarded_notification_center_observer", "title" : "Discarded Notification Center Observer", - "description" : "When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later.", + "description" : "When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later", "parameters" : [ ] }, { "patternId" : "discouraged_assert", @@ -171,87 +181,92 @@ }, { "patternId" : "discouraged_direct_init", "title" : "Discouraged Direct Initialization", - "description" : "Discouraged direct initialization of types that can be harmful.", + "description" : "Discouraged direct initialization of types that can be harmful", "parameters" : [ ] }, { "patternId" : "discouraged_none_name", "title" : "Discouraged None Name", - "description" : "Discourages name cases/static members `none`, which can conflict with `Optional.none`.", + "description" : "Enum cases and static members named `none` are discouraged as they can conflict with `Optional.none`.", "parameters" : [ ] }, { "patternId" : "discouraged_object_literal", "title" : "Discouraged Object Literal", - "description" : "Prefer initializers over object literals.", + "description" : "Prefer initializers over object literals", "parameters" : [ ] }, { "patternId" : "discouraged_optional_boolean", "title" : "Discouraged Optional Boolean", - "description" : "Prefer non-optional booleans over optional booleans.", + "description" : "Prefer non-optional booleans over optional booleans", "parameters" : [ ] }, { "patternId" : "discouraged_optional_collection", "title" : "Discouraged Optional Collection", - "description" : "Prefer empty collection over optional collection.", + "description" : "Prefer empty collection over optional collection", + "parameters" : [ ] +}, { + "patternId" : "duplicate_conditions", + "title" : "Duplicate Conditions", + "description" : "Duplicate sets of conditions in the same branch instruction should be avoided", "parameters" : [ ] }, { "patternId" : "duplicate_enum_cases", "title" : "Duplicate Enum Cases", - "description" : "Enum can't contain multiple cases with the same name.", + "description" : "Enum shouldn't contain multiple cases with the same name", "parameters" : [ ] }, { "patternId" : "duplicate_imports", "title" : "Duplicate Imports", - "description" : "Imports should be unique.", + "description" : "Imports should be unique", "parameters" : [ ] }, { "patternId" : "duplicated_key_in_dictionary_literal", "title" : "Duplicated Key in Dictionary Literal", - "description" : "Dictionary literals with duplicated keys will crash in runtime.", + "description" : "Dictionary literals with duplicated keys will crash at runtime", "parameters" : [ ] }, { "patternId" : "dynamic_inline", "title" : "Dynamic Inline", - "description" : "Avoid using 'dynamic' and '@inline(__always)' together.", + "description" : "Avoid using 'dynamic' and '@inline(__always)' together", "parameters" : [ ] }, { "patternId" : "empty_collection_literal", "title" : "Empty Collection Literal", - "description" : "Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal.", + "description" : "Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal", "parameters" : [ ] }, { "patternId" : "empty_count", "title" : "Empty Count", - "description" : "Prefer checking `isEmpty` over comparing `count` to zero.", + "description" : "Prefer checking `isEmpty` over comparing `count` to zero", "parameters" : [ ] }, { "patternId" : "empty_enum_arguments", "title" : "Empty Enum Arguments", - "description" : "Arguments can be omitted when matching enums with associated values if they are not used.", + "description" : "Arguments can be omitted when matching enums with associated values if they are not used", "parameters" : [ ] }, { "patternId" : "empty_parameters", "title" : "Empty Parameters", - "description" : "Prefer `() -> ` over `Void -> `.", + "description" : "Prefer `() -> ` over `Void -> `", "parameters" : [ ] }, { "patternId" : "empty_parentheses_with_trailing_closure", "title" : "Empty Parentheses with Trailing Closure", - "description" : "When using trailing closures, empty parentheses should be avoided after the method call.", + "description" : "When using trailing closures, empty parentheses should be avoided after the method call", "parameters" : [ ] }, { "patternId" : "empty_string", "title" : "Empty String", - "description" : "Prefer checking `isEmpty` over comparing `string` to an empty string literal.", + "description" : "Prefer checking `isEmpty` over comparing `string` to an empty string literal", "parameters" : [ ] }, { "patternId" : "empty_xctest_method", "title" : "Empty XCTest Method", - "description" : "Empty XCTest method should be avoided.", + "description" : "Empty XCTest method should be avoided", "parameters" : [ ] }, { "patternId" : "enum_case_associated_values_count", "title" : "Enum Case Associated Values Count", - "description" : "Number of associated values in an enum case should be low", + "description" : "The number of associated values in an enum case should be low.", "parameters" : [ ] }, { "patternId" : "expiring_todo", @@ -261,27 +276,27 @@ }, { "patternId" : "explicit_acl", "title" : "Explicit ACL", - "description" : "All declarations should specify Access Control Level keywords explicitly.", + "description" : "All declarations should specify Access Control Level keywords explicitly", "parameters" : [ ] }, { "patternId" : "explicit_enum_raw_value", "title" : "Explicit Enum Raw Value", - "description" : "Enums should be explicitly assigned their raw values.", + "description" : "Enums should be explicitly assigned their raw values", "parameters" : [ ] }, { "patternId" : "explicit_init", "title" : "Explicit Init", - "description" : "Explicitly calling .init() should be avoided.", + "description" : "Explicitly calling .init() should be avoided", "parameters" : [ ] }, { "patternId" : "explicit_self", "title" : "Explicit Self", - "description" : "Instance variables and functions should be explicitly accessed with 'self.'.", + "description" : "Instance variables and functions should be explicitly accessed with 'self.'", "parameters" : [ ] }, { "patternId" : "explicit_top_level_acl", "title" : "Explicit Top Level ACL", - "description" : "Top-level declarations should specify Access Control Level keywords explicitly.", + "description" : "Top-level declarations should specify Access Control Level keywords explicitly", "parameters" : [ ] }, { "patternId" : "explicit_type_interface", @@ -296,12 +311,12 @@ }, { "patternId" : "fallthrough", "title" : "Fallthrough", - "description" : "Fallthrough should be avoided.", + "description" : "Fallthrough should be avoided", "parameters" : [ ] }, { "patternId" : "fatal_error_message", "title" : "Fatal Error Message", - "description" : "A fatalError call should have a message.", + "description" : "A fatalError call should have a message", "parameters" : [ ] }, { "patternId" : "file_header", @@ -316,12 +331,12 @@ }, { "patternId" : "file_name", "title" : "File Name", - "description" : "File name should match a type or extension declared in the file (if any).", + "description" : "File name should match a type or extension declared in the file (if any)", "parameters" : [ ] }, { "patternId" : "file_name_no_space", - "title" : "File Name No Space", - "description" : "File name should not contain any whitespace.", + "title" : "File Name no Space", + "description" : "File name should not contain any whitespace", "parameters" : [ ] }, { "patternId" : "file_types_order", @@ -331,42 +346,42 @@ }, { "patternId" : "first_where", "title" : "First Where", - "description" : "Prefer using `.first(where:)` over `.filter { }.first` in collections.", + "description" : "Prefer using `.first(where:)` over `.filter { }.first` in collections", "parameters" : [ ] }, { "patternId" : "flatmap_over_map_reduce", - "title" : "FlatMap over map and reduce", - "description" : "Prefer `flatMap` over `map` followed by `reduce([], +)`.", + "title" : "Flat Map over Map Reduce", + "description" : "Prefer `flatMap` over `map` followed by `reduce([], +)`", "parameters" : [ ] }, { "patternId" : "for_where", - "title" : "For Where", - "description" : "`where` clauses are preferred over a single `if` inside a `for`.", + "title" : "Prefer For-Where", + "description" : "`where` clauses are preferred over a single `if` inside a `for`", "parameters" : [ ] }, { "patternId" : "force_cast", "title" : "Force Cast", - "description" : "Force casts should be avoided.", + "description" : "Force casts should be avoided", "parameters" : [ ] }, { "patternId" : "force_try", "title" : "Force Try", - "description" : "Force tries should be avoided.", + "description" : "Force tries should be avoided", "parameters" : [ ] }, { "patternId" : "force_unwrapping", "title" : "Force Unwrapping", - "description" : "Force unwrapping should be avoided.", + "description" : "Force unwrapping should be avoided", "parameters" : [ ] }, { "patternId" : "function_body_length", "title" : "Function Body Length", - "description" : "Functions bodies should not span too many lines.", + "description" : "Function bodies should not span too many lines", "parameters" : [ ] }, { "patternId" : "function_default_parameter_at_end", "title" : "Function Default Parameter at End", - "description" : "Prefer to locate parameters with defaults toward the end of the parameter list.", + "description" : "Prefer to locate parameters with defaults toward the end of the parameter list", "parameters" : [ ] }, { "patternId" : "function_parameter_count", @@ -381,17 +396,17 @@ }, { "patternId" : "ibinspectable_in_extension", "title" : "IBInspectable in Extension", - "description" : "Extensions shouldn't add @IBInspectable properties.", + "description" : "Extensions shouldn't add @IBInspectable properties", "parameters" : [ ] }, { "patternId" : "identical_operands", "title" : "Identical Operands", - "description" : "Comparing two identical operands is likely a mistake.", + "description" : "Comparing two identical operands is likely a mistake", "parameters" : [ ] }, { "patternId" : "identifier_name", "title" : "Identifier Name", - "description" : "Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared static and immutable. Variable names should not be too long or too short.", + "description" : "Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared as static. Variable names should not be too long or too short.", "parameters" : [ ] }, { "patternId" : "implicit_getter", @@ -401,17 +416,17 @@ }, { "patternId" : "implicit_return", "title" : "Implicit Return", - "description" : "Prefer implicit returns in closures, functions and getters.", + "description" : "Prefer implicit returns in closures, functions and getters", "parameters" : [ ] }, { "patternId" : "implicitly_unwrapped_optional", "title" : "Implicitly Unwrapped Optional", - "description" : "Implicitly unwrapped optionals should be avoided when possible.", + "description" : "Implicitly unwrapped optionals should be avoided when possible", "parameters" : [ ] }, { "patternId" : "inclusive_language", "title" : "Inclusive Language", - "description" : "Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status", + "description" : "Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status.", "parameters" : [ ] }, { "patternId" : "indentation_width", @@ -421,17 +436,22 @@ }, { "patternId" : "inert_defer", "title" : "Inert Defer", - "description" : "If defer is at the end of its parent scope, it will be executed right where it is anyway.", + "description" : "If defer is at the end of its parent scope, it will be executed right where it is anyway", + "parameters" : [ ] +}, { + "patternId" : "invalid_swiftlint_command", + "title" : "Invalid SwiftLint Command", + "description" : "swiftlint command does not have a valid action or modifier", "parameters" : [ ] }, { "patternId" : "is_disjoint", "title" : "Is Disjoint", - "description" : "Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty`.", + "description" : "Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty`", "parameters" : [ ] }, { "patternId" : "joined_default_parameter", "title" : "Joined Default Parameter", - "description" : "Discouraged explicit usage of the default separator.", + "description" : "Discouraged explicit usage of the default separator", "parameters" : [ ] }, { "patternId" : "large_tuple", @@ -441,12 +461,12 @@ }, { "patternId" : "last_where", "title" : "Last Where", - "description" : "Prefer using `.last(where:)` over `.filter { }.last` in collections.", + "description" : "Prefer using `.last(where:)` over `.filter { }.last` in collections", "parameters" : [ ] }, { "patternId" : "leading_whitespace", "title" : "Leading Whitespace", - "description" : "Files should not contain leading whitespace.", + "description" : "Files should not contain leading whitespace", "parameters" : [ ] }, { "patternId" : "legacy_cggeometry_functions", @@ -456,12 +476,12 @@ }, { "patternId" : "legacy_constant", "title" : "Legacy Constant", - "description" : "Struct-scoped constants are preferred over legacy global constants.", + "description" : "Struct-scoped constants are preferred over legacy global constants", "parameters" : [ ] }, { "patternId" : "legacy_constructor", "title" : "Legacy Constructor", - "description" : "Swift constructors are preferred over legacy convenience functions.", + "description" : "Swift constructors are preferred over legacy convenience functions", "parameters" : [ ] }, { "patternId" : "legacy_hashing", @@ -471,7 +491,7 @@ }, { "patternId" : "legacy_multiple", "title" : "Legacy Multiple", - "description" : "Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`).", + "description" : "Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`)", "parameters" : [ ] }, { "patternId" : "legacy_nsgeometry_functions", @@ -486,12 +506,12 @@ }, { "patternId" : "legacy_random", "title" : "Legacy Random", - "description" : "Prefer using `type.random(in:)` over legacy functions.", + "description" : "Prefer using `type.random(in:)` over legacy functions", "parameters" : [ ] }, { "patternId" : "let_var_whitespace", "title" : "Variable Declaration Whitespace", - "description" : "Let and var should be separated from other statements by a blank line.", + "description" : "Variable declarations should be separated from other statements by a blank line", "parameters" : [ ] }, { "patternId" : "line_length", @@ -501,16 +521,16 @@ }, { "patternId" : "literal_expression_end_indentation", "title" : "Literal Expression End Indentation", - "description" : "Array and dictionary literal end should have the same indentation as the line that started it.", + "description" : "Array and dictionary literal end should have the same indentation as the line that started it", "parameters" : [ ] }, { "patternId" : "local_doc_comment", "title" : "Local Doc Comment", - "description" : "Doc comments shouldn't be used in local scopes. Use regular comments.", + "description" : "Prefer regular comments over doc comments in local scopes", "parameters" : [ ] }, { "patternId" : "lower_acl_than_parent", - "title" : "Lower ACL than parent", + "title" : "Lower ACL than Parent", "description" : "Ensure declarations have a lower access control level than their enclosing parent", "parameters" : [ ] }, { @@ -531,37 +551,37 @@ }, { "patternId" : "multiline_arguments", "title" : "Multiline Arguments", - "description" : "Arguments should be either on the same line, or one per line.", + "description" : "Arguments should be either on the same line, or one per line", "parameters" : [ ] }, { "patternId" : "multiline_arguments_brackets", "title" : "Multiline Arguments Brackets", - "description" : "Multiline arguments should have their surrounding brackets in a new line.", + "description" : "Multiline arguments should have their surrounding brackets in a new line", "parameters" : [ ] }, { "patternId" : "multiline_function_chains", "title" : "Multiline Function Chains", - "description" : "Chained function calls should be either on the same line, or one per line.", + "description" : "Chained function calls should be either on the same line, or one per line", "parameters" : [ ] }, { "patternId" : "multiline_literal_brackets", "title" : "Multiline Literal Brackets", - "description" : "Multiline literals should have their surrounding brackets in a new line.", + "description" : "Multiline literals should have their surrounding brackets in a new line", "parameters" : [ ] }, { "patternId" : "multiline_parameters", "title" : "Multiline Parameters", - "description" : "Functions and methods parameters should be either on the same line, or one per line.", + "description" : "Functions and methods parameters should be either on the same line, or one per line", "parameters" : [ ] }, { "patternId" : "multiline_parameters_brackets", "title" : "Multiline Parameters Brackets", - "description" : "Multiline parameters should have their surrounding brackets in a new line.", + "description" : "Multiline parameters should have their surrounding brackets in a new line", "parameters" : [ ] }, { "patternId" : "multiple_closures_with_trailing_closure", "title" : "Multiple Closures with Trailing Closure", - "description" : "Trailing closure syntax should not be used when passing more than one closure argument.", + "description" : "Trailing closure syntax should not be used when passing more than one closure argument", "parameters" : [ ] }, { "patternId" : "nesting", @@ -571,7 +591,7 @@ }, { "patternId" : "nimble_operator", "title" : "Nimble Operator", - "description" : "Prefer Nimble operator overloads over free matcher functions.", + "description" : "Prefer Nimble operator overloads over free matcher functions", "parameters" : [ ] }, { "patternId" : "no_extension_access_modifier", @@ -580,113 +600,118 @@ "parameters" : [ ] }, { "patternId" : "no_fallthrough_only", - "title" : "No Fallthrough Only", - "description" : "Fallthroughs can only be used if the `case` contains at least one other statement.", + "title" : "No Fallthrough only", + "description" : "Fallthroughs can only be used if the `case` contains at least one other statement", "parameters" : [ ] }, { "patternId" : "no_grouping_extension", "title" : "No Grouping Extension", - "description" : "Extensions shouldn't be used to group code within the same source file.", + "description" : "Extensions shouldn't be used to group code within the same source file", "parameters" : [ ] }, { "patternId" : "no_magic_numbers", "title" : "No Magic Numbers", - "description" : "Magic numbers should be replaced by named constants.", + "description" : "Magic numbers should be replaced by named constants", "parameters" : [ ] }, { "patternId" : "no_space_in_method_call", "title" : "No Space in Method Call", - "description" : "Don't add a space between the method name and the parentheses.", + "description" : "Don't add a space between the method name and the parentheses", "parameters" : [ ] }, { "patternId" : "notification_center_detachment", "title" : "Notification Center Detachment", - "description" : "An object should only remove itself as an observer in `deinit`.", + "description" : "An object should only remove itself as an observer in `deinit`", "parameters" : [ ] }, { "patternId" : "ns_number_init_as_function_reference", "title" : "NSNumber Init as Function Reference", - "description" : "Passing `NSNumber.init` or `NSDecimalNumber.init` as a function reference is dangerous as it can cause the wrong initializer to be used, causing crashes. Use `.init(value:)` instead.", + "description" : "Passing `NSNumber.init` or `NSDecimalNumber.init` as a function reference is dangerous as it can cause the wrong initializer to be used, causing crashes; use `.init(value:)` instead", "parameters" : [ ] }, { "patternId" : "nslocalizedstring_key", "title" : "NSLocalizedString Key", - "description" : "Static strings should be used as key/comment in NSLocalizedString in order for genstrings to work.", + "description" : "Static strings should be used as key/comment in NSLocalizedString in order for genstrings to work", "parameters" : [ ] }, { "patternId" : "nslocalizedstring_require_bundle", "title" : "NSLocalizedString Require Bundle", - "description" : "Calls to NSLocalizedString should specify the bundle which contains the strings file.", + "description" : "Calls to NSLocalizedString should specify the bundle which contains the strings file", "parameters" : [ ] }, { "patternId" : "nsobject_prefer_isequal", "title" : "NSObject Prefer isEqual", - "description" : "NSObject subclasses should implement isEqual instead of ==.", + "description" : "NSObject subclasses should implement isEqual instead of ==", "parameters" : [ ] }, { "patternId" : "number_separator", "title" : "Number Separator", - "description" : "Underscores should be used as thousand separator in large decimal numbers.", + "description" : "Underscores should be used as thousand separator in large numbers with a configurable number of digits. In other words, there should be an underscore after every 3 digits in the integral as well as the fractional part of a number.", "parameters" : [ ] }, { "patternId" : "object_literal", "title" : "Object Literal", - "description" : "Prefer object literals over image and color inits.", + "description" : "Prefer object literals over image and color inits", "parameters" : [ ] }, { "patternId" : "opening_brace", "title" : "Opening Brace Spacing", - "description" : "Opening braces should be preceded by a single space and on the same line as the declaration.", + "description" : "Opening braces should be preceded by a single space and on the same line as the declaration", "parameters" : [ ] }, { "patternId" : "operator_usage_whitespace", "title" : "Operator Usage Whitespace", - "description" : "Operators should be surrounded by a single whitespace when they are being used.", + "description" : "Operators should be surrounded by a single whitespace when they are being used", "parameters" : [ ] }, { "patternId" : "operator_whitespace", "title" : "Operator Function Whitespace", - "description" : "Operators should be surrounded by a single whitespace when defining them.", + "description" : "Operators should be surrounded by a single whitespace when defining them", "parameters" : [ ] }, { "patternId" : "optional_enum_case_matching", "title" : "Optional Enum Case Match", - "description" : "Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above.", + "description" : "Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above", "parameters" : [ ] }, { "patternId" : "orphaned_doc_comment", "title" : "Orphaned Doc Comment", - "description" : "A doc comment should be attached to a declaration.", + "description" : "A doc comment should be attached to a declaration", "parameters" : [ ] }, { "patternId" : "overridden_super_call", - "title" : "Overridden methods call super", - "description" : "Some overridden methods should always call super", + "title" : "Overridden Method Calls Super", + "description" : "Some overridden methods should always call super.", "parameters" : [ ] }, { "patternId" : "override_in_extension", "title" : "Override in Extension", - "description" : "Extensions shouldn't override declarations.", + "description" : "Extensions shouldn't override declarations", "parameters" : [ ] }, { "patternId" : "pattern_matching_keywords", "title" : "Pattern Matching Keywords", - "description" : "Combine multiple pattern matching bindings by moving keywords out of tuples.", + "description" : "Combine multiple pattern matching bindings by moving keywords out of tuples", + "parameters" : [ ] +}, { + "patternId" : "period_spacing", + "title" : "Period Spacing", + "description" : "Periods should not be followed by more than one space", "parameters" : [ ] }, { "patternId" : "prefer_nimble", "title" : "Prefer Nimble", - "description" : "Prefer Nimble matchers over XCTAssert functions.", + "description" : "Prefer Nimble matchers over XCTAssert functions", "parameters" : [ ] }, { "patternId" : "prefer_self_in_static_references", "title" : "Prefer Self in Static References", - "description" : "Use `Self` to refer to the surrounding type name.", + "description" : "Use `Self` to refer to the surrounding type name", "parameters" : [ ] }, { "patternId" : "prefer_self_type_over_type_of_self", "title" : "Prefer Self Type Over Type of Self", - "description" : "Prefer `Self` over `type(of: self)` when accessing properties or calling methods.", + "description" : "Prefer `Self` over `type(of: self)` when accessing properties or calling methods", "parameters" : [ ] }, { "patternId" : "prefer_zero_over_explicit_init", @@ -696,47 +721,47 @@ }, { "patternId" : "prefixed_toplevel_constant", "title" : "Prefixed Top-Level Constant", - "description" : "Top-level constants should be prefixed by `k`.", + "description" : "Top-level constants should be prefixed by `k`", "parameters" : [ ] }, { "patternId" : "private_action", "title" : "Private Actions", - "description" : "IBActions should be private.", + "description" : "IBActions should be private", "parameters" : [ ] }, { "patternId" : "private_outlet", "title" : "Private Outlets", - "description" : "IBOutlets should be private to avoid leaking UIKit to higher layers.", + "description" : "IBOutlets should be private to avoid leaking UIKit to higher layers", "parameters" : [ ] }, { "patternId" : "private_over_fileprivate", - "title" : "Private over fileprivate", - "description" : "Prefer `private` over `fileprivate` declarations.", + "title" : "Private over Fileprivate", + "description" : "Prefer `private` over `fileprivate` declarations", "parameters" : [ ] }, { "patternId" : "private_subject", "title" : "Private Combine Subject", - "description" : "Combine Subject should be private.", + "description" : "Combine Subject should be private", "parameters" : [ ] }, { "patternId" : "private_unit_test", "title" : "Private Unit Test", - "description" : "Unit tests marked private are silently skipped.", + "description" : "Unit tests marked private are silently skipped", "parameters" : [ ] }, { "patternId" : "prohibited_interface_builder", "title" : "Prohibited Interface Builder", - "description" : "Creating views using Interface Builder should be avoided.", + "description" : "Creating views using Interface Builder should be avoided", "parameters" : [ ] }, { "patternId" : "prohibited_super_call", - "title" : "Prohibited calls to super", - "description" : "Some methods should not call super", + "title" : "Prohibited Calls to Super", + "description" : "Some methods should not call super.", "parameters" : [ ] }, { "patternId" : "protocol_property_accessors_order", "title" : "Protocol Property Accessors Order", - "description" : "When declaring properties in protocols, the order of accessors should be `get set`.", + "description" : "When declaring properties in protocols, the order of accessors should be `get set`", "parameters" : [ ] }, { "patternId" : "quick_discouraged_call", @@ -746,32 +771,32 @@ }, { "patternId" : "quick_discouraged_focused_test", "title" : "Quick Discouraged Focused Test", - "description" : "Discouraged focused test. Other tests won't run while this one is focused.", + "description" : "Non-focused tests won't run as long as this test is focused", "parameters" : [ ] }, { "patternId" : "quick_discouraged_pending_test", "title" : "Quick Discouraged Pending Test", - "description" : "Discouraged pending test. This test won't run while it's marked as pending.", + "description" : "This test won't run as long as it's marked pending", "parameters" : [ ] }, { "patternId" : "raw_value_for_camel_cased_codable_enum", - "title" : "Raw Value For Camel Cased Codable Enum", - "description" : "Camel cased cases of Codable String enums should have raw value.", + "title" : "Raw Value for Camel Cased Codable Enum", + "description" : "Camel cased cases of Codable String enums should have raw values", "parameters" : [ ] }, { "patternId" : "reduce_boolean", "title" : "Reduce Boolean", - "description" : "Prefer using `.allSatisfy()` or `.contains()` over `reduce(true)` or `reduce(false)`", + "description" : "Prefer using `.allSatisfy()` or `.contains()` over `reduce(true)` or `reduce(false)`.", "parameters" : [ ] }, { "patternId" : "reduce_into", - "title" : "Reduce Into", + "title" : "Reduce into", "description" : "Prefer `reduce(into:_:)` over `reduce(_:_:)` for copy-on-write types", "parameters" : [ ] }, { "patternId" : "redundant_discardable_let", "title" : "Redundant Discardable Let", - "description" : "Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function.", + "description" : "Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function", "parameters" : [ ] }, { "patternId" : "redundant_nil_coalescing", @@ -781,22 +806,27 @@ }, { "patternId" : "redundant_objc_attribute", "title" : "Redundant @objc Attribute", - "description" : "Objective-C attribute (@objc) is redundant in declaration.", + "description" : "Objective-C attribute (@objc) is redundant in declaration", "parameters" : [ ] }, { "patternId" : "redundant_optional_initialization", "title" : "Redundant Optional Initialization", - "description" : "Initializing an optional variable with nil is redundant.", + "description" : "Initializing an optional variable with nil is redundant", + "parameters" : [ ] +}, { + "patternId" : "redundant_self_in_closure", + "title" : "Redundant Self in Closure", + "description" : "Explicit use of 'self' is not required", "parameters" : [ ] }, { "patternId" : "redundant_set_access_control", - "title" : "Redundant Set Access Control Rule", - "description" : "Property setter access level shouldn't be explicit if it's the same as the variable access level.", + "title" : "Redundant Access Control for Setter", + "description" : "Property setter access level shouldn't be explicit if it's the same as the variable access level", "parameters" : [ ] }, { "patternId" : "redundant_string_enum_value", "title" : "Redundant String Enum Value", - "description" : "String enum values can be omitted when they are equal to the enumcase name.", + "description" : "String enum values can be omitted when they are equal to the enumcase name", "parameters" : [ ] }, { "patternId" : "redundant_type_annotation", @@ -806,12 +836,12 @@ }, { "patternId" : "redundant_void_return", "title" : "Redundant Void Return", - "description" : "Returning Void in a function declaration is redundant.", + "description" : "Returning Void in a function declaration is redundant", "parameters" : [ ] }, { "patternId" : "required_deinit", "title" : "Required Deinit", - "description" : "Classes should have an explicit deinit method.", + "description" : "Classes should have an explicit deinit method", "parameters" : [ ] }, { "patternId" : "required_enum_case", @@ -821,12 +851,12 @@ }, { "patternId" : "return_arrow_whitespace", "title" : "Returning Whitespace", - "description" : "Return arrow and return type should be separated by a single space or on a separate line.", + "description" : "Return arrow and return type should be separated by a single space or on a separate line", "parameters" : [ ] }, { "patternId" : "return_value_from_void_function", "title" : "Return Value from Void Function", - "description" : "Returning values from Void functions should be avoided.", + "description" : "Returning values from Void functions should be avoided", "parameters" : [ ] }, { "patternId" : "self_binding", @@ -836,12 +866,12 @@ }, { "patternId" : "self_in_property_initialization", "title" : "Self in Property Initialization", - "description" : "`self` refers to the unapplied `NSObject.self()` method, which is likely not expected. Make the variable `lazy` to be able to refer to the current instance or use `ClassName.self`.", + "description" : "`self` refers to the unapplied `NSObject.self()` method, which is likely not expected; make the variable `lazy` to be able to refer to the current instance or use `ClassName.self`", "parameters" : [ ] }, { "patternId" : "shorthand_operator", "title" : "Shorthand Operator", - "description" : "Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning.", + "description" : "Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning", "parameters" : [ ] }, { "patternId" : "shorthand_optional_binding", @@ -853,6 +883,11 @@ "title" : "Single Test Class", "description" : "Test files should contain a single QuickSpec or XCTestCase class.", "parameters" : [ ] +}, { + "patternId" : "sorted_enum_cases", + "title" : "Sorted Enum Cases", + "description" : "Enum cases should be sorted", + "parameters" : [ ] }, { "patternId" : "sorted_first_last", "title" : "Min or Max over Sorted First or Last", @@ -861,33 +896,38 @@ }, { "patternId" : "sorted_imports", "title" : "Sorted Imports", - "description" : "Imports should be sorted.", + "description" : "Imports should be sorted", "parameters" : [ ] }, { "patternId" : "statement_position", "title" : "Statement Position", - "description" : "Else and catch should be on the same line, one space after the previous declaration.", + "description" : "Else and catch should be on the same line, one space after the previous declaration", "parameters" : [ ] }, { "patternId" : "static_operator", "title" : "Static Operator", - "description" : "Operators should be declared as static functions, not free functions.", + "description" : "Operators should be declared as static functions, not free functions", "parameters" : [ ] }, { "patternId" : "strict_fileprivate", - "title" : "Strict fileprivate", - "description" : "`fileprivate` should be avoided.", + "title" : "Strict Fileprivate", + "description" : "`fileprivate` should be avoided", "parameters" : [ ] }, { "patternId" : "strong_iboutlet", "title" : "Strong IBOutlet", - "description" : "@IBOutlets shouldn't be declared as weak.", + "description" : "@IBOutlets shouldn't be declared as weak", "parameters" : [ ] }, { "patternId" : "superfluous_disable_command", "title" : "Superfluous Disable Command", "description" : "SwiftLint 'disable' commands are superfluous when the disabled rule would not have triggered a violation in the disabled region. Use \" - \" if you wish to document a command.", "parameters" : [ ] +}, { + "patternId" : "superfluous_else", + "title" : "Superfluous Else", + "description" : "Else branches should be avoided when the previous if-block exits the current scope", + "parameters" : [ ] }, { "patternId" : "switch_case_alignment", "title" : "Switch and Case Statement Alignment", @@ -895,7 +935,7 @@ "parameters" : [ ] }, { "patternId" : "switch_case_on_newline", - "title" : "Switch Case on Newline", + "title" : "Cases on Newline", "description" : "Cases inside a switch should always be on a newline", "parameters" : [ ] }, { @@ -905,8 +945,8 @@ "parameters" : [ ] }, { "patternId" : "test_case_accessibility", - "title" : "Test case accessibility", - "description" : "Test cases should only contain private non-test members.", + "title" : "Test Case Accessibility", + "description" : "Test cases should only contain private non-test members", "parameters" : [ ] }, { "patternId" : "todo", @@ -916,12 +956,12 @@ }, { "patternId" : "toggle_bool", "title" : "Toggle Bool", - "description" : "Prefer `someBool.toggle()` over `someBool = !someBool`.", + "description" : "Prefer `someBool.toggle()` over `someBool = !someBool`", "parameters" : [ ] }, { "patternId" : "trailing_closure", "title" : "Trailing Closure", - "description" : "Trailing closure syntax should be used whenever possible.", + "description" : "Trailing closure syntax should be used whenever possible", "parameters" : [ ] }, { "patternId" : "trailing_comma", @@ -931,22 +971,22 @@ }, { "patternId" : "trailing_newline", "title" : "Trailing Newline", - "description" : "Files should have a single trailing newline.", + "description" : "Files should have a single trailing newline", "parameters" : [ ] }, { "patternId" : "trailing_semicolon", "title" : "Trailing Semicolon", - "description" : "Lines should not have trailing semicolons.", + "description" : "Lines should not have trailing semicolons", "parameters" : [ ] }, { "patternId" : "trailing_whitespace", "title" : "Trailing Whitespace", - "description" : "Lines should not have trailing whitespace.", + "description" : "Lines should not have trailing whitespace", "parameters" : [ ] }, { "patternId" : "type_body_length", "title" : "Type Body Length", - "description" : "Type bodies should not span too many lines.", + "description" : "Type bodies should not span too many lines", "parameters" : [ ] }, { "patternId" : "type_contents_order", @@ -961,7 +1001,7 @@ }, { "patternId" : "typesafe_array_init", "title" : "Type-safe Array Init", - "description" : "Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array.", + "description" : "Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array", "parameters" : [ ] }, { "patternId" : "unavailable_condition", @@ -971,47 +1011,57 @@ }, { "patternId" : "unavailable_function", "title" : "Unavailable Function", - "description" : "Unimplemented functions should be marked as unavailable.", + "description" : "Unimplemented functions should be marked as unavailable", + "parameters" : [ ] +}, { + "patternId" : "unhandled_throwing_task", + "title" : "Unhandled Throwing Task", + "description" : "Errors thrown inside this task are not handled, which may be unexpected. Handle errors inside the task, or use `try await` to access the Tasks value and handle errors. See this forum thread for more details: https://forums.swift.org/t/task-initializer-with-throwing-closure-swallows-error/56066", "parameters" : [ ] }, { "patternId" : "unneeded_break_in_switch", "title" : "Unneeded Break in Switch", - "description" : "Avoid using unneeded break statements.", + "description" : "Avoid using unneeded break statements", "parameters" : [ ] }, { "patternId" : "unneeded_parentheses_in_closure_argument", "title" : "Unneeded Parentheses in Closure Argument", - "description" : "Parentheses are not needed when declaring closure arguments.", + "description" : "Parentheses are not needed when declaring closure arguments", + "parameters" : [ ] +}, { + "patternId" : "unneeded_synthesized_initializer", + "title" : "Unneeded Synthesized Initializer", + "description" : "Default or memberwise initializers that will be automatically synthesized do not need to be manually defined.", "parameters" : [ ] }, { "patternId" : "unowned_variable_capture", "title" : "Unowned Variable Capture", - "description" : "Prefer capturing references as weak to avoid potential crashes.", + "description" : "Prefer capturing references as weak to avoid potential crashes", "parameters" : [ ] }, { "patternId" : "untyped_error_in_catch", "title" : "Untyped Error in Catch", - "description" : "Catch statements should not declare error variables without type casting.", + "description" : "Catch statements should not declare error variables without type casting", "parameters" : [ ] }, { "patternId" : "unused_capture_list", "title" : "Unused Capture List", - "description" : "Unused reference in a capture list should be removed.", + "description" : "Unused reference in a capture list should be removed", "parameters" : [ ] }, { "patternId" : "unused_closure_parameter", "title" : "Unused Closure Parameter", - "description" : "Unused parameter in a closure should be replaced with _.", + "description" : "Unused parameter in a closure should be replaced with _", "parameters" : [ ] }, { "patternId" : "unused_control_flow_label", "title" : "Unused Control Flow Label", - "description" : "Unused control flow label should be removed.", + "description" : "Unused control flow label should be removed", "parameters" : [ ] }, { "patternId" : "unused_declaration", "title" : "Unused Declaration", - "description" : "Declarations should be referenced at least once within all files linted.", + "description" : "Declarations should be referenced at least once within all files linted", "parameters" : [ ] }, { "patternId" : "unused_enumerated", @@ -1021,7 +1071,7 @@ }, { "patternId" : "unused_import", "title" : "Unused Import", - "description" : "All imported modules should be required to make the file compile.", + "description" : "All imported modules should be required to make the file compile", "parameters" : [ ] }, { "patternId" : "unused_optional_binding", @@ -1031,7 +1081,7 @@ }, { "patternId" : "unused_setter_value", "title" : "Unused Setter Value", - "description" : "Setter value is not used.", + "description" : "Setter value is not used", "parameters" : [ ] }, { "patternId" : "valid_ibinspectable", @@ -1041,12 +1091,12 @@ }, { "patternId" : "vertical_parameter_alignment", "title" : "Vertical Parameter Alignment", - "description" : "Function parameters should be aligned vertically if they're in multiple lines in a declaration.", + "description" : "Function parameters should be aligned vertically if they're in multiple lines in a declaration", "parameters" : [ ] }, { "patternId" : "vertical_parameter_alignment_on_call", - "title" : "Vertical Parameter Alignment On Call", - "description" : "Function parameters should be aligned vertically if they're in multiple lines in a method call.", + "title" : "Vertical Parameter Alignment on Call", + "description" : "Function parameters should be aligned vertically if they're in multiple lines in a method call", "parameters" : [ ] }, { "patternId" : "vertical_whitespace", @@ -1055,47 +1105,47 @@ "parameters" : [ ] }, { "patternId" : "vertical_whitespace_between_cases", - "title" : "Vertical Whitespace Between Cases", - "description" : "Include a single empty line between switch cases.", + "title" : "Vertical Whitespace between Cases", + "description" : "Include a single empty line between switch cases", "parameters" : [ ] }, { "patternId" : "vertical_whitespace_closing_braces", "title" : "Vertical Whitespace before Closing Braces", - "description" : "Don't include vertical whitespace (empty line) before closing braces.", + "description" : "Don't include vertical whitespace (empty line) before closing braces", "parameters" : [ ] }, { "patternId" : "vertical_whitespace_opening_braces", "title" : "Vertical Whitespace after Opening Braces", - "description" : "Don't include vertical whitespace (empty line) after opening braces.", + "description" : "Don't include vertical whitespace (empty line) after opening braces", "parameters" : [ ] }, { "patternId" : "void_function_in_ternary", "title" : "Void Function in Ternary", - "description" : "Using ternary to call Void functions should be avoided.", + "description" : "Using ternary to call Void functions should be avoided", "parameters" : [ ] }, { "patternId" : "void_return", "title" : "Void Return", - "description" : "Prefer `-> Void` over `-> ()`.", + "description" : "Prefer `-> Void` over `-> ()`", "parameters" : [ ] }, { "patternId" : "weak_delegate", "title" : "Weak Delegate", - "description" : "Delegates should be weak to avoid reference cycles.", + "description" : "Delegates should be weak to avoid reference cycles", "parameters" : [ ] }, { "patternId" : "xct_specific_matcher", "title" : "XCTest Specific Matcher", - "description" : "Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual`", + "description" : "Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual`.", "parameters" : [ ] }, { "patternId" : "xctfail_message", "title" : "XCTFail Message", - "description" : "An XCTFail call should include a description of the assertion.", + "description" : "An XCTFail call should include a description of the assertion", "parameters" : [ ] }, { "patternId" : "yoda_condition", - "title" : "Yoda condition rule", - "description" : "The constant literal should be placed on the right-hand side of the comparison operator.", + "title" : "Yoda Condition", + "description" : "The constant literal should be placed on the right-hand side of the comparison operator", "parameters" : [ ] } ] diff --git a/docs/description/direct_return.md b/docs/description/direct_return.md new file mode 100644 index 0000000..6402af4 --- /dev/null +++ b/docs/description/direct_return.md @@ -0,0 +1,110 @@ +# Direct Return + +Directly return the expression instead of assigning it to a variable first + +* **Identifier:** direct_return +* **Enabled by default:** No +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ +## Non Triggering Examples + +```swift + func f() -> Int { + let b = 2 + let a = 1 + return b + } +``` + +```swift + struct S { + var a: Int { + var b = 1 + b = 2 + return b + } + } +``` + +```swift + func f() -> Int { + let b = 2 + f() + return b + } +``` + +```swift + func f() -> Int { + { i in + let b = 2 + return i + }(1) + } +``` + +## Triggering Examples + +```swift + func f() -> Int { + let ↓b = 2 + return b + } +``` + +```swift + struct S { + var a: Int { + var ↓b = 1 + // comment + return b + } + } +``` + +```swift + func f() -> Bool { + let a = 1, ↓b = true + return b + } +``` + +```swift + func f() -> Int { + { _ in + let ↓b = 2 + return b + }(1) + } +``` + +```swift + func f(i: Int) -> Int { + if i > 1 { + let ↓a = 2 + return a + } else { + let ↓b = 2, a = 1 + return b + } + } +``` \ No newline at end of file diff --git a/docs/description/discarded_notification_center_observer.md b/docs/description/discarded_notification_center_observer.md index 2390c02..76bb793 100644 --- a/docs/description/discarded_notification_center_observer.md +++ b/docs/description/discarded_notification_center_observer.md @@ -1,6 +1,6 @@ # Discarded Notification Center Observer -When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later. +When registering for a notification using a block, the opaque observer that is returned should be stored so it can be removed later * **Identifier:** discarded_notification_center_observer * **Enabled by default:** No @@ -8,7 +8,22 @@ When registering for a notification using a block, the opaque observer that is r * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/discouraged_assert.md b/docs/description/discouraged_assert.md index cc59a7f..64f4f64 100644 --- a/docs/description/discouraged_assert.md +++ b/docs/description/discouraged_assert.md @@ -8,7 +8,22 @@ Prefer `assertionFailure()` and/or `preconditionFailure()` over `assert(false)` * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/discouraged_direct_init.md b/docs/description/discouraged_direct_init.md index 041fcb4..112735d 100644 --- a/docs/description/discouraged_direct_init.md +++ b/docs/description/discouraged_direct_init.md @@ -1,6 +1,6 @@ # Discouraged Direct Initialization -Discouraged direct initialization of types that can be harmful. +Discouraged direct initialization of types that can be harmful * **Identifier:** discouraged_direct_init * **Enabled by default:** Yes @@ -8,7 +8,30 @@ Discouraged direct initialization of types that can be harmful. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, types: ["Bundle", "Bundle.init", "NSError", "NSError.init", "UIDevice", "UIDevice.init"] +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ types + + ["Bundle", "Bundle.init", "NSError", "NSError.init", "UIDevice", "UIDevice.init"] +
## Non Triggering Examples diff --git a/docs/description/discouraged_none_name.md b/docs/description/discouraged_none_name.md index 09074d9..794cdaf 100644 --- a/docs/description/discouraged_none_name.md +++ b/docs/description/discouraged_none_name.md @@ -1,6 +1,6 @@ # Discouraged None Name -Discourages name cases/static members `none`, which can conflict with `Optional.none`. +Enum cases and static members named `none` are discouraged as they can conflict with `Optional.none`. * **Identifier:** discouraged_none_name * **Enabled by default:** No @@ -8,7 +8,22 @@ Discourages name cases/static members `none`, which can conflict with `Optional< * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/discouraged_object_literal.md b/docs/description/discouraged_object_literal.md index 410f3c8..3dbac3f 100644 --- a/docs/description/discouraged_object_literal.md +++ b/docs/description/discouraged_object_literal.md @@ -1,6 +1,6 @@ # Discouraged Object Literal -Prefer initializers over object literals. +Prefer initializers over object literals * **Identifier:** discouraged_object_literal * **Enabled by default:** No @@ -8,7 +8,38 @@ Prefer initializers over object literals. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, image_literal: true, color_literal: true +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ image_literal + + true +
+ color_literal + + true +
## Non Triggering Examples diff --git a/docs/description/discouraged_optional_boolean.md b/docs/description/discouraged_optional_boolean.md index e82a2e9..400fd66 100644 --- a/docs/description/discouraged_optional_boolean.md +++ b/docs/description/discouraged_optional_boolean.md @@ -1,6 +1,6 @@ # Discouraged Optional Boolean -Prefer non-optional booleans over optional booleans. +Prefer non-optional booleans over optional booleans * **Identifier:** discouraged_optional_boolean * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer non-optional booleans over optional booleans. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/discouraged_optional_collection.md b/docs/description/discouraged_optional_collection.md index 3366799..134f398 100644 --- a/docs/description/discouraged_optional_collection.md +++ b/docs/description/discouraged_optional_collection.md @@ -1,6 +1,6 @@ # Discouraged Optional Collection -Prefer empty collection over optional collection. +Prefer empty collection over optional collection * **Identifier:** discouraged_optional_collection * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer empty collection over optional collection. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/duplicate_conditions.md b/docs/description/duplicate_conditions.md new file mode 100644 index 0000000..5578e5b --- /dev/null +++ b/docs/description/duplicate_conditions.md @@ -0,0 +1,190 @@ +# Duplicate Conditions + +Duplicate sets of conditions in the same branch instruction should be avoided + +* **Identifier:** duplicate_conditions +* **Enabled by default:** Yes +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + error +
+ +## Non Triggering Examples + +```swift + if x < 5 { + foo() + } else if y == "s" { + bar() + } +``` + +```swift + if x < 5 { + foo() + } + if x < 5 { + bar() + } +``` + +```swift + if x < 5, y == "s" { + foo() + } else if x < 5 { + bar() + } +``` + +```swift + switch x { + case "a": + foo() + bar() + } +``` + +```swift + switch x { + case "a" where y == "s": + foo() + case "a" where y == "t": + bar() + } +``` + +```swift + if let x = maybeAbc { + foo() + } else if let x = maybePqr { + bar() + } +``` + +```swift + if let x = maybeAbc, let z = x.maybeY { + foo() + } else if let x = maybePqr, let z = x.maybeY { + bar() + } +``` + +```swift + if case .p = x { + foo() + } else if case .q = x { + bar() + } +``` + +```swift + if true { + if true { foo() } + } +``` + +## Triggering Examples + +```swift + if ↓x < 5 { + foo() + } else if y == "s" { + bar() + } else if ↓x < 5 { + baz() + } +``` + +```swift + if z { + if ↓x < 5 { + foo() + } else if y == "s" { + bar() + } else if ↓x < 5 { + baz() + } + } +``` + +```swift + if ↓x < 5, y == "s" { + foo() + } else if x < 10 { + bar() + } else if ↓y == "s", x < 5 { + baz() + } +``` + +```swift + switch x { + case ↓"a", "b": + foo() + case "c", ↓"a": + bar() + } +``` + +```swift + switch x { + case ↓"a" where y == "s": + foo() + case ↓"a" where y == "s": + bar() + } +``` + +```swift + if ↓let xyz = maybeXyz { + foo() + } else if ↓let xyz = maybeXyz { + bar() + } +``` + +```swift + if ↓let x = maybeAbc, let z = x.maybeY { + foo() + } else if ↓let x = maybeAbc, let z = x.maybeY { + bar() + } +``` + +```swift + if ↓#available(macOS 10.15, *) { + foo() + } else if ↓#available(macOS 10.15, *) { + bar() + } +``` + +```swift + if ↓case .p = x { + foo() + } else if ↓case .p = x { + bar() + } +``` + +```swift + if ↓x < 5 {} + else if ↓x < 5 {} + else if ↓x < 5 {} +``` \ No newline at end of file diff --git a/docs/description/duplicate_enum_cases.md b/docs/description/duplicate_enum_cases.md index b52921b..4417934 100644 --- a/docs/description/duplicate_enum_cases.md +++ b/docs/description/duplicate_enum_cases.md @@ -1,6 +1,6 @@ # Duplicate Enum Cases -Enum can't contain multiple cases with the same name. +Enum shouldn't contain multiple cases with the same name * **Identifier:** duplicate_enum_cases * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Enum can't contain multiple cases with the same name. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** error +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + error +
## Non Triggering Examples diff --git a/docs/description/duplicate_imports.md b/docs/description/duplicate_imports.md index 0b86c63..0ef2d68 100644 --- a/docs/description/duplicate_imports.md +++ b/docs/description/duplicate_imports.md @@ -1,6 +1,6 @@ # Duplicate Imports -Imports should be unique. +Imports should be unique * **Identifier:** duplicate_imports * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Imports should be unique. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/duplicated_key_in_dictionary_literal.md b/docs/description/duplicated_key_in_dictionary_literal.md index f4c3189..9b06d71 100644 --- a/docs/description/duplicated_key_in_dictionary_literal.md +++ b/docs/description/duplicated_key_in_dictionary_literal.md @@ -1,6 +1,6 @@ # Duplicated Key in Dictionary Literal -Dictionary literals with duplicated keys will crash in runtime. +Dictionary literals with duplicated keys will crash at runtime * **Identifier:** duplicated_key_in_dictionary_literal * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Dictionary literals with duplicated keys will crash in runtime. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/dynamic_inline.md b/docs/description/dynamic_inline.md index d6b52a3..837ed2b 100644 --- a/docs/description/dynamic_inline.md +++ b/docs/description/dynamic_inline.md @@ -1,6 +1,6 @@ # Dynamic Inline -Avoid using 'dynamic' and '@inline(__always)' together. +Avoid using 'dynamic' and '@inline(__always)' together * **Identifier:** dynamic_inline * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Avoid using 'dynamic' and '@inline(__always)' together. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** error +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + error +
## Non Triggering Examples diff --git a/docs/description/empty_collection_literal.md b/docs/description/empty_collection_literal.md index 2ca5b3d..74290f7 100644 --- a/docs/description/empty_collection_literal.md +++ b/docs/description/empty_collection_literal.md @@ -1,6 +1,6 @@ # Empty Collection Literal -Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal. +Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal * **Identifier:** empty_collection_literal * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer checking `isEmpty` over comparing collection to an empty array or diction * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/empty_count.md b/docs/description/empty_count.md index 053caf2..c5da195 100644 --- a/docs/description/empty_count.md +++ b/docs/description/empty_count.md @@ -1,6 +1,6 @@ # Empty Count -Prefer checking `isEmpty` over comparing `count` to zero. +Prefer checking `isEmpty` over comparing `count` to zero * **Identifier:** empty_count * **Enabled by default:** No @@ -8,7 +8,30 @@ Prefer checking `isEmpty` over comparing `count` to zero. * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** error, only_after_dot: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + error +
+ only_after_dot + + false +
## Non Triggering Examples diff --git a/docs/description/empty_enum_arguments.md b/docs/description/empty_enum_arguments.md index 4babd33..10556c3 100644 --- a/docs/description/empty_enum_arguments.md +++ b/docs/description/empty_enum_arguments.md @@ -1,6 +1,6 @@ # Empty Enum Arguments -Arguments can be omitted when matching enums with associated values if they are not used. +Arguments can be omitted when matching enums with associated values if they are not used * **Identifier:** empty_enum_arguments * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Arguments can be omitted when matching enums with associated values if they are * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/empty_parameters.md b/docs/description/empty_parameters.md index 7dcf92d..f28a205 100644 --- a/docs/description/empty_parameters.md +++ b/docs/description/empty_parameters.md @@ -1,6 +1,6 @@ # Empty Parameters -Prefer `() -> ` over `Void -> `. +Prefer `() -> ` over `Void -> ` * **Identifier:** empty_parameters * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Prefer `() -> ` over `Void -> `. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/empty_parentheses_with_trailing_closure.md b/docs/description/empty_parentheses_with_trailing_closure.md index 849585b..b2a8250 100644 --- a/docs/description/empty_parentheses_with_trailing_closure.md +++ b/docs/description/empty_parentheses_with_trailing_closure.md @@ -1,6 +1,6 @@ # Empty Parentheses with Trailing Closure -When using trailing closures, empty parentheses should be avoided after the method call. +When using trailing closures, empty parentheses should be avoided after the method call * **Identifier:** empty_parentheses_with_trailing_closure * **Enabled by default:** Yes @@ -8,7 +8,22 @@ When using trailing closures, empty parentheses should be avoided after the meth * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/empty_string.md b/docs/description/empty_string.md index 9f879e3..8ea4f2c 100644 --- a/docs/description/empty_string.md +++ b/docs/description/empty_string.md @@ -1,6 +1,6 @@ # Empty String -Prefer checking `isEmpty` over comparing `string` to an empty string literal. +Prefer checking `isEmpty` over comparing `string` to an empty string literal * **Identifier:** empty_string * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer checking `isEmpty` over comparing `string` to an empty string literal. * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/empty_xctest_method.md b/docs/description/empty_xctest_method.md index fd6304e..77392df 100644 --- a/docs/description/empty_xctest_method.md +++ b/docs/description/empty_xctest_method.md @@ -1,6 +1,6 @@ # Empty XCTest Method -Empty XCTest method should be avoided. +Empty XCTest method should be avoided * **Identifier:** empty_xctest_method * **Enabled by default:** No @@ -8,7 +8,30 @@ Empty XCTest method should be avoided. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, test_parent_classes: ["QuickSpec", "XCTestCase"] +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ test_parent_classes + + ["QuickSpec", "XCTestCase"] +
## Non Triggering Examples diff --git a/docs/description/enum_case_associated_values_count.md b/docs/description/enum_case_associated_values_count.md index 9a10c3d..8dd4bce 100644 --- a/docs/description/enum_case_associated_values_count.md +++ b/docs/description/enum_case_associated_values_count.md @@ -1,6 +1,6 @@ # Enum Case Associated Values Count -Number of associated values in an enum case should be low +The number of associated values in an enum case should be low. * **Identifier:** enum_case_associated_values_count * **Enabled by default:** No @@ -8,7 +8,30 @@ Number of associated values in an enum case should be low * **Kind:** metrics * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning: 5, error: 6 +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ warning + + 5 +
+ error + + 6 +
## Non Triggering Examples diff --git a/docs/description/expiring_todo.md b/docs/description/expiring_todo.md index 632d161..835ec81 100644 --- a/docs/description/expiring_todo.md +++ b/docs/description/expiring_todo.md @@ -8,7 +8,92 @@ TODOs and FIXMEs should be resolved prior to their expiry date. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** approaching_expiry_severity: warning, expired_severity: error, bad_formatting_severity: error, approaching_expiry_threshold: 15, date_format: MM/dd/yyyy, date_delimiters: { opening: [, closing: ] }, date_separator: / +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ approaching_expiry_severity + + warning +
+ expired_severity + + error +
+ bad_formatting_severity + + error +
+ approaching_expiry_threshold + + 15 +
+ date_delimiters + + + + + + + + + + + + + + + +
KeyValue
+ opening + + "[" +
+ closing + + "]" +
+
+ date_format + + "MM/dd/yyyy" +
+ date_separator + + "/" +
## Non Triggering Examples diff --git a/docs/description/explicit_acl.md b/docs/description/explicit_acl.md index f27e57e..5cc74d0 100644 --- a/docs/description/explicit_acl.md +++ b/docs/description/explicit_acl.md @@ -1,6 +1,6 @@ # Explicit ACL -All declarations should specify Access Control Level keywords explicitly. +All declarations should specify Access Control Level keywords explicitly * **Identifier:** explicit_acl * **Enabled by default:** No @@ -8,7 +8,22 @@ All declarations should specify Access Control Level keywords explicitly. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/explicit_enum_raw_value.md b/docs/description/explicit_enum_raw_value.md index 2e6334f..ff06d6b 100644 --- a/docs/description/explicit_enum_raw_value.md +++ b/docs/description/explicit_enum_raw_value.md @@ -1,6 +1,6 @@ # Explicit Enum Raw Value -Enums should be explicitly assigned their raw values. +Enums should be explicitly assigned their raw values * **Identifier:** explicit_enum_raw_value * **Enabled by default:** No @@ -8,7 +8,22 @@ Enums should be explicitly assigned their raw values. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/explicit_init.md b/docs/description/explicit_init.md index ba082e2..e91e820 100644 --- a/docs/description/explicit_init.md +++ b/docs/description/explicit_init.md @@ -1,6 +1,6 @@ # Explicit Init -Explicitly calling .init() should be avoided. +Explicitly calling .init() should be avoided * **Identifier:** explicit_init * **Enabled by default:** No @@ -8,7 +8,22 @@ Explicitly calling .init() should be avoided. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/explicit_self.md b/docs/description/explicit_self.md index f4e18d9..2fdec19 100644 --- a/docs/description/explicit_self.md +++ b/docs/description/explicit_self.md @@ -1,6 +1,6 @@ # Explicit Self -Instance variables and functions should be explicitly accessed with 'self.'. +Instance variables and functions should be explicitly accessed with 'self.' * **Identifier:** explicit_self * **Enabled by default:** No @@ -8,7 +8,22 @@ Instance variables and functions should be explicitly accessed with 'self.'. * **Kind:** style * **Analyzer rule:** Yes * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/explicit_top_level_acl.md b/docs/description/explicit_top_level_acl.md index a481286..cb223e7 100644 --- a/docs/description/explicit_top_level_acl.md +++ b/docs/description/explicit_top_level_acl.md @@ -1,6 +1,6 @@ # Explicit Top Level ACL -Top-level declarations should specify Access Control Level keywords explicitly. +Top-level declarations should specify Access Control Level keywords explicitly * **Identifier:** explicit_top_level_acl * **Enabled by default:** No @@ -8,7 +8,22 @@ Top-level declarations should specify Access Control Level keywords explicitly. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/explicit_type_interface.md b/docs/description/explicit_type_interface.md index 3fd9b1e..6eca641 100644 --- a/docs/description/explicit_type_interface.md +++ b/docs/description/explicit_type_interface.md @@ -8,7 +8,38 @@ Properties should have a type interface * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, excluded: [], allow_redundancy: false +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ excluded + + [] +
+ allow_redundancy + + false +
## Non Triggering Examples @@ -20,7 +51,7 @@ class Foo { ```swift class Foo { - let myVar: Int? = 0 + let myVar: Int? = 0, s: String = "" } ``` @@ -40,36 +71,36 @@ class Foo { ```swift class Foo { - ↓var myVar = 0 + var ↓myVar = 0 } ``` ```swift class Foo { - ↓let mylet = 0 + let ↓mylet = 0 } ``` ```swift class Foo { - ↓static var myStaticVar = 0 + static var ↓myStaticVar = 0 } ``` ```swift class Foo { - ↓class var myClassVar = 0 + class var ↓myClassVar = 0 } ``` ```swift class Foo { - ↓let myVar = Int(0) + let ↓myVar = Int(0), ↓s = "" } ``` ```swift class Foo { - ↓let myVar = Set(0) + let ↓myVar = Set(0) } ``` \ No newline at end of file diff --git a/docs/description/extension_access_modifier.md b/docs/description/extension_access_modifier.md index 0984f56..3b586b7 100644 --- a/docs/description/extension_access_modifier.md +++ b/docs/description/extension_access_modifier.md @@ -8,7 +8,22 @@ Prefer to use extension access modifiers * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/fallthrough.md b/docs/description/fallthrough.md index abfbb97..b3e7582 100644 --- a/docs/description/fallthrough.md +++ b/docs/description/fallthrough.md @@ -1,6 +1,6 @@ # Fallthrough -Fallthrough should be avoided. +Fallthrough should be avoided * **Identifier:** fallthrough * **Enabled by default:** No @@ -8,7 +8,22 @@ Fallthrough should be avoided. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/fatal_error_message.md b/docs/description/fatal_error_message.md index 6803ad6..f54ba78 100644 --- a/docs/description/fatal_error_message.md +++ b/docs/description/fatal_error_message.md @@ -1,6 +1,6 @@ # Fatal Error Message -A fatalError call should have a message. +A fatalError call should have a message * **Identifier:** fatal_error_message * **Enabled by default:** No @@ -8,7 +8,22 @@ A fatalError call should have a message. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/file_header.md b/docs/description/file_header.md index 7dea4e4..68e3e1b 100644 --- a/docs/description/file_header.md +++ b/docs/description/file_header.md @@ -8,7 +8,22 @@ Header comments should be consistent with project patterns. The SWIFTLINT_CURREN * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, required_string: None, required_pattern: None, forbidden_string: None, forbidden_pattern: None +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/file_length.md b/docs/description/file_length.md index aedf948..88721e6 100644 --- a/docs/description/file_length.md +++ b/docs/description/file_length.md @@ -8,7 +8,38 @@ Files should not span too many lines. * **Kind:** metrics * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning: 400, error: 1000, ignore_comment_only_lines: false +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ warning + + 400 +
+ error + + 1000 +
+ ignore_comment_only_lines + + false +
## Non Triggering Examples diff --git a/docs/description/file_name.md b/docs/description/file_name.md index d4e87ef..6c79ea8 100644 --- a/docs/description/file_name.md +++ b/docs/description/file_name.md @@ -1,6 +1,6 @@ # File Name -File name should match a type or extension declared in the file (if any). +File name should match a type or extension declared in the file (if any) * **Identifier:** file_name * **Enabled by default:** No @@ -8,4 +8,51 @@ File name should match a type or extension declared in the file (if any). * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** (severity) warning, excluded: ["LinuxMain.swift", "main.swift"], prefix_pattern: , suffix_pattern: \+.*, nested_type_separator: . \ No newline at end of file +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ excluded + + ["LinuxMain.swift", "main.swift"] +
+ prefix_pattern + + "" +
+ suffix_pattern + + "\+.*" +
+ nested_type_separator + + "." +
\ No newline at end of file diff --git a/docs/description/file_name_no_space.md b/docs/description/file_name_no_space.md index 925220b..d7a6a74 100644 --- a/docs/description/file_name_no_space.md +++ b/docs/description/file_name_no_space.md @@ -1,6 +1,6 @@ -# File Name No Space +# File Name no Space -File name should not contain any whitespace. +File name should not contain any whitespace * **Identifier:** file_name_no_space * **Enabled by default:** No @@ -8,4 +8,27 @@ File name should not contain any whitespace. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** (severity) warning, excluded: [] \ No newline at end of file +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ excluded + + [] +
\ No newline at end of file diff --git a/docs/description/file_types_order.md b/docs/description/file_types_order.md index cee2d15..c8e63ce 100644 --- a/docs/description/file_types_order.md +++ b/docs/description/file_types_order.md @@ -8,7 +8,30 @@ Specifies how the types within a file should be ordered. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, order: [[SwiftLintFramework.FileType.supportingType], [SwiftLintFramework.FileType.mainType], [SwiftLintFramework.FileType.extension], [SwiftLintFramework.FileType.previewProvider], [SwiftLintFramework.FileType.libraryContentProvider]] +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ order + + [[supporting_type], [main_type], [extension], [preview_provider], [library_content_provider]] +
## Non Triggering Examples diff --git a/docs/description/first_where.md b/docs/description/first_where.md index cacd9db..c90c3e6 100644 --- a/docs/description/first_where.md +++ b/docs/description/first_where.md @@ -1,6 +1,6 @@ # First Where -Prefer using `.first(where:)` over `.filter { }.first` in collections. +Prefer using `.first(where:)` over `.filter { }.first` in collections * **Identifier:** first_where * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer using `.first(where:)` over `.filter { }.first` in collections. * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/flatmap_over_map_reduce.md b/docs/description/flatmap_over_map_reduce.md index 53edf71..de9adeb 100644 --- a/docs/description/flatmap_over_map_reduce.md +++ b/docs/description/flatmap_over_map_reduce.md @@ -1,6 +1,6 @@ -# FlatMap over map and reduce +# Flat Map over Map Reduce -Prefer `flatMap` over `map` followed by `reduce([], +)`. +Prefer `flatMap` over `map` followed by `reduce([], +)` * **Identifier:** flatmap_over_map_reduce * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer `flatMap` over `map` followed by `reduce([], +)`. * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/for_where.md b/docs/description/for_where.md index 4cef146..bce5582 100644 --- a/docs/description/for_where.md +++ b/docs/description/for_where.md @@ -1,6 +1,6 @@ -# For Where +# Prefer For-Where -`where` clauses are preferred over a single `if` inside a `for`. +`where` clauses are preferred over a single `if` inside a `for` * **Identifier:** for_where * **Enabled by default:** Yes @@ -8,7 +8,30 @@ * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, allow_for_as_filter: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ allow_for_as_filter + + false +
## Non Triggering Examples diff --git a/docs/description/force_cast.md b/docs/description/force_cast.md index b12992d..a63d644 100644 --- a/docs/description/force_cast.md +++ b/docs/description/force_cast.md @@ -1,6 +1,6 @@ # Force Cast -Force casts should be avoided. +Force casts should be avoided * **Identifier:** force_cast * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Force casts should be avoided. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** error +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + error +
## Non Triggering Examples diff --git a/docs/description/force_try.md b/docs/description/force_try.md index 7ac131c..aad410b 100644 --- a/docs/description/force_try.md +++ b/docs/description/force_try.md @@ -1,6 +1,6 @@ # Force Try -Force tries should be avoided. +Force tries should be avoided * **Identifier:** force_try * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Force tries should be avoided. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** error +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + error +
## Non Triggering Examples diff --git a/docs/description/force_unwrapping.md b/docs/description/force_unwrapping.md index 5c8b50f..32cc2c8 100644 --- a/docs/description/force_unwrapping.md +++ b/docs/description/force_unwrapping.md @@ -1,6 +1,6 @@ # Force Unwrapping -Force unwrapping should be avoided. +Force unwrapping should be avoided * **Identifier:** force_unwrapping * **Enabled by default:** No @@ -8,7 +8,22 @@ Force unwrapping should be avoided. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/function_body_length.md b/docs/description/function_body_length.md index 26e823e..9ff8e15 100644 --- a/docs/description/function_body_length.md +++ b/docs/description/function_body_length.md @@ -1,6 +1,6 @@ # Function Body Length -Functions bodies should not span too many lines. +Function bodies should not span too many lines * **Identifier:** function_body_length * **Enabled by default:** Yes @@ -8,4 +8,27 @@ Functions bodies should not span too many lines. * **Kind:** metrics * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning: 50, error: 100 \ No newline at end of file +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ warning + + 50 +
+ error + + 100 +
\ No newline at end of file diff --git a/docs/description/function_default_parameter_at_end.md b/docs/description/function_default_parameter_at_end.md index 866f35d..69b42ce 100644 --- a/docs/description/function_default_parameter_at_end.md +++ b/docs/description/function_default_parameter_at_end.md @@ -1,6 +1,6 @@ # Function Default Parameter at End -Prefer to locate parameters with defaults toward the end of the parameter list. +Prefer to locate parameters with defaults toward the end of the parameter list * **Identifier:** function_default_parameter_at_end * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer to locate parameters with defaults toward the end of the parameter list. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/function_parameter_count.md b/docs/description/function_parameter_count.md index 784c801..795aad4 100644 --- a/docs/description/function_parameter_count.md +++ b/docs/description/function_parameter_count.md @@ -8,7 +8,38 @@ Number of function parameters should be low. * **Kind:** metrics * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning: 5, error: 8ignores_default_parameters: true +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ warning + + 5 +
+ error + + 8 +
+ ignores_default_parameters + + true +
## Non Triggering Examples diff --git a/docs/description/generic_type_name.md b/docs/description/generic_type_name.md index b9a4478..043f8aa 100644 --- a/docs/description/generic_type_name.md +++ b/docs/description/generic_type_name.md @@ -8,7 +8,106 @@ Generic type name should only contain alphanumeric characters, start with an upp * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** (min_length) w/e: 1/0, (max_length) w/e: 20/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ min_length + + + + + + + + + + + + + + + +
KeyValue
+ warning + + 1 +
+ error + + 0 +
+
+ max_length + + + + + + + + + + + + + + + +
KeyValue
+ warning + + 20 +
+ error + + 1000 +
+
+ excluded + + [] +
+ allowed_symbols + + [] +
+ unallowed_symbols_severity + + error +
+ validates_start_with_lowercase + + error +
## Non Triggering Examples diff --git a/docs/description/ibinspectable_in_extension.md b/docs/description/ibinspectable_in_extension.md index 3a49ad3..7759a60 100644 --- a/docs/description/ibinspectable_in_extension.md +++ b/docs/description/ibinspectable_in_extension.md @@ -1,6 +1,6 @@ # IBInspectable in Extension -Extensions shouldn't add @IBInspectable properties. +Extensions shouldn't add @IBInspectable properties * **Identifier:** ibinspectable_in_extension * **Enabled by default:** No @@ -8,7 +8,22 @@ Extensions shouldn't add @IBInspectable properties. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/identical_operands.md b/docs/description/identical_operands.md index 3c84483..81764e0 100644 --- a/docs/description/identical_operands.md +++ b/docs/description/identical_operands.md @@ -1,6 +1,6 @@ # Identical Operands -Comparing two identical operands is likely a mistake. +Comparing two identical operands is likely a mistake * **Identifier:** identical_operands * **Enabled by default:** No @@ -8,7 +8,22 @@ Comparing two identical operands is likely a mistake. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -565,7 +580,7 @@ f( i : 2) <= f (i: 3 ) ``` ```swift -func evaluate(_ mode: CommandMode) -> Result>> +func evaluate(_ mode: CommandMode) -> Result>> ``` ```swift diff --git a/docs/description/identifier_name.md b/docs/description/identifier_name.md index 327f6bd..0748be6 100644 --- a/docs/description/identifier_name.md +++ b/docs/description/identifier_name.md @@ -1,6 +1,6 @@ # Identifier Name -Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared static and immutable. Variable names should not be too long or too short. +Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared as static. Variable names should not be too long or too short. * **Identifier:** identifier_name * **Enabled by default:** Yes @@ -8,7 +8,106 @@ Identifier names should only contain alphanumeric characters and start with a lo * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** (min_length) w/e: 3/2, (max_length) w/e: 40/60, excluded: ["id"], allowed_symbols: [], validates_start_with_lowercase: true +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ min_length + + + + + + + + + + + + + + + +
KeyValue
+ warning + + 3 +
+ error + + 2 +
+
+ max_length + + + + + + + + + + + + + + + +
KeyValue
+ warning + + 40 +
+ error + + 60 +
+
+ excluded + + ["^id$"] +
+ allowed_symbols + + [] +
+ unallowed_symbols_severity + + error +
+ validates_start_with_lowercase + + error +
## Non Triggering Examples @@ -68,12 +167,20 @@ enum Foo { case `private` } enum Foo { case value(String) } ``` -## Triggering Examples +```swift +class Foo { + static let Bar = 0 +} +``` ```swift -↓let MyLet = 0 +class Foo { + static var Bar = 0 +} ``` +## Triggering Examples + ```swift ↓let _myLet = 0 ``` @@ -104,12 +211,4 @@ private ↓let _myExtremelyVeryVeryVeryVeryVeryVeryLongLet = 0 ```swift private ↓let _i = 0 -``` - -```swift -↓func IsOperator(name: String) -> Bool -``` - -```swift -enum Foo { case ↓MyEnum } ``` \ No newline at end of file diff --git a/docs/description/implicit_getter.md b/docs/description/implicit_getter.md index 2520c5e..bb3b7ac 100644 --- a/docs/description/implicit_getter.md +++ b/docs/description/implicit_getter.md @@ -8,7 +8,22 @@ Computed read-only properties and subscripts should avoid using the get keyword. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/implicit_return.md b/docs/description/implicit_return.md index 14b7237..d8a358a 100644 --- a/docs/description/implicit_return.md +++ b/docs/description/implicit_return.md @@ -1,6 +1,6 @@ # Implicit Return -Prefer implicit returns in closures, functions and getters. +Prefer implicit returns in closures, functions and getters * **Identifier:** implicit_return * **Enabled by default:** No @@ -8,7 +8,30 @@ Prefer implicit returns in closures, functions and getters. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, included: [closure, function, getter] +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ included + + [closure, function, getter] +
## Non Triggering Examples diff --git a/docs/description/implicitly_unwrapped_optional.md b/docs/description/implicitly_unwrapped_optional.md index 6ec49f7..f697d07 100644 --- a/docs/description/implicitly_unwrapped_optional.md +++ b/docs/description/implicitly_unwrapped_optional.md @@ -1,6 +1,6 @@ # Implicitly Unwrapped Optional -Implicitly unwrapped optionals should be avoided when possible. +Implicitly unwrapped optionals should be avoided when possible * **Identifier:** implicitly_unwrapped_optional * **Enabled by default:** No @@ -8,7 +8,30 @@ Implicitly unwrapped optionals should be avoided when possible. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, mode: allExceptIBOutlets +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ mode + + all_except_iboutlets +
## Non Triggering Examples @@ -39,41 +62,47 @@ let int: Int? = nil ## Triggering Examples ```swift -let label: UILabel! +let label: ↓UILabel! ``` ```swift -let IBOutlet: UILabel! +let IBOutlet: ↓UILabel! ``` ```swift -let labels: [UILabel!] +let labels: [↓UILabel!] ``` ```swift -var ints: [Int!] = [42, nil, 42] +var ints: [↓Int!] = [42, nil, 42] ``` ```swift -let label: IBOutlet! +let label: ↓IBOutlet! ``` ```swift -let int: Int! = 42 +let int: ↓Int! = 42 ``` ```swift -let int: Int! = nil +let int: ↓Int! = nil ``` ```swift -var int: Int! = 42 +var int: ↓Int! = 42 ``` ```swift -let collection: AnyCollection +let collection: AnyCollection<↓Int!> ``` ```swift -func foo(int: Int!) {} +func foo(int: ↓Int!) {} +``` + +```swift +class MyClass { + weak var bar: ↓SomeObject! +} ``` \ No newline at end of file diff --git a/docs/description/inclusive_language.md b/docs/description/inclusive_language.md index b973aec..6521362 100644 --- a/docs/description/inclusive_language.md +++ b/docs/description/inclusive_language.md @@ -1,6 +1,6 @@ # Inclusive Language -Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status +Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status. * **Identifier:** inclusive_language * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Identifiers should use inclusive language that avoids discrimination against gro * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, additional_terms: [], override_terms: [], override_allowed_terms: [] +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/indentation_width.md b/docs/description/indentation_width.md index 46fbffe..4763e0a 100644 --- a/docs/description/indentation_width.md +++ b/docs/description/indentation_width.md @@ -8,7 +8,54 @@ Indent code using either one tab or the configured amount of spaces, unindent to * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** severity: warning, indentation_width: 4, include_comments: true +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ indentation_width + + 4 +
+ include_comments + + true +
+ include_compiler_directives + + true +
+ include_multiline_strings + + true +
## Non Triggering Examples diff --git a/docs/description/inert_defer.md b/docs/description/inert_defer.md index 068914a..1a67e28 100644 --- a/docs/description/inert_defer.md +++ b/docs/description/inert_defer.md @@ -1,14 +1,29 @@ # Inert Defer -If defer is at the end of its parent scope, it will be executed right where it is anyway. +If defer is at the end of its parent scope, it will be executed right where it is anyway * **Identifier:** inert_defer -* **Enabled by default:** Yes +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/invalid_swiftlint_command.md b/docs/description/invalid_swiftlint_command.md new file mode 100644 index 0000000..a45c387 --- /dev/null +++ b/docs/description/invalid_swiftlint_command.md @@ -0,0 +1,106 @@ +# Invalid SwiftLint Command + +swiftlint command does not have a valid action or modifier + +* **Identifier:** invalid_swiftlint_command +* **Enabled by default:** Yes +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ +## Non Triggering Examples + +```swift +// swiftlint:disable unused_import +``` + +```swift +// swiftlint:enable unused_import +``` + +```swift +// swiftlint:disable:next unused_import +``` + +```swift +// swiftlint:disable:previous unused_import +``` + +```swift +// swiftlint:disable:this unused_import +``` + +## Triggering Examples + +```swift +// swiftlint: +``` + +```swift +// swiftlint: +``` + +```swift +// swiftlint:: +``` + +```swift +// swiftlint:: +``` + +```swift +// swiftlint:disable +``` + +```swift +// swiftlint:dissable unused_import +``` + +```swift +// swiftlint:enaaaable unused_import +``` + +```swift +// swiftlint:disable:nxt unused_import +``` + +```swift +// swiftlint:enable:prevus unused_import +``` + +```swift +// swiftlint:enable:ths unused_import +``` + +```swift +// swiftlint:enable +``` + +```swift +// swiftlint:enable: +``` + +```swift +// swiftlint:enable: +``` + +```swift +// swiftlint:disable: unused_import +``` \ No newline at end of file diff --git a/docs/description/is_disjoint.md b/docs/description/is_disjoint.md index 0367431..7f14413 100644 --- a/docs/description/is_disjoint.md +++ b/docs/description/is_disjoint.md @@ -1,6 +1,6 @@ # Is Disjoint -Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty`. +Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty` * **Identifier:** is_disjoint * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty`. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/joined_default_parameter.md b/docs/description/joined_default_parameter.md index 1e760f8..bf4d07b 100644 --- a/docs/description/joined_default_parameter.md +++ b/docs/description/joined_default_parameter.md @@ -1,6 +1,6 @@ # Joined Default Parameter -Discouraged explicit usage of the default separator. +Discouraged explicit usage of the default separator * **Identifier:** joined_default_parameter * **Enabled by default:** No @@ -8,7 +8,22 @@ Discouraged explicit usage of the default separator. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/large_tuple.md b/docs/description/large_tuple.md index 637f190..bb0117d 100644 --- a/docs/description/large_tuple.md +++ b/docs/description/large_tuple.md @@ -8,7 +8,30 @@ Tuples shouldn't have too many members. Create a custom type instead. * **Kind:** metrics * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning: 2, error: 3 +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ warning + + 2 +
+ error + + 3 +
## Non Triggering Examples diff --git a/docs/description/last_where.md b/docs/description/last_where.md index 3ecff1c..f3666dc 100644 --- a/docs/description/last_where.md +++ b/docs/description/last_where.md @@ -1,6 +1,6 @@ # Last Where -Prefer using `.last(where:)` over `.filter { }.last` in collections. +Prefer using `.last(where:)` over `.filter { }.last` in collections * **Identifier:** last_where * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer using `.last(where:)` over `.filter { }.last` in collections. * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/leading_whitespace.md b/docs/description/leading_whitespace.md index f31054b..e87facd 100644 --- a/docs/description/leading_whitespace.md +++ b/docs/description/leading_whitespace.md @@ -1,6 +1,6 @@ # Leading Whitespace -Files should not contain leading whitespace. +Files should not contain leading whitespace * **Identifier:** leading_whitespace * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Files should not contain leading whitespace. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/legacy_cggeometry_functions.md b/docs/description/legacy_cggeometry_functions.md index f8aca26..f5268d5 100644 --- a/docs/description/legacy_cggeometry_functions.md +++ b/docs/description/legacy_cggeometry_functions.md @@ -8,7 +8,22 @@ Struct extension properties and methods are preferred over legacy functions * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/legacy_constant.md b/docs/description/legacy_constant.md index d92d7ad..1344464 100644 --- a/docs/description/legacy_constant.md +++ b/docs/description/legacy_constant.md @@ -1,6 +1,6 @@ # Legacy Constant -Struct-scoped constants are preferred over legacy global constants. +Struct-scoped constants are preferred over legacy global constants * **Identifier:** legacy_constant * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Struct-scoped constants are preferred over legacy global constants. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/legacy_constructor.md b/docs/description/legacy_constructor.md index 738789b..3c0839f 100644 --- a/docs/description/legacy_constructor.md +++ b/docs/description/legacy_constructor.md @@ -1,6 +1,6 @@ # Legacy Constructor -Swift constructors are preferred over legacy convenience functions. +Swift constructors are preferred over legacy convenience functions * **Identifier:** legacy_constructor * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Swift constructors are preferred over legacy convenience functions. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/legacy_hashing.md b/docs/description/legacy_hashing.md index fc3466d..d3c7d7e 100644 --- a/docs/description/legacy_hashing.md +++ b/docs/description/legacy_hashing.md @@ -8,7 +8,22 @@ Prefer using the `hash(into:)` function instead of overriding `hashValue` * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/legacy_multiple.md b/docs/description/legacy_multiple.md index d9b52a8..bd0e8b8 100644 --- a/docs/description/legacy_multiple.md +++ b/docs/description/legacy_multiple.md @@ -1,6 +1,6 @@ # Legacy Multiple -Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`). +Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`) * **Identifier:** legacy_multiple * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer using the `isMultiple(of:)` function instead of using the remainder opera * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/legacy_nsgeometry_functions.md b/docs/description/legacy_nsgeometry_functions.md index 2eca251..3c8af76 100644 --- a/docs/description/legacy_nsgeometry_functions.md +++ b/docs/description/legacy_nsgeometry_functions.md @@ -8,7 +8,22 @@ Struct extension properties and methods are preferred over legacy functions * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/legacy_objc_type.md b/docs/description/legacy_objc_type.md index 965dbc0..5942b0a 100644 --- a/docs/description/legacy_objc_type.md +++ b/docs/description/legacy_objc_type.md @@ -8,7 +8,22 @@ Prefer Swift value types to bridged Objective-C reference types * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/legacy_random.md b/docs/description/legacy_random.md index 58ec0de..e1a4ec1 100644 --- a/docs/description/legacy_random.md +++ b/docs/description/legacy_random.md @@ -1,6 +1,6 @@ # Legacy Random -Prefer using `type.random(in:)` over legacy functions. +Prefer using `type.random(in:)` over legacy functions * **Identifier:** legacy_random * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Prefer using `type.random(in:)` over legacy functions. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -30,7 +45,7 @@ Float.random(in: 0 ..< 1) ## Triggering Examples ```swift -↓arc4random(10) +↓arc4random() ``` @@ -40,6 +55,6 @@ Float.random(in: 0 ..< 1) ``` ```swift -↓drand48(52) +↓drand48() ``` \ No newline at end of file diff --git a/docs/description/let_var_whitespace.md b/docs/description/let_var_whitespace.md index ed629a9..36f13b9 100644 --- a/docs/description/let_var_whitespace.md +++ b/docs/description/let_var_whitespace.md @@ -1,6 +1,6 @@ # Variable Declaration Whitespace -Let and var should be separated from other statements by a blank line. +Variable declarations should be separated from other statements by a blank line * **Identifier:** let_var_whitespace * **Enabled by default:** No @@ -8,7 +8,22 @@ Let and var should be separated from other statements by a blank line. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/line_length.md b/docs/description/line_length.md index f0a46b9..403c672 100644 --- a/docs/description/line_length.md +++ b/docs/description/line_length.md @@ -8,7 +8,62 @@ Lines should not span too many characters. * **Kind:** metrics * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning: 120, error: 200, ignores urls: false, ignores function declarations: false, ignores comments: false, ignores interpolated strings: false +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ warning + + 120 +
+ error + + 200 +
+ ignores_urls + + false +
+ ignores_function_declarations + + false +
+ ignores_comments + + false +
+ ignores_interpolated_strings + + false +
## Non Triggering Examples diff --git a/docs/description/literal_expression_end_indentation.md b/docs/description/literal_expression_end_indentation.md index 790c86f..2236e67 100644 --- a/docs/description/literal_expression_end_indentation.md +++ b/docs/description/literal_expression_end_indentation.md @@ -1,6 +1,6 @@ # Literal Expression End Indentation -Array and dictionary literal end should have the same indentation as the line that started it. +Array and dictionary literal end should have the same indentation as the line that started it * **Identifier:** literal_expression_end_indentation * **Enabled by default:** No @@ -8,7 +8,22 @@ Array and dictionary literal end should have the same indentation as the line th * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/local_doc_comment.md b/docs/description/local_doc_comment.md index 6886c03..61c48fe 100644 --- a/docs/description/local_doc_comment.md +++ b/docs/description/local_doc_comment.md @@ -1,6 +1,6 @@ # Local Doc Comment -Doc comments shouldn't be used in local scopes. Use regular comments. +Prefer regular comments over doc comments in local scopes * **Identifier:** local_doc_comment * **Enabled by default:** No @@ -8,7 +8,22 @@ Doc comments shouldn't be used in local scopes. Use regular comments. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/lower_acl_than_parent.md b/docs/description/lower_acl_than_parent.md index b480862..01bc6e8 100644 --- a/docs/description/lower_acl_than_parent.md +++ b/docs/description/lower_acl_than_parent.md @@ -1,4 +1,4 @@ -# Lower ACL than parent +# Lower ACL than Parent Ensure declarations have a lower access control level than their enclosing parent @@ -8,7 +8,22 @@ Ensure declarations have a lower access control level than their enclosing paren * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/mark.md b/docs/description/mark.md index e6cad2c..2a870db 100644 --- a/docs/description/mark.md +++ b/docs/description/mark.md @@ -8,7 +8,22 @@ MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...' * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/missing_docs.md b/docs/description/missing_docs.md index ce9db84..7d3d43c 100644 --- a/docs/description/missing_docs.md +++ b/docs/description/missing_docs.md @@ -8,7 +8,46 @@ Declarations should be documented. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning: open, public, excludes_extensions: true, excludes_inherited_types: true, excludes_trivial_init: false +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ warning + + [open, public] +
+ excludes_extensions + + true +
+ excludes_inherited_types + + true +
+ excludes_trivial_init + + false +
## Non Triggering Examples diff --git a/docs/description/modifier_order.md b/docs/description/modifier_order.md index e889aa2..70ac9c5 100644 --- a/docs/description/modifier_order.md +++ b/docs/description/modifier_order.md @@ -8,7 +8,30 @@ Modifier order should be consistent. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, preferred_modifier_order: [override, acl, setterACL, dynamic, mutators, lazy, final, required, convenience, typeMethods, owned] +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ preferred_modifier_order + + [override, acl, setterACL, dynamic, mutators, lazy, final, required, convenience, typeMethods, owned] +
## Non Triggering Examples diff --git a/docs/description/multiline_arguments.md b/docs/description/multiline_arguments.md index 472daa3..abe2608 100644 --- a/docs/description/multiline_arguments.md +++ b/docs/description/multiline_arguments.md @@ -1,6 +1,6 @@ # Multiline Arguments -Arguments should be either on the same line, or one per line. +Arguments should be either on the same line, or one per line * **Identifier:** multiline_arguments * **Enabled by default:** No @@ -8,7 +8,38 @@ Arguments should be either on the same line, or one per line. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, first_argument_location: any_line, only_enforce_after_first_closure_on_first_line: false +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ first_argument_location + + any_line +
+ only_enforce_after_first_closure_on_first_line + + false +
## Non Triggering Examples @@ -93,6 +124,36 @@ foo( ) ``` +```swift +Picker(selection: viewStore.binding(\.$someProperty)) { + ForEach(SomeEnum.allCases, id: \.rawValue) { someCase in + Text(someCase.rawValue) + .tag(someCase) + } +} label: { + EmptyView() +} +``` + +```swift +UIView.animate(withDuration: 1, + delay: 0) { + // sample + print("a") +} completion: { _ in + // sample + print("b") +} +``` + +```swift +UIView.animate(withDuration: 1, delay: 0) { + print("a") +} completion: { _ in + print("b") +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/multiline_arguments_brackets.md b/docs/description/multiline_arguments_brackets.md index 5747f9d..e09564d 100644 --- a/docs/description/multiline_arguments_brackets.md +++ b/docs/description/multiline_arguments_brackets.md @@ -1,6 +1,6 @@ # Multiline Arguments Brackets -Multiline arguments should have their surrounding brackets in a new line. +Multiline arguments should have their surrounding brackets in a new line * **Identifier:** multiline_arguments_brackets * **Enabled by default:** No @@ -8,7 +8,22 @@ Multiline arguments should have their surrounding brackets in a new line. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/multiline_function_chains.md b/docs/description/multiline_function_chains.md index 6154a02..3e973f6 100644 --- a/docs/description/multiline_function_chains.md +++ b/docs/description/multiline_function_chains.md @@ -1,6 +1,6 @@ # Multiline Function Chains -Chained function calls should be either on the same line, or one per line. +Chained function calls should be either on the same line, or one per line * **Identifier:** multiline_function_chains * **Enabled by default:** No @@ -8,7 +8,22 @@ Chained function calls should be either on the same line, or one per line. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/multiline_literal_brackets.md b/docs/description/multiline_literal_brackets.md index a65caa9..28d1f88 100644 --- a/docs/description/multiline_literal_brackets.md +++ b/docs/description/multiline_literal_brackets.md @@ -1,6 +1,6 @@ # Multiline Literal Brackets -Multiline literals should have their surrounding brackets in a new line. +Multiline literals should have their surrounding brackets in a new line * **Identifier:** multiline_literal_brackets * **Enabled by default:** No @@ -8,7 +8,22 @@ Multiline literals should have their surrounding brackets in a new line. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/multiline_parameters.md b/docs/description/multiline_parameters.md index 24f4e4c..68a31a8 100644 --- a/docs/description/multiline_parameters.md +++ b/docs/description/multiline_parameters.md @@ -1,6 +1,6 @@ # Multiline Parameters -Functions and methods parameters should be either on the same line, or one per line. +Functions and methods parameters should be either on the same line, or one per line * **Identifier:** multiline_parameters * **Enabled by default:** No @@ -8,7 +8,30 @@ Functions and methods parameters should be either on the same line, or one per l * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, allowsSingleLine: true +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ allows_single_line + + true +
## Non Triggering Examples diff --git a/docs/description/multiline_parameters_brackets.md b/docs/description/multiline_parameters_brackets.md index abeda76..cdd97c5 100644 --- a/docs/description/multiline_parameters_brackets.md +++ b/docs/description/multiline_parameters_brackets.md @@ -1,6 +1,6 @@ # Multiline Parameters Brackets -Multiline parameters should have their surrounding brackets in a new line. +Multiline parameters should have their surrounding brackets in a new line * **Identifier:** multiline_parameters_brackets * **Enabled by default:** No @@ -8,7 +8,22 @@ Multiline parameters should have their surrounding brackets in a new line. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/multiple_closures_with_trailing_closure.md b/docs/description/multiple_closures_with_trailing_closure.md index f83d1db..14e2cb2 100644 --- a/docs/description/multiple_closures_with_trailing_closure.md +++ b/docs/description/multiple_closures_with_trailing_closure.md @@ -1,6 +1,6 @@ # Multiple Closures with Trailing Closure -Trailing closure syntax should not be used when passing more than one closure argument. +Trailing closure syntax should not be used when passing more than one closure argument * **Identifier:** multiple_closures_with_trailing_closure * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Trailing closure syntax should not be used when passing more than one closure ar * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/nesting.md b/docs/description/nesting.md index ad37870..f65f259 100644 --- a/docs/description/nesting.md +++ b/docs/description/nesting.md @@ -8,7 +8,74 @@ Types should be nested at most 1 level deep, and functions should be nested at m * **Kind:** metrics * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** (type_level) w: 1, (function_level) w: 2, (check_nesting_in_closures_and_statements) true, (always_allow_one_type_in_functions) false +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ type_level + + + + + + + + + + + +
KeyValue
+ warning + + 1 +
+
+ function_level + + + + + + + + + + + +
KeyValue
+ warning + + 2 +
+
+ check_nesting_in_closures_and_statements + + true +
+ always_allow_one_type_in_functions + + false +
## Non Triggering Examples diff --git a/docs/description/nimble_operator.md b/docs/description/nimble_operator.md index b4994a8..648f125 100644 --- a/docs/description/nimble_operator.md +++ b/docs/description/nimble_operator.md @@ -1,6 +1,6 @@ # Nimble Operator -Prefer Nimble operator overloads over free matcher functions. +Prefer Nimble operator overloads over free matcher functions * **Identifier:** nimble_operator * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer Nimble operator overloads over free matcher functions. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/no_extension_access_modifier.md b/docs/description/no_extension_access_modifier.md index a605127..2233cf5 100644 --- a/docs/description/no_extension_access_modifier.md +++ b/docs/description/no_extension_access_modifier.md @@ -8,7 +8,22 @@ Prefer not to use extension access modifiers * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** error +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + error +
## Non Triggering Examples diff --git a/docs/description/no_fallthrough_only.md b/docs/description/no_fallthrough_only.md index 0ca558f..d35b5b1 100644 --- a/docs/description/no_fallthrough_only.md +++ b/docs/description/no_fallthrough_only.md @@ -1,6 +1,6 @@ -# No Fallthrough Only +# No Fallthrough only -Fallthroughs can only be used if the `case` contains at least one other statement. +Fallthroughs can only be used if the `case` contains at least one other statement * **Identifier:** no_fallthrough_only * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Fallthroughs can only be used if the `case` contains at least one other statemen * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/no_grouping_extension.md b/docs/description/no_grouping_extension.md index 06273ab..120abd0 100644 --- a/docs/description/no_grouping_extension.md +++ b/docs/description/no_grouping_extension.md @@ -1,6 +1,6 @@ # No Grouping Extension -Extensions shouldn't be used to group code within the same source file. +Extensions shouldn't be used to group code within the same source file * **Identifier:** no_grouping_extension * **Enabled by default:** No @@ -8,7 +8,22 @@ Extensions shouldn't be used to group code within the same source file. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/no_magic_numbers.md b/docs/description/no_magic_numbers.md index 9005451..6e3169e 100644 --- a/docs/description/no_magic_numbers.md +++ b/docs/description/no_magic_numbers.md @@ -1,6 +1,6 @@ # No Magic Numbers -Magic numbers should be replaced by named constants. +Magic numbers should be replaced by named constants * **Identifier:** no_magic_numbers * **Enabled by default:** No @@ -8,7 +8,30 @@ Magic numbers should be replaced by named constants. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ test_parent_classes + + ["QuickSpec", "XCTestCase"] +
## Non Triggering Examples @@ -64,6 +87,29 @@ func version() { } ``` +```swift +enum Example: Int { + case positive = 2 + case negative = -2 +} +``` + +```swift +class FooTests: XCTestCase { + let array: [Int] = [] + let bar = array[42] +} +``` + +```swift +class FooTests: XCTestCase { + class Bar { + let array: [Int] = [] + let bar = array[42] + } +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/no_space_in_method_call.md b/docs/description/no_space_in_method_call.md index 4ccd464..2ba3538 100644 --- a/docs/description/no_space_in_method_call.md +++ b/docs/description/no_space_in_method_call.md @@ -1,6 +1,6 @@ # No Space in Method Call -Don't add a space between the method name and the parentheses. +Don't add a space between the method name and the parentheses * **Identifier:** no_space_in_method_call * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Don't add a space between the method name and the parentheses. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/notification_center_detachment.md b/docs/description/notification_center_detachment.md index b994997..c860ada 100644 --- a/docs/description/notification_center_detachment.md +++ b/docs/description/notification_center_detachment.md @@ -1,6 +1,6 @@ # Notification Center Detachment -An object should only remove itself as an observer in `deinit`. +An object should only remove itself as an observer in `deinit` * **Identifier:** notification_center_detachment * **Enabled by default:** Yes @@ -8,7 +8,22 @@ An object should only remove itself as an observer in `deinit`. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/ns_number_init_as_function_reference.md b/docs/description/ns_number_init_as_function_reference.md index 76386e4..513fdfd 100644 --- a/docs/description/ns_number_init_as_function_reference.md +++ b/docs/description/ns_number_init_as_function_reference.md @@ -1,6 +1,6 @@ # NSNumber Init as Function Reference -Passing `NSNumber.init` or `NSDecimalNumber.init` as a function reference is dangerous as it can cause the wrong initializer to be used, causing crashes. Use `.init(value:)` instead. +Passing `NSNumber.init` or `NSDecimalNumber.init` as a function reference is dangerous as it can cause the wrong initializer to be used, causing crashes; use `.init(value:)` instead * **Identifier:** ns_number_init_as_function_reference * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Passing `NSNumber.init` or `NSDecimalNumber.init` as a function reference is dan * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/nslocalizedstring_key.md b/docs/description/nslocalizedstring_key.md index 41a8946..5e56c19 100644 --- a/docs/description/nslocalizedstring_key.md +++ b/docs/description/nslocalizedstring_key.md @@ -1,6 +1,6 @@ # NSLocalizedString Key -Static strings should be used as key/comment in NSLocalizedString in order for genstrings to work. +Static strings should be used as key/comment in NSLocalizedString in order for genstrings to work * **Identifier:** nslocalizedstring_key * **Enabled by default:** No @@ -8,7 +8,22 @@ Static strings should be used as key/comment in NSLocalizedString in order for g * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/nslocalizedstring_require_bundle.md b/docs/description/nslocalizedstring_require_bundle.md index 8845e12..c87c168 100644 --- a/docs/description/nslocalizedstring_require_bundle.md +++ b/docs/description/nslocalizedstring_require_bundle.md @@ -1,6 +1,6 @@ # NSLocalizedString Require Bundle -Calls to NSLocalizedString should specify the bundle which contains the strings file. +Calls to NSLocalizedString should specify the bundle which contains the strings file * **Identifier:** nslocalizedstring_require_bundle * **Enabled by default:** No @@ -8,7 +8,22 @@ Calls to NSLocalizedString should specify the bundle which contains the strings * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/nsobject_prefer_isequal.md b/docs/description/nsobject_prefer_isequal.md index 2cd1ea0..57f6bae 100644 --- a/docs/description/nsobject_prefer_isequal.md +++ b/docs/description/nsobject_prefer_isequal.md @@ -1,6 +1,6 @@ # NSObject Prefer isEqual -NSObject subclasses should implement isEqual instead of ==. +NSObject subclasses should implement isEqual instead of == * **Identifier:** nsobject_prefer_isequal * **Enabled by default:** Yes @@ -8,7 +8,22 @@ NSObject subclasses should implement isEqual instead of ==. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/number_separator.md b/docs/description/number_separator.md index 4fae190..8fa1320 100644 --- a/docs/description/number_separator.md +++ b/docs/description/number_separator.md @@ -1,6 +1,6 @@ # Number Separator -Underscores should be used as thousand separator in large decimal numbers. +Underscores should be used as thousand separator in large numbers with a configurable number of digits. In other words, there should be an underscore after every 3 digits in the integral as well as the fractional part of a number. * **Identifier:** number_separator * **Enabled by default:** No @@ -8,7 +8,30 @@ Underscores should be used as thousand separator in large decimal numbers. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, minimum_length: 0, minimum_fraction_length: none +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ minimum_length + + 0 +
## Non Triggering Examples diff --git a/docs/description/object_literal.md b/docs/description/object_literal.md index 494d0b7..21b0e02 100644 --- a/docs/description/object_literal.md +++ b/docs/description/object_literal.md @@ -1,6 +1,6 @@ # Object Literal -Prefer object literals over image and color inits. +Prefer object literals over image and color inits * **Identifier:** object_literal * **Enabled by default:** No @@ -8,7 +8,38 @@ Prefer object literals over image and color inits. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, image_literal: true, color_literal: true +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ image_literal + + true +
+ color_literal + + true +
## Non Triggering Examples diff --git a/docs/description/opening_brace.md b/docs/description/opening_brace.md index 91c92f0..631c701 100644 --- a/docs/description/opening_brace.md +++ b/docs/description/opening_brace.md @@ -1,6 +1,6 @@ # Opening Brace Spacing -Opening braces should be preceded by a single space and on the same line as the declaration. +Opening braces should be preceded by a single space and on the same line as the declaration * **Identifier:** opening_brace * **Enabled by default:** Yes @@ -8,7 +8,30 @@ Opening braces should be preceded by a single space and on the same line as the * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, allowMultilineFunc: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ allow_multiline_func + + false +
## Non Triggering Examples @@ -214,4 +237,18 @@ func run_Array_method1x(_ N: Int) { func run_Array_method2x(_ N: Int) { } +``` + +```swift + class TestFile { + func problemFunction() { + #if DEBUG + #endif + } + + func openingBraceViolation() + ↓{ + print("Brackets") + } + } ``` \ No newline at end of file diff --git a/docs/description/operator_usage_whitespace.md b/docs/description/operator_usage_whitespace.md index a730ed8..5c109c5 100644 --- a/docs/description/operator_usage_whitespace.md +++ b/docs/description/operator_usage_whitespace.md @@ -1,6 +1,6 @@ # Operator Usage Whitespace -Operators should be surrounded by a single whitespace when they are being used. +Operators should be surrounded by a single whitespace when they are being used * **Identifier:** operator_usage_whitespace * **Enabled by default:** No @@ -8,7 +8,46 @@ Operators should be surrounded by a single whitespace when they are being used. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, lines_look_around: 2, skip_aligned_constants: true, allowed_no_space_operators: ["...", "..<"] +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ lines_look_around + + 2 +
+ skip_aligned_constants + + true +
+ allowed_no_space_operators + + ["...", "..<"] +
## Non Triggering Examples @@ -134,7 +173,7 @@ return path.flatMap { path in ``` ```swift -internal static func == (lhs: Vertix, rhs: Vertix) -> Bool { +internal static func == (lhs: Vertex, rhs: Vertex) -> Bool { return lhs.filePath == rhs.filePath && lhs.originalRemoteString == rhs.originalRemoteString && lhs.rootDirectory == rhs.rootDirectory @@ -142,7 +181,7 @@ internal static func == (lhs: Vertix, rhs: Vertix) -> Bool { ``` ```swift -internal static func == (lhs: Vertix, rhs: Vertix) -> Bool { +internal static func == (lhs: Vertex, rhs: Vertex) -> Bool { return lhs.filePath == rhs.filePath && lhs.originalRemoteString == rhs.originalRemoteString && lhs.rootDirectory == rhs.rootDirectory diff --git a/docs/description/operator_whitespace.md b/docs/description/operator_whitespace.md index 594908e..ade7e3b 100644 --- a/docs/description/operator_whitespace.md +++ b/docs/description/operator_whitespace.md @@ -1,6 +1,6 @@ # Operator Function Whitespace -Operators should be surrounded by a single whitespace when defining them. +Operators should be surrounded by a single whitespace when defining them * **Identifier:** operator_whitespace * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Operators should be surrounded by a single whitespace when defining them. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/optional_enum_case_matching.md b/docs/description/optional_enum_case_matching.md index 6a73f13..9f82d14 100644 --- a/docs/description/optional_enum_case_matching.md +++ b/docs/description/optional_enum_case_matching.md @@ -1,6 +1,6 @@ # Optional Enum Case Match -Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above. +Matching an enum case against an optional enum without '?' is supported on Swift 5.1 and above * **Identifier:** optional_enum_case_matching * **Enabled by default:** No @@ -8,7 +8,22 @@ Matching an enum case against an optional enum without '?' is supported on Swift * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.1.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/orphaned_doc_comment.md b/docs/description/orphaned_doc_comment.md index c225ca5..33d15ad 100644 --- a/docs/description/orphaned_doc_comment.md +++ b/docs/description/orphaned_doc_comment.md @@ -1,6 +1,6 @@ # Orphaned Doc Comment -A doc comment should be attached to a declaration. +A doc comment should be attached to a declaration * **Identifier:** orphaned_doc_comment * **Enabled by default:** Yes @@ -8,7 +8,22 @@ A doc comment should be attached to a declaration. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/overridden_super_call.md b/docs/description/overridden_super_call.md index 041e82b..82f0768 100644 --- a/docs/description/overridden_super_call.md +++ b/docs/description/overridden_super_call.md @@ -1,6 +1,6 @@ -# Overridden methods call super +# Overridden Method Calls Super -Some overridden methods should always call super +Some overridden methods should always call super. * **Identifier:** overridden_super_call * **Enabled by default:** No @@ -8,7 +8,38 @@ Some overridden methods should always call super * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, excluded: [], included: ["*"] +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ excluded + + [] +
+ included + + ["*"] +
## Non Triggering Examples diff --git a/docs/description/override_in_extension.md b/docs/description/override_in_extension.md index 21b037e..fdc5127 100644 --- a/docs/description/override_in_extension.md +++ b/docs/description/override_in_extension.md @@ -1,6 +1,6 @@ # Override in Extension -Extensions shouldn't override declarations. +Extensions shouldn't override declarations * **Identifier:** override_in_extension * **Enabled by default:** No @@ -8,7 +8,22 @@ Extensions shouldn't override declarations. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/pattern_matching_keywords.md b/docs/description/pattern_matching_keywords.md index e83aee1..630515c 100644 --- a/docs/description/pattern_matching_keywords.md +++ b/docs/description/pattern_matching_keywords.md @@ -1,6 +1,6 @@ # Pattern Matching Keywords -Combine multiple pattern matching bindings by moving keywords out of tuples. +Combine multiple pattern matching bindings by moving keywords out of tuples * **Identifier:** pattern_matching_keywords * **Enabled by default:** No @@ -8,7 +8,22 @@ Combine multiple pattern matching bindings by moving keywords out of tuples. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/period_spacing.md b/docs/description/period_spacing.md new file mode 100644 index 0000000..3037d52 --- /dev/null +++ b/docs/description/period_spacing.md @@ -0,0 +1,91 @@ +# Period Spacing + +Periods should not be followed by more than one space + +* **Identifier:** period_spacing +* **Enabled by default:** No +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ +## Non Triggering Examples + +```swift +let pi = 3.2 +``` + +```swift +let pi = Double.pi +``` + +```swift +let pi = Double. pi +``` + +```swift +let pi = Double. pi +``` + +```swift +// A. Single. +``` + +```swift +/// - code: Identifier of the error. Integer. +``` + +```swift +// value: Multiline. +// Comment. +``` + +```swift +/** +Sentence ended in period. + +- Sentence 2 new line characters after. +**/ +``` + +## Triggering Examples + +```swift +/* Only god knows why. ↓ This symbol does nothing. */ +``` + +```swift +// Only god knows why. ↓ This symbol does nothing. +``` + +```swift +// Single. Double. ↓ End. +``` + +```swift +// Single. Double. ↓ Triple. ↓ End. +``` + +```swift +// Triple. ↓ Quad. ↓ End. +``` + +```swift +/// - code: Identifier of the error. ↓ Integer. +``` \ No newline at end of file diff --git a/docs/description/prefer_nimble.md b/docs/description/prefer_nimble.md index 41829bd..8c234e3 100644 --- a/docs/description/prefer_nimble.md +++ b/docs/description/prefer_nimble.md @@ -1,6 +1,6 @@ # Prefer Nimble -Prefer Nimble matchers over XCTAssert functions. +Prefer Nimble matchers over XCTAssert functions * **Identifier:** prefer_nimble * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer Nimble matchers over XCTAssert functions. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/prefer_self_in_static_references.md b/docs/description/prefer_self_in_static_references.md index dd5db56..81def90 100644 --- a/docs/description/prefer_self_in_static_references.md +++ b/docs/description/prefer_self_in_static_references.md @@ -1,6 +1,6 @@ # Prefer Self in Static References -Use `Self` to refer to the surrounding type name. +Use `Self` to refer to the surrounding type name * **Identifier:** prefer_self_in_static_references * **Enabled by default:** No @@ -8,7 +8,22 @@ Use `Self` to refer to the surrounding type name. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -40,6 +55,18 @@ Use `Self` to refer to the surrounding type name. ## Triggering Examples +```swift +final class CheckCellView: NSTableCellView { + @IBOutlet var checkButton: NSButton! + + override func awakeFromNib() { + checkButton.action = #selector(↓CheckCellView.check(_:)) + } + + @objc func check(_ button: AnyObject?) {} +} +``` + ```swift class C { struct S { @@ -53,14 +80,23 @@ Use `Self` to refer to the surrounding type name. } ``` +```swift + class C { + func f() { + _ = [↓C]() + _ = [Int: ↓C]() + } + } +``` + ```swift struct S { let j: Int static let i = 1 static func f() -> Int { ↓S.i } func g() -> Any { ↓S.self } - func h() -> S { ↓S(j: 2) } - func i() -> KeyPath { \↓S.j } + func h() -> ↓S { ↓S(j: 2) } + func i() -> KeyPath<↓S, Int> { \↓S.j } func j(@Wrap(-↓S.i, ↓S.i) n: Int = ↓S.i) {} } ``` @@ -80,7 +116,7 @@ Use `Self` to refer to the surrounding type name. ```swift enum E { case A - static func f() -> E { ↓E.A } - static func g() -> E { ↓E.f() } + static func f() -> ↓E { ↓E.A } + static func g() -> ↓E { ↓E.f() } } ``` \ No newline at end of file diff --git a/docs/description/prefer_self_type_over_type_of_self.md b/docs/description/prefer_self_type_over_type_of_self.md index d679609..3233887 100644 --- a/docs/description/prefer_self_type_over_type_of_self.md +++ b/docs/description/prefer_self_type_over_type_of_self.md @@ -1,6 +1,6 @@ # Prefer Self Type Over Type of Self -Prefer `Self` over `type(of: self)` when accessing properties or calling methods. +Prefer `Self` over `type(of: self)` when accessing properties or calling methods * **Identifier:** prefer_self_type_over_type_of_self * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer `Self` over `type(of: self)` when accessing properties or calling methods * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.1.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/prefer_zero_over_explicit_init.md b/docs/description/prefer_zero_over_explicit_init.md index 56feb85..cd95a5b 100644 --- a/docs/description/prefer_zero_over_explicit_init.md +++ b/docs/description/prefer_zero_over_explicit_init.md @@ -8,7 +8,22 @@ Prefer `.zero` over explicit init with zero parameters (e.g. `CGPoint(x: 0, y: 0 * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/prefixed_toplevel_constant.md b/docs/description/prefixed_toplevel_constant.md index ed9ba21..d100a81 100644 --- a/docs/description/prefixed_toplevel_constant.md +++ b/docs/description/prefixed_toplevel_constant.md @@ -1,6 +1,6 @@ # Prefixed Top-Level Constant -Top-level constants should be prefixed by `k`. +Top-level constants should be prefixed by `k` * **Identifier:** prefixed_toplevel_constant * **Enabled by default:** No @@ -8,7 +8,30 @@ Top-level constants should be prefixed by `k`. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, only_private: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ only_private + + false +
## Non Triggering Examples diff --git a/docs/description/private_action.md b/docs/description/private_action.md index 032453c..8faff71 100644 --- a/docs/description/private_action.md +++ b/docs/description/private_action.md @@ -1,6 +1,6 @@ # Private Actions -IBActions should be private. +IBActions should be private * **Identifier:** private_action * **Enabled by default:** No @@ -8,7 +8,22 @@ IBActions should be private. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/private_outlet.md b/docs/description/private_outlet.md index 5a046e0..a6ae706 100644 --- a/docs/description/private_outlet.md +++ b/docs/description/private_outlet.md @@ -1,6 +1,6 @@ # Private Outlets -IBOutlets should be private to avoid leaking UIKit to higher layers. +IBOutlets should be private to avoid leaking UIKit to higher layers * **Identifier:** private_outlet * **Enabled by default:** No @@ -8,7 +8,30 @@ IBOutlets should be private to avoid leaking UIKit to higher layers. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, allow_private_set: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ allow_private_set + + false +
## Non Triggering Examples diff --git a/docs/description/private_over_fileprivate.md b/docs/description/private_over_fileprivate.md index 038f785..072b373 100644 --- a/docs/description/private_over_fileprivate.md +++ b/docs/description/private_over_fileprivate.md @@ -1,6 +1,6 @@ -# Private over fileprivate +# Private over Fileprivate -Prefer `private` over `fileprivate` declarations. +Prefer `private` over `fileprivate` declarations * **Identifier:** private_over_fileprivate * **Enabled by default:** Yes @@ -8,7 +8,30 @@ Prefer `private` over `fileprivate` declarations. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, validate_extensions: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ validate_extensions + + false +
## Non Triggering Examples diff --git a/docs/description/private_subject.md b/docs/description/private_subject.md index 64b70ad..1667bdb 100644 --- a/docs/description/private_subject.md +++ b/docs/description/private_subject.md @@ -1,6 +1,6 @@ # Private Combine Subject -Combine Subject should be private. +Combine Subject should be private * **Identifier:** private_subject * **Enabled by default:** No @@ -8,7 +8,22 @@ Combine Subject should be private. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -32,7 +47,7 @@ final class Foobar { ```swift final class Foobar { - private let goodSubject: PassthroughSubject = .ini() + private let goodSubject: PassthroughSubject = .init() } ``` @@ -56,7 +71,7 @@ final class Foobar { ```swift final class Foobar { - private let goodSubject: CurrentValueSubject = .ini("toto") + private let goodSubject: CurrentValueSubject = .init("toto") } ``` @@ -88,7 +103,7 @@ final class Foobar { ```swift final class Foobar { private let goodSubject: - PassthroughSubject = .ini() + PassthroughSubject = .init() } ``` @@ -99,6 +114,22 @@ final class Foobar { } ``` +```swift +final class Foobar { + private let goodSubject: CurrentValueSubject + init() { + let goodSubject = CurrentValueSubject(true) + self.goosSubject = goodSubject + } +} +``` + +```swift +func foo() { + let goodSubject = PassthroughSubject(true) +} +``` + ## Triggering Examples ```swift @@ -127,7 +158,7 @@ final class Foobar { ```swift final class Foobar { - let goodSubject: PassthroughSubject = .ini() + let goodSubject: PassthroughSubject = .init() } ``` @@ -221,7 +252,7 @@ final class Foobar { ```swift final class Foobar { let ↓badSubject: - PassthroughSubject = .ini() + PassthroughSubject = .init() } ``` diff --git a/docs/description/private_unit_test.md b/docs/description/private_unit_test.md index b54f8d2..8c24e17 100644 --- a/docs/description/private_unit_test.md +++ b/docs/description/private_unit_test.md @@ -1,6 +1,6 @@ # Private Unit Test -Unit tests marked private are silently skipped. +Unit tests marked private are silently skipped * **Identifier:** private_unit_test * **Enabled by default:** Yes @@ -8,7 +8,30 @@ Unit tests marked private are silently skipped. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning: XCTestCase +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ regex + + "XCTestCase" +
## Non Triggering Examples diff --git a/docs/description/prohibited_interface_builder.md b/docs/description/prohibited_interface_builder.md index c5cfc8d..057e5c0 100644 --- a/docs/description/prohibited_interface_builder.md +++ b/docs/description/prohibited_interface_builder.md @@ -1,6 +1,6 @@ # Prohibited Interface Builder -Creating views using Interface Builder should be avoided. +Creating views using Interface Builder should be avoided * **Identifier:** prohibited_interface_builder * **Enabled by default:** No @@ -8,7 +8,22 @@ Creating views using Interface Builder should be avoided. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/prohibited_super_call.md b/docs/description/prohibited_super_call.md index 4d75527..d7e2da4 100644 --- a/docs/description/prohibited_super_call.md +++ b/docs/description/prohibited_super_call.md @@ -1,6 +1,6 @@ -# Prohibited calls to super +# Prohibited Calls to Super -Some methods should not call super +Some methods should not call super. * **Identifier:** prohibited_super_call * **Enabled by default:** No @@ -8,7 +8,38 @@ Some methods should not call super * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, excluded: [[]], included: [["*"]] +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ excluded + + [] +
+ included + + ["*"] +
## Non Triggering Examples diff --git a/docs/description/protocol_property_accessors_order.md b/docs/description/protocol_property_accessors_order.md index 13f742b..c6dcd36 100644 --- a/docs/description/protocol_property_accessors_order.md +++ b/docs/description/protocol_property_accessors_order.md @@ -1,6 +1,6 @@ # Protocol Property Accessors Order -When declaring properties in protocols, the order of accessors should be `get set`. +When declaring properties in protocols, the order of accessors should be `get set` * **Identifier:** protocol_property_accessors_order * **Enabled by default:** Yes @@ -8,7 +8,22 @@ When declaring properties in protocols, the order of accessors should be `get se * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/quick_discouraged_call.md b/docs/description/quick_discouraged_call.md index 9d5e775..8524a23 100644 --- a/docs/description/quick_discouraged_call.md +++ b/docs/description/quick_discouraged_call.md @@ -8,10 +8,35 @@ Discouraged call inside 'describe' and/or 'context' block. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples +```swift +class TotoTests { + override func spec() { + describe("foo") { + let foo = Foo() + } + } +} +``` + ```swift class TotoTests: QuickSpec { override func spec() { @@ -50,6 +75,32 @@ class TotoTests: QuickSpec { } ``` +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + justBeforeEach { + let foo = Foo() + foo.toto() + } + } + } +} +``` + +```swift +class TotoTests: QuickSpec { + override func spec() { + describe("foo") { + aroundEach { + let foo = Foo() + foo.toto() + } + } + } +} +``` + ```swift class TotoTests: QuickSpec { override func spec() { @@ -168,15 +219,18 @@ class TotoTests: QuickSpec { ## Triggering Examples ```swift -class TotoTests { +class TotoTests: QuickSpec { override func spec() { describe("foo") { - let foo = Foo() + let foo = ↓Foo() } } } +``` + +```swift class TotoTests: QuickSpec { - override func spec() { + override static func spec() { describe("foo") { let foo = ↓Foo() } diff --git a/docs/description/quick_discouraged_focused_test.md b/docs/description/quick_discouraged_focused_test.md index 3942056..4727ded 100644 --- a/docs/description/quick_discouraged_focused_test.md +++ b/docs/description/quick_discouraged_focused_test.md @@ -1,6 +1,6 @@ # Quick Discouraged Focused Test -Discouraged focused test. Other tests won't run while this one is focused. +Non-focused tests won't run as long as this test is focused * **Identifier:** quick_discouraged_focused_test * **Enabled by default:** No @@ -8,7 +8,22 @@ Discouraged focused test. Other tests won't run while this one is focused. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/quick_discouraged_pending_test.md b/docs/description/quick_discouraged_pending_test.md index 10da0b4..b5e8605 100644 --- a/docs/description/quick_discouraged_pending_test.md +++ b/docs/description/quick_discouraged_pending_test.md @@ -1,6 +1,6 @@ # Quick Discouraged Pending Test -Discouraged pending test. This test won't run while it's marked as pending. +This test won't run as long as it's marked pending * **Identifier:** quick_discouraged_pending_test * **Enabled by default:** No @@ -8,7 +8,22 @@ Discouraged pending test. This test won't run while it's marked as pending. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/raw_value_for_camel_cased_codable_enum.md b/docs/description/raw_value_for_camel_cased_codable_enum.md index 15776c4..95e3cd0 100644 --- a/docs/description/raw_value_for_camel_cased_codable_enum.md +++ b/docs/description/raw_value_for_camel_cased_codable_enum.md @@ -1,6 +1,6 @@ -# Raw Value For Camel Cased Codable Enum +# Raw Value for Camel Cased Codable Enum -Camel cased cases of Codable String enums should have raw value. +Camel cased cases of Codable String enums should have raw values * **Identifier:** raw_value_for_camel_cased_codable_enum * **Enabled by default:** No @@ -8,7 +8,22 @@ Camel cased cases of Codable String enums should have raw value. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/reduce_boolean.md b/docs/description/reduce_boolean.md index 9fae3bf..2e9ec85 100644 --- a/docs/description/reduce_boolean.md +++ b/docs/description/reduce_boolean.md @@ -1,6 +1,6 @@ # Reduce Boolean -Prefer using `.allSatisfy()` or `.contains()` over `reduce(true)` or `reduce(false)` +Prefer using `.allSatisfy()` or `.contains()` over `reduce(true)` or `reduce(false)`. * **Identifier:** reduce_boolean * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Prefer using `.allSatisfy()` or `.contains()` over `reduce(true)` or `reduce(fal * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -20,6 +35,10 @@ nums.reduce(0) { $0.0 + $0.1 } nums.reduce(0.0) { $0.0 + $0.1 } ``` +```swift +nums.reduce(initial: true) { $0.0 && $0.1 == 3 } +``` + ## Triggering Examples ```swift @@ -52,4 +71,8 @@ let allValid = validators.↓reduce(true, { $0 && $1(input) }) ```swift let anyValid = validators.↓reduce(false, { $0 || $1(input) }) +``` + +```swift +nums.reduce(into: true) { (r: inout Bool, s) in r = r && (s == 3) } ``` \ No newline at end of file diff --git a/docs/description/reduce_into.md b/docs/description/reduce_into.md index c705e5d..1f49703 100644 --- a/docs/description/reduce_into.md +++ b/docs/description/reduce_into.md @@ -1,4 +1,4 @@ -# Reduce Into +# Reduce into Prefer `reduce(into:_:)` over `reduce(_:_:)` for copy-on-write types @@ -8,7 +8,22 @@ Prefer `reduce(into:_:)` over `reduce(_:_:)` for copy-on-write types * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/redundant_discardable_let.md b/docs/description/redundant_discardable_let.md index c0d4591..c4d6a35 100644 --- a/docs/description/redundant_discardable_let.md +++ b/docs/description/redundant_discardable_let.md @@ -1,6 +1,6 @@ # Redundant Discardable Let -Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function. +Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function * **Identifier:** redundant_discardable_let * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/redundant_nil_coalescing.md b/docs/description/redundant_nil_coalescing.md index e3b45be..dd4abf2 100644 --- a/docs/description/redundant_nil_coalescing.md +++ b/docs/description/redundant_nil_coalescing.md @@ -8,7 +8,22 @@ nil coalescing operator is only evaluated if the lhs is nil, coalescing operator * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/redundant_objc_attribute.md b/docs/description/redundant_objc_attribute.md index ebaa138..4439b43 100644 --- a/docs/description/redundant_objc_attribute.md +++ b/docs/description/redundant_objc_attribute.md @@ -1,6 +1,6 @@ # Redundant @objc Attribute -Objective-C attribute (@objc) is redundant in declaration. +Objective-C attribute (@objc) is redundant in declaration * **Identifier:** redundant_objc_attribute * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Objective-C attribute (@objc) is redundant in declaration. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -49,7 +64,7 @@ private @GKInspectable var foo: String! {} class Foo { var bar: Any? @objc - class Bar { + class Bar: NSObject { @objc var foo: Any? } @@ -101,15 +116,16 @@ class Foo: NSObject { ```swift @objcMembers class Foo { + @objc class Bar: NSObject { - @objc var foo: Any + @objc var foo: Any? } } ``` ```swift @objcMembers -class Foo { +class Foo: NSObject { @objc class Bar {} } ``` @@ -121,6 +137,64 @@ extension BlockEditorSettings { } ``` +```swift +@objcMembers +public class Foo: NSObject { + @objc + private func handler(_ notification: Notification) { + } + + func registerForNotifications() { + NotificationCenter.default.addObserver(self, selector: #selector(handler(_:)), name: nil, object: nil) + } +} +``` + +```swift +class Foo: NSObject { } + +@objc extension Foo { + @objc enum Bar: Int { + case bar + } + + var bar: Bar { .bar } +} +``` + +```swift +class Foo: NSObject { } + +@objc extension Foo { + @objc private enum Baz: Int { + case baz + } + + private var baz: Baz { .baz } +} +``` + +```swift +@objcMembers +internal class Foo: NSObject { + @objc + private var baz: Int = 1 + + var x: Any? { + value(forKey: "baz") + } +} +``` + +```swift +@objcMembers +class Foo: NSObject { + @objc enum Bar: Int { + case bar + } +} +``` + ## Triggering Examples ```swift @@ -161,14 +235,14 @@ extension BlockEditorSettings { ```swift @objcMembers -class Foo { +class Foo: NSObject { ↓@objc var bar: Any? } ``` ```swift @objcMembers -class Foo { +class Foo: NSObject { ↓@objc var bar: Any? ↓@objc var foo: Any? @objc @@ -201,7 +275,7 @@ extension Foo { ```swift @objcMembers -class Foo { +class Foo: NSObject { @objcMembers class Bar: NSObject { ↓@objc var foo: Any diff --git a/docs/description/redundant_optional_initialization.md b/docs/description/redundant_optional_initialization.md index 0d004c6..d4fc4b8 100644 --- a/docs/description/redundant_optional_initialization.md +++ b/docs/description/redundant_optional_initialization.md @@ -1,6 +1,6 @@ # Redundant Optional Initialization -Initializing an optional variable with nil is redundant. +Initializing an optional variable with nil is redundant * **Identifier:** redundant_optional_initialization * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Initializing an optional variable with nil is redundant. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/redundant_self_in_closure.md b/docs/description/redundant_self_in_closure.md new file mode 100644 index 0000000..8276f69 --- /dev/null +++ b/docs/description/redundant_self_in_closure.md @@ -0,0 +1,195 @@ +# Redundant Self in Closure + +Explicit use of 'self' is not required + +* **Identifier:** redundant_self_in_closure +* **Enabled by default:** No +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ +## Non Triggering Examples + +```swift + struct S { + var x = 0 + func f(_ work: @escaping () -> Void) { work() } + func g() { + f { + x = 1 + f { x = 1 } + g() + } + } + } +``` + +```swift + class C { + var x = 0 + func f(_ work: @escaping () -> Void) { work() } + func g() { + f { [weak self] in + self?.x = 1 + self?.g() + guard let self = self ?? C() else { return } + self?.x = 1 + } + C().f { self.x = 1 } + f { [weak self] in if let self { x = 1 } } + } + } +``` + +```swift + struct S { + var x = 0, error = 0, exception = 0 + var y: Int?, z: Int?, u: Int, v: Int?, w: Int? + func f(_ work: @escaping (Int) -> Void) { work() } + func g(x: Int) { + f { u in + self.x = x + let x = 1 + self.x = 2 + if let y, let v { + self.y = 3 + self.v = 1 + } + guard let z else { + let v = 4 + self.x = 5 + self.v = 6 + return + } + self.z = 7 + while let v { self.v = 8 } + for w in [Int]() { self.w = 9 } + self.u = u + do {} catch { self.error = 10 } + do {} catch let exception { self.exception = 11 } + } + } + } +``` + +```swift + enum E { + case a(Int) + case b(Int, Int) + } + struct S { + var x: E = .a(3), y: Int, z: Int + func f(_ work: @escaping () -> Void) { work() } + func g(x: Int) { + f { + switch x { + case let .a(y): + self.y = 1 + case .b(let y, var z): + self.y = 2 + self.z = 3 + } + } + } + } +``` + +## Triggering Examples + +```swift + struct S { + var x = 0 + func f(_ work: @escaping () -> Void) { work() } + func g() { + f { + ↓self.x = 1 + if ↓self.x == 1 { ↓self.g() } + } + } + } +``` + +```swift + class C { + var x = 0 + func g() { + { + ↓self.x = 1 + ↓self.g() + }() + } + } +``` + +```swift + class C { + var x = 0 + func f(_ work: @escaping () -> Void) { work() } + func g() { + f { [self] in + ↓self.x = 1 + ↓self.g() + f { self.x = 1 } + } + } + } +``` + +```swift + class C { + var x = 0 + func f(_ work: @escaping () -> Void) { work() } + func g() { + f { [unowned self] in ↓self.x = 1 } + f { [self = self] in ↓self.x = 1 } + f { [s = self] in s.x = 1 } + } + } +``` + +```swift + struct S { + var x = 0 + var y: Int?, z: Int?, v: Int?, w: Int? + func f(_ work: @escaping () -> Void) { work() } + func g(w: Int, _ v: Int) { + f { + self.w = 1 + ↓self.x = 2 + if let y { ↓self.x = 3 } + else { ↓self.y = 3 } + guard let z else { + ↓self.z = 4 + ↓self.x = 5 + return + } + ↓self.y = 6 + while let y { ↓self.x = 7 } + for y in [Int]() { ↓self.x = 8 } + self.v = 9 + do { + let x = 10 + self.x = 11 + } + ↓self.x = 12 + } + } + } +``` \ No newline at end of file diff --git a/docs/description/redundant_set_access_control.md b/docs/description/redundant_set_access_control.md index a0b353f..7bce61b 100644 --- a/docs/description/redundant_set_access_control.md +++ b/docs/description/redundant_set_access_control.md @@ -1,6 +1,6 @@ -# Redundant Set Access Control Rule +# Redundant Access Control for Setter -Property setter access level shouldn't be explicit if it's the same as the variable access level. +Property setter access level shouldn't be explicit if it's the same as the variable access level * **Identifier:** redundant_set_access_control * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Property setter access level shouldn't be explicit if it's the same as the varia * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/redundant_string_enum_value.md b/docs/description/redundant_string_enum_value.md index a537c96..fb13d06 100644 --- a/docs/description/redundant_string_enum_value.md +++ b/docs/description/redundant_string_enum_value.md @@ -1,6 +1,6 @@ # Redundant String Enum Value -String enum values can be omitted when they are equal to the enumcase name. +String enum values can be omitted when they are equal to the enumcase name * **Identifier:** redundant_string_enum_value * **Enabled by default:** Yes @@ -8,7 +8,22 @@ String enum values can be omitted when they are equal to the enumcase name. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/redundant_type_annotation.md b/docs/description/redundant_type_annotation.md index dd150e4..11f37cf 100644 --- a/docs/description/redundant_type_annotation.md +++ b/docs/description/redundant_type_annotation.md @@ -8,7 +8,22 @@ Variables should not have redundant type annotation * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/redundant_void_return.md b/docs/description/redundant_void_return.md index cf87639..d423a75 100644 --- a/docs/description/redundant_void_return.md +++ b/docs/description/redundant_void_return.md @@ -1,6 +1,6 @@ # Redundant Void Return -Returning Void in a function declaration is redundant. +Returning Void in a function declaration is redundant * **Identifier:** redundant_void_return * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Returning Void in a function declaration is redundant. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/required_deinit.md b/docs/description/required_deinit.md index 4332b68..f1578bb 100644 --- a/docs/description/required_deinit.md +++ b/docs/description/required_deinit.md @@ -1,6 +1,6 @@ # Required Deinit -Classes should have an explicit deinit method. +Classes should have an explicit deinit method * **Identifier:** required_deinit * **Enabled by default:** No @@ -8,7 +8,22 @@ Classes should have an explicit deinit method. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/required_enum_case.md b/docs/description/required_enum_case.md index f57611c..774c0c6 100644 --- a/docs/description/required_enum_case.md +++ b/docs/description/required_enum_case.md @@ -8,13 +8,44 @@ Enums conforming to a specified protocol must implement a specific case(s). * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** No protocols configured. In config add 'required_enum_case' to 'opt_in_rules' and config using : - -'required_enum_case: - {Protocol Name}: - {Case Name}:{warning|error} - {Case Name}:{warning|error} - +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ {Protocol Name} + + + + + + + + + + + + + + + +
KeyValue
+ {Case Name 1} + + {warning|error} +
+ {Case Name 2} + + {warning|error} +
+
## Non Triggering Examples diff --git a/docs/description/return_arrow_whitespace.md b/docs/description/return_arrow_whitespace.md index d24687c..a456e68 100644 --- a/docs/description/return_arrow_whitespace.md +++ b/docs/description/return_arrow_whitespace.md @@ -1,6 +1,6 @@ # Returning Whitespace -Return arrow and return type should be separated by a single space or on a separate line. +Return arrow and return type should be separated by a single space or on a separate line * **Identifier:** return_arrow_whitespace * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Return arrow and return type should be separated by a single space or on a separ * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/return_value_from_void_function.md b/docs/description/return_value_from_void_function.md index 40a027c..6d37d7d 100644 --- a/docs/description/return_value_from_void_function.md +++ b/docs/description/return_value_from_void_function.md @@ -1,6 +1,6 @@ # Return Value from Void Function -Returning values from Void functions should be avoided. +Returning values from Void functions should be avoided * **Identifier:** return_value_from_void_function * **Enabled by default:** No @@ -8,7 +8,22 @@ Returning values from Void functions should be avoided. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.1.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/self_binding.md b/docs/description/self_binding.md index 352135d..23ca01c 100644 --- a/docs/description/self_binding.md +++ b/docs/description/self_binding.md @@ -8,7 +8,30 @@ Re-bind `self` to a consistent identifier name. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, bindIdentifier: self +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ bind_identifier + + "self" +
## Non Triggering Examples @@ -17,7 +40,7 @@ if let self = self { return } ``` ```swift -guard let self = self else else { return } +guard let self = self else { return } ``` ```swift @@ -25,7 +48,7 @@ if let this = this { return } ``` ```swift -guard let this = this else else { return } +guard let this = this else { return } ``` ```swift @@ -33,7 +56,7 @@ if let this = self { return } ``` ```swift -guard let this = self else else { return } +guard let this = self else { return } ``` ## Triggering Examples @@ -43,7 +66,7 @@ if let ↓`self` = self { return } ``` ```swift -guard let ↓`self` = self else else { return } +guard let ↓`self` = self else { return } ``` ```swift @@ -51,7 +74,7 @@ if let ↓this = self { return } ``` ```swift -guard let ↓this = self else else { return } +guard let ↓this = self else { return } ``` ```swift diff --git a/docs/description/self_in_property_initialization.md b/docs/description/self_in_property_initialization.md index 306a6c1..332940f 100644 --- a/docs/description/self_in_property_initialization.md +++ b/docs/description/self_in_property_initialization.md @@ -1,6 +1,6 @@ # Self in Property Initialization -`self` refers to the unapplied `NSObject.self()` method, which is likely not expected. Make the variable `lazy` to be able to refer to the current instance or use `ClassName.self`. +`self` refers to the unapplied `NSObject.self()` method, which is likely not expected; make the variable `lazy` to be able to refer to the current instance or use `ClassName.self` * **Identifier:** self_in_property_initialization * **Enabled by default:** Yes @@ -8,7 +8,22 @@ * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/shorthand_operator.md b/docs/description/shorthand_operator.md index cac88a2..f8338ab 100644 --- a/docs/description/shorthand_operator.md +++ b/docs/description/shorthand_operator.md @@ -1,6 +1,6 @@ # Shorthand Operator -Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning. +Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning * **Identifier:** shorthand_operator * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigni * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** error +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + error +
## Non Triggering Examples diff --git a/docs/description/shorthand_optional_binding.md b/docs/description/shorthand_optional_binding.md index 587fe78..270966d 100644 --- a/docs/description/shorthand_optional_binding.md +++ b/docs/description/shorthand_optional_binding.md @@ -8,7 +8,22 @@ Use shorthand syntax for optional binding * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.7.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/single_test_class.md b/docs/description/single_test_class.md index 2671186..2b78337 100644 --- a/docs/description/single_test_class.md +++ b/docs/description/single_test_class.md @@ -8,7 +8,30 @@ Test files should contain a single QuickSpec or XCTestCase class. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, test_parent_classes: ["QuickSpec", "XCTestCase"] +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ test_parent_classes + + ["QuickSpec", "XCTestCase"] +
## Non Triggering Examples diff --git a/docs/description/sorted_enum_cases.md b/docs/description/sorted_enum_cases.md new file mode 100644 index 0000000..dfb7a90 --- /dev/null +++ b/docs/description/sorted_enum_cases.md @@ -0,0 +1,102 @@ +# Sorted Enum Cases + +Enum cases should be sorted + +* **Identifier:** sorted_enum_cases +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ +## Non Triggering Examples + +```swift +enum foo { + case a + case b + case c +} +``` + +```swift +enum foo { + case a, b, c +} +``` + +```swift +enum foo { + case a + case b, c +} +``` + +```swift +enum foo { + case a(foo: Foo) + case b(String), c +} +``` + +```swift +@frozen +enum foo { + case b + case a + case c, f, d +} +``` + +## Triggering Examples + +```swift +enum foo { + ↓case b + ↓case a + case c +} +``` + +```swift +enum foo { + case ↓b, ↓a, c +} +``` + +```swift +enum foo { + ↓case b, c + ↓case a +} +``` + +```swift +enum foo { + case a + case b, ↓d, ↓c +} +``` + +```swift +enum foo { + case a(foo: Foo) + case ↓c, ↓b(String) +} +``` \ No newline at end of file diff --git a/docs/description/sorted_first_last.md b/docs/description/sorted_first_last.md index e0aebf1..19aee1b 100644 --- a/docs/description/sorted_first_last.md +++ b/docs/description/sorted_first_last.md @@ -8,7 +8,22 @@ Prefer using `min()` or `max()` over `sorted().first` or `sorted().last` * **Kind:** performance * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -69,6 +84,22 @@ myList.sorted().firstIndex { $0 == key } myList.sorted().lastIndex { $0 == key } ``` +```swift +myList.sorted().first(where: someFunction) +``` + +```swift +myList.sorted().last(where: someFunction) +``` + +```swift +myList.sorted().first { $0 == key } +``` + +```swift +myList.sorted().last { $0 == key } +``` + ## Triggering Examples ```swift diff --git a/docs/description/sorted_imports.md b/docs/description/sorted_imports.md index b3a1bcc..96f3fc5 100644 --- a/docs/description/sorted_imports.md +++ b/docs/description/sorted_imports.md @@ -1,6 +1,6 @@ # Sorted Imports -Imports should be sorted. +Imports should be sorted * **Identifier:** sorted_imports * **Enabled by default:** No @@ -8,7 +8,30 @@ Imports should be sorted. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ grouping + + names +
## Non Triggering Examples diff --git a/docs/description/statement_position.md b/docs/description/statement_position.md index 890cc17..359d752 100644 --- a/docs/description/statement_position.md +++ b/docs/description/statement_position.md @@ -1,6 +1,6 @@ # Statement Position -Else and catch should be on the same line, one space after the previous declaration. +Else and catch should be on the same line, one space after the previous declaration * **Identifier:** statement_position * **Enabled by default:** Yes @@ -8,7 +8,30 @@ Else and catch should be on the same line, one space after the previous declarat * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** (statement_mode) default, (severity) warning +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ statement_mode + + default +
## Non Triggering Examples diff --git a/docs/description/static_operator.md b/docs/description/static_operator.md index aaa499f..433bf38 100644 --- a/docs/description/static_operator.md +++ b/docs/description/static_operator.md @@ -1,6 +1,6 @@ # Static Operator -Operators should be declared as static functions, not free functions. +Operators should be declared as static functions, not free functions * **Identifier:** static_operator * **Enabled by default:** No @@ -8,7 +8,22 @@ Operators should be declared as static functions, not free functions. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/strict_fileprivate.md b/docs/description/strict_fileprivate.md index 5aa8c30..861c684 100644 --- a/docs/description/strict_fileprivate.md +++ b/docs/description/strict_fileprivate.md @@ -1,6 +1,6 @@ -# Strict fileprivate +# Strict Fileprivate -`fileprivate` should be avoided. +`fileprivate` should be avoided * **Identifier:** strict_fileprivate * **Enabled by default:** No @@ -8,7 +8,22 @@ * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -22,56 +37,63 @@ private extension String {} ```swift public -extension String {} + extension String { + var i: Int { 1 } + } ``` ```swift -open extension - String {} + private enum E { + func f() {} + } ``` ```swift -internal extension String {} + public struct S { + internal let i: Int + } ``` -## Triggering Examples - ```swift -↓fileprivate extension String {} + open class C { + private func f() {} + } ``` ```swift -↓fileprivate - extension String {} + internal actor A {} ``` +## Triggering Examples + ```swift -↓fileprivate extension - String {} + ↓fileprivate class C { + ↓fileprivate func f() {} + } ``` ```swift -extension String { - ↓fileprivate func Something(){} -} + ↓fileprivate extension String { + ↓fileprivate var isSomething: Bool { self == "something" } + } ``` ```swift -class MyClass { - ↓fileprivate let myInt = 4 -} + ↓fileprivate actor A { + ↓fileprivate let i = 1 + } ``` ```swift -class MyClass { - ↓fileprivate(set) var myInt = 4 -} + ↓fileprivate struct C { + ↓fileprivate(set) var myInt = 4 + } ``` ```swift -struct Outter { - struct Inter { - ↓fileprivate struct Inner {} - } -} + struct Outter { + struct Inter { + ↓fileprivate struct Inner {} + } + } ``` \ No newline at end of file diff --git a/docs/description/strong_iboutlet.md b/docs/description/strong_iboutlet.md index e0f1cea..f96dc7a 100644 --- a/docs/description/strong_iboutlet.md +++ b/docs/description/strong_iboutlet.md @@ -1,6 +1,6 @@ # Strong IBOutlet -@IBOutlets shouldn't be declared as weak. +@IBOutlets shouldn't be declared as weak * **Identifier:** strong_iboutlet * **Enabled by default:** No @@ -8,7 +8,22 @@ * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/superfluous_disable_command.md b/docs/description/superfluous_disable_command.md index ba8434a..fbe85b2 100644 --- a/docs/description/superfluous_disable_command.md +++ b/docs/description/superfluous_disable_command.md @@ -8,4 +8,19 @@ SwiftLint 'disable' commands are superfluous when the disabled rule would not ha * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning \ No newline at end of file +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
\ No newline at end of file diff --git a/docs/description/superfluous_else.md b/docs/description/superfluous_else.md new file mode 100644 index 0000000..2a687f2 --- /dev/null +++ b/docs/description/superfluous_else.md @@ -0,0 +1,103 @@ +# Superfluous Else + +Else branches should be avoided when the previous if-block exits the current scope + +* **Identifier:** superfluous_else +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ +## Non Triggering Examples + +```swift + if i > 0 { + // comment + } else if i < 12 { + return 2 + } else { + return 3 + } +``` + +```swift + if i > 0 { + let a = 1 + if a > 1 { + // comment + } else { + return 1 + } + // comment + } else { + return 3 + } +``` + +```swift + if i > 0 { + if a > 1 { + return 1 + } + } else { + return 3 + } +``` + +## Triggering Examples + +```swift + ↓if i > 0 { + return 1 + // comment + } else { + return 2 + } +``` + +```swift + ↓if i > 0 { + return 1 + } else ↓if i < 12 { + return 2 + } else if i > 18 { + return 3 + } +``` + +```swift + ↓if i > 0 { + ↓if i < 12 { + return 5 + } else { + ↓if i > 11 { + return 6 + } else { + return 7 + } + } + } else ↓if i < 12 { + return 2 + } else ↓if i < 24 { + return 8 + } else { + return 3 + } +``` \ No newline at end of file diff --git a/docs/description/switch_case_alignment.md b/docs/description/switch_case_alignment.md index b16e4fe..a0298d9 100644 --- a/docs/description/switch_case_alignment.md +++ b/docs/description/switch_case_alignment.md @@ -8,7 +8,30 @@ Case statements should vertically align with their enclosing switch statement, o * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, indented_cases: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ indented_cases + + false +
## Non Triggering Examples @@ -53,6 +76,13 @@ default: } ``` +```swift +let a = switch i { + case 1: 1 + default: 2 +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/switch_case_on_newline.md b/docs/description/switch_case_on_newline.md index 9ddc8b1..d8c248d 100644 --- a/docs/description/switch_case_on_newline.md +++ b/docs/description/switch_case_on_newline.md @@ -1,4 +1,4 @@ -# Switch Case on Newline +# Cases on Newline Cases inside a switch should always be on a newline @@ -8,7 +8,22 @@ Cases inside a switch should always be on a newline * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/syntactic_sugar.md b/docs/description/syntactic_sugar.md index 7caa043..0e006be 100644 --- a/docs/description/syntactic_sugar.md +++ b/docs/description/syntactic_sugar.md @@ -8,7 +8,22 @@ Shorthand syntactic sugar should be used, i.e. [Int] instead of Array. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/test_case_accessibility.md b/docs/description/test_case_accessibility.md index 4c31c3f..0725e91 100644 --- a/docs/description/test_case_accessibility.md +++ b/docs/description/test_case_accessibility.md @@ -1,6 +1,6 @@ -# Test case accessibility +# Test Case Accessibility -Test cases should only contain private non-test members. +Test cases should only contain private non-test members * **Identifier:** test_case_accessibility * **Enabled by default:** No @@ -8,7 +8,38 @@ Test cases should only contain private non-test members. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, allowed_prefixes: [], test_parent_classes: ["QuickSpec", "XCTestCase"] +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ allowed_prefixes + + [] +
+ test_parent_classes + + ["QuickSpec", "XCTestCase"] +
## Non Triggering Examples @@ -27,29 +58,17 @@ class FooTests: XCTestCase { return nestedMember } - override static func setUp() { - super.setUp() - } + override static func setUp() {} - override func setUp() { - super.setUp() - } + override func setUp() {} - override func setUpWithError() throws { - try super.setUpWithError() - } + override func setUpWithError() throws {} - override static func tearDown() { - super.tearDown() - } + override static func tearDown() {} - override func tearDown() { - super.tearDown() - } + override func tearDown() {} - override func tearDownWithError() { - try super.tearDownWithError() - } + override func tearDownWithError() {} override func someFutureXCTestFunction() { super.someFutureXCTestFunction() diff --git a/docs/description/todo.md b/docs/description/todo.md index 8de86b2..03980fa 100644 --- a/docs/description/todo.md +++ b/docs/description/todo.md @@ -8,7 +8,22 @@ TODOs and FIXMEs should be resolved. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/toggle_bool.md b/docs/description/toggle_bool.md index cad6c6a..3b13186 100644 --- a/docs/description/toggle_bool.md +++ b/docs/description/toggle_bool.md @@ -1,6 +1,6 @@ # Toggle Bool -Prefer `someBool.toggle()` over `someBool = !someBool`. +Prefer `someBool.toggle()` over `someBool = !someBool` * **Identifier:** toggle_bool * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer `someBool.toggle()` over `someBool = !someBool`. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/trailing_closure.md b/docs/description/trailing_closure.md index 13b090b..edf1d5a 100644 --- a/docs/description/trailing_closure.md +++ b/docs/description/trailing_closure.md @@ -1,6 +1,6 @@ # Trailing Closure -Trailing closure syntax should be used whenever possible. +Trailing closure syntax should be used whenever possible * **Identifier:** trailing_closure * **Enabled by default:** No @@ -8,7 +8,30 @@ Trailing closure syntax should be used whenever possible. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, only_single_muted_parameter: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ only_single_muted_parameter + + false +
## Non Triggering Examples diff --git a/docs/description/trailing_comma.md b/docs/description/trailing_comma.md index 722a94e..a945b4c 100644 --- a/docs/description/trailing_comma.md +++ b/docs/description/trailing_comma.md @@ -8,7 +8,30 @@ Trailing commas in arrays and dictionaries should be avoided/enforced. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, mandatory_comma: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ mandatory_comma + + false +
## Non Triggering Examples diff --git a/docs/description/trailing_newline.md b/docs/description/trailing_newline.md index 9712571..be7f563 100644 --- a/docs/description/trailing_newline.md +++ b/docs/description/trailing_newline.md @@ -1,6 +1,6 @@ # Trailing Newline -Files should have a single trailing newline. +Files should have a single trailing newline * **Identifier:** trailing_newline * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Files should have a single trailing newline. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/trailing_semicolon.md b/docs/description/trailing_semicolon.md index e51fd58..2b15404 100644 --- a/docs/description/trailing_semicolon.md +++ b/docs/description/trailing_semicolon.md @@ -1,6 +1,6 @@ # Trailing Semicolon -Lines should not have trailing semicolons. +Lines should not have trailing semicolons * **Identifier:** trailing_semicolon * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Lines should not have trailing semicolons. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -32,4 +47,9 @@ let a = 0↓; let a = 0↓; let b = 1 +``` + +```swift +let a = 0↓; // a comment + ``` \ No newline at end of file diff --git a/docs/description/trailing_whitespace.md b/docs/description/trailing_whitespace.md index 280ba44..4ca5400 100644 --- a/docs/description/trailing_whitespace.md +++ b/docs/description/trailing_whitespace.md @@ -1,6 +1,6 @@ # Trailing Whitespace -Lines should not have trailing whitespace. +Lines should not have trailing whitespace * **Identifier:** trailing_whitespace * **Enabled by default:** Yes @@ -8,7 +8,38 @@ Lines should not have trailing whitespace. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, ignores_empty_lines: false, ignores_comments: true +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ ignores_empty_lines + + false +
+ ignores_comments + + true +
## Non Triggering Examples diff --git a/docs/description/type_body_length.md b/docs/description/type_body_length.md index ce014e8..de49b47 100644 --- a/docs/description/type_body_length.md +++ b/docs/description/type_body_length.md @@ -1,6 +1,6 @@ # Type Body Length -Type bodies should not span too many lines. +Type bodies should not span too many lines * **Identifier:** type_body_length * **Enabled by default:** Yes @@ -8,7 +8,30 @@ Type bodies should not span too many lines. * **Kind:** metrics * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning: 250, error: 350 +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ warning + + 250 +
+ error + + 350 +
## Non Triggering Examples diff --git a/docs/description/type_contents_order.md b/docs/description/type_contents_order.md index fe43bf0..7ded60e 100644 --- a/docs/description/type_contents_order.md +++ b/docs/description/type_contents_order.md @@ -8,7 +8,30 @@ Specifies the order of subtypes, properties, methods & more within a type. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, order: [[SwiftLintFramework.TypeContent.case], [SwiftLintFramework.TypeContent.typeAlias, SwiftLintFramework.TypeContent.associatedType], [SwiftLintFramework.TypeContent.subtype], [SwiftLintFramework.TypeContent.typeProperty], [SwiftLintFramework.TypeContent.instanceProperty], [SwiftLintFramework.TypeContent.ibInspectable], [SwiftLintFramework.TypeContent.ibOutlet], [SwiftLintFramework.TypeContent.initializer], [SwiftLintFramework.TypeContent.typeMethod], [SwiftLintFramework.TypeContent.viewLifeCycleMethod], [SwiftLintFramework.TypeContent.ibAction], [SwiftLintFramework.TypeContent.otherMethod], [SwiftLintFramework.TypeContent.subscript], [SwiftLintFramework.TypeContent.deinitializer]] +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ order + + [[case], [type_alias, associated_type], [subtype], [type_property], [instance_property], [ib_inspectable], [ib_outlet], [initializer], [type_method], [view_life_cycle_method], [ib_action], [other_method], [subscript], [deinitializer]] +
## Non Triggering Examples diff --git a/docs/description/type_name.md b/docs/description/type_name.md index 75b81e3..ef1f7c5 100644 --- a/docs/description/type_name.md +++ b/docs/description/type_name.md @@ -9,7 +9,114 @@ Private types may start with an underscore. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** (min_length) w/e: 3/0, (max_length) w/e: 40/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true, validate_protocols: true +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ min_length + + + + + + + + + + + + + + + +
KeyValue
+ warning + + 3 +
+ error + + 0 +
+
+ max_length + + + + + + + + + + + + + + + +
KeyValue
+ warning + + 40 +
+ error + + 1000 +
+
+ excluded + + [] +
+ allowed_symbols + + [] +
+ unallowed_symbols_severity + + error +
+ validates_start_with_lowercase + + error +
+ validate_protocols + + true +
## Non Triggering Examples diff --git a/docs/description/typesafe_array_init.md b/docs/description/typesafe_array_init.md index c9a978c..397614e 100644 --- a/docs/description/typesafe_array_init.md +++ b/docs/description/typesafe_array_init.md @@ -1,6 +1,6 @@ # Type-safe Array Init -Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array. +Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array * **Identifier:** typesafe_array_init * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Ar * **Kind:** lint * **Analyzer rule:** Yes * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/unavailable_condition.md b/docs/description/unavailable_condition.md index eac96fb..01e8e74 100644 --- a/docs/description/unavailable_condition.md +++ b/docs/description/unavailable_condition.md @@ -8,7 +8,22 @@ Use #unavailable/#available instead of #available/#unavailable with an empty bod * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.6.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/unavailable_function.md b/docs/description/unavailable_function.md index 8bac9d1..839d07b 100644 --- a/docs/description/unavailable_function.md +++ b/docs/description/unavailable_function.md @@ -1,6 +1,6 @@ # Unavailable Function -Unimplemented functions should be marked as unavailable. +Unimplemented functions should be marked as unavailable * **Identifier:** unavailable_function * **Enabled by default:** No @@ -8,7 +8,22 @@ Unimplemented functions should be marked as unavailable. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/unhandled_throwing_task.md b/docs/description/unhandled_throwing_task.md new file mode 100644 index 0000000..5ed0071 --- /dev/null +++ b/docs/description/unhandled_throwing_task.md @@ -0,0 +1,220 @@ +# Unhandled Throwing Task + +Errors thrown inside this task are not handled, which may be unexpected. Handle errors inside the task, or use `try await` to access the Tasks value and handle errors. See this forum thread for more details: https://forums.swift.org/t/task-initializer-with-throwing-closure-swallows-error/56066 + +* **Identifier:** unhandled_throwing_task +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + error +
+ +## Non Triggering Examples + +```swift +Task { + try await myThrowingFunction() +} +``` + +```swift +Task { + try? await myThrowingFunction() +} +``` + +```swift +Task { + try! await myThrowingFunction() +} +``` + +```swift +Task { + let text = try myThrowingFunction() + return text +} +``` + +```swift +Task { + do { + try myThrowingFunction() + } catch let e { + print(e) + } +} +``` + +```swift +func someFunction() throws { + Task { + anotherFunction() + do { + try myThrowingFunction() + } catch { + print(error) + } + } + + try something() +} +``` + +```swift +let task = Task { + try await myThrowingFunction() +} +``` + +```swift +var task = Task { + try await myThrowingFunction() +} +``` + +```swift +try await Task { + try await myThrowingFunction() +}.value +``` + +```swift +executor.task = Task { + try await isolatedOpen(.init(executor.asUnownedSerialExecutor())) +} +``` + +```swift +let result = await Task { + throw CancellationError() +}.result +``` + +```swift +func makeTask() -> Task { + return Task { + try await someThrowingFunction() + } +} +``` + +```swift +func makeTask() -> Task { + // Implicit return + Task { + try await someThrowingFunction() + } +} +``` + +```swift +Task { + return Result { + try someThrowingFunc() + } +} +``` + +## Triggering Examples + +```swift +↓Task { + try await myThrowingFunction() +} +``` + +```swift +↓Task { + let text = try myThrowingFunction() + return text +} +``` + +```swift +↓Task { + do { + try myThrowingFunction() + } +} +``` + +```swift +↓Task { + do { + try myThrowingFunction() + } catch let e as FooError { + print(e) + } +} +``` + +```swift +↓Task { + do { + throw FooError.bar + } +} +``` + +```swift +↓Task { + throw FooError.bar +} +``` + +```swift +↓Task<_, _> { + throw FooError.bar +} +``` + +```swift +↓Task { + throw FooError.bar +} +``` + +```swift +↓Task { + do { + try foo() + } catch { + try bar() + } +} +``` + +```swift +↓Task { + do { + try foo() + } catch { + throw BarError() + } +} +``` + +```swift +func doTask() { + ↓Task { + try await someThrowingFunction() + } +} +``` \ No newline at end of file diff --git a/docs/description/unneeded_break_in_switch.md b/docs/description/unneeded_break_in_switch.md index da0c4b4..99f89d8 100644 --- a/docs/description/unneeded_break_in_switch.md +++ b/docs/description/unneeded_break_in_switch.md @@ -1,6 +1,6 @@ # Unneeded Break in Switch -Avoid using unneeded break statements. +Avoid using unneeded break statements * **Identifier:** unneeded_break_in_switch * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Avoid using unneeded break statements. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/unneeded_parentheses_in_closure_argument.md b/docs/description/unneeded_parentheses_in_closure_argument.md index b3f2cee..2793742 100644 --- a/docs/description/unneeded_parentheses_in_closure_argument.md +++ b/docs/description/unneeded_parentheses_in_closure_argument.md @@ -1,6 +1,6 @@ # Unneeded Parentheses in Closure Argument -Parentheses are not needed when declaring closure arguments. +Parentheses are not needed when declaring closure arguments * **Identifier:** unneeded_parentheses_in_closure_argument * **Enabled by default:** No @@ -8,7 +8,22 @@ Parentheses are not needed when declaring closure arguments. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/unneeded_synthesized_initializer.md b/docs/description/unneeded_synthesized_initializer.md new file mode 100644 index 0000000..d189482 --- /dev/null +++ b/docs/description/unneeded_synthesized_initializer.md @@ -0,0 +1,373 @@ +# Unneeded Synthesized Initializer + +Default or memberwise initializers that will be automatically synthesized do not need to be manually defined. + +* **Identifier:** unneeded_synthesized_initializer +* **Enabled by default:** Yes +* **Supports autocorrection:** Yes +* **Kind:** idiomatic +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ +## Non Triggering Examples + +```swift +struct Foo { + let bar: String + + // Synthesized initializer would not be private. + private init(bar: String) { + self.bar = bar + } +} +``` + +```swift +struct Foo { + var bar: String + + // Synthesized initializer would not be private. + private init(bar: String) { + self.bar = bar + } +} +``` + +```swift +struct Foo { + let bar: String + + // Synthesized initializer would not be fileprivate. + fileprivate init(bar: String) { + self.bar = bar + } +} +``` + +```swift +struct Foo { + let bar: String + + // Synthesized initializer would not prepend "foo". + init(bar: String) { + self.bar = "foo" + bar + } +} +``` + +```swift +internal struct Foo { + let bar: String + + // Failable initializer + init?(bar: String) { + self.bar = bar + } +} +``` + +```swift +internal struct Foo { + let bar: String + + // Initializer throws + init(bar: String) throws { + self.bar = bar + } +} +``` + +```swift +internal struct Foo { + let bar: String + + // Different argument labels + init(_ bar: String) { + self.bar = bar + } +} +``` + +```swift +internal struct Foo { + var bar: String = "foo" + + // Different default values + init(bar: String = "bar") { + self.bar = bar + } +} +``` + +```swift +internal struct Foo { + private static var bar: String + + // var is static + init(bar: String) { + Self.bar = bar + } +} +``` + +```swift +internal struct Foo { + private var bar: String + + // var is private + init(bar: String) { + self.bar = bar + } +} +``` + +```swift +internal struct Foo { + fileprivate var bar: String + + // var is fileprivate + init(bar: String) { + self.bar = bar + } +} +``` + +```swift +struct Foo { + var foo: String + var bar: String + + // init has no body + init(foo: String, bar: String) { + } +} +``` + +```swift +struct Foo { + var foo: String + var bar: String + + // foo is not initialized + init(foo: String, bar: String) { + self.bar = bar + } +} +``` + +```swift +struct Foo { + var foo: String + var bar: String + + // Ordering of args is different from properties. + init(bar: String, foo: String) { + self.foo = foo + self.bar = bar + } +} +``` + +```swift +@frozen +public struct Field { + @usableFromInline + let index: Int + + @usableFromInline + let parent: Metadata + + @inlinable // inlinable + init(index: Int, parent: Metadata) { + self.index = index + self.parent = parent + } +} +``` + +```swift +internal struct Foo { + var bar: String = "" + var baz: Int = 0 + + // These initializers must be declared. + init() { } + + init(bar: String = "", baz: Int = 0) { + self.bar = bar + self.baz = baz + } + + // Because manually declared initializers block + // synthesization. + init(bar: String) { + self.bar = bar + } +} +``` + +```swift +struct Foo { + init() { + print("perform side effect") + } +} +``` + +```swift +struct Foo { + var bar: Int = 0 + + init(bar: Int = 0) { + self.bar = bar + print("perform side effect") + } +} +``` + +## Triggering Examples + +```swift +struct Foo { + let bar: String + + ↓init(bar: String) { + self.bar = bar + } +} +``` + +```swift +struct Foo { + var bar: String + + ↓init(bar: String) { + self.bar = bar + } +} +``` + +```swift +private struct Foo { + let bar: String + + ↓init(bar: String) { + self.bar = bar + } +} +``` + +```swift +fileprivate struct Foo { + let bar: String + + ↓init(bar: String) { + self.bar = bar + } +} +``` + +```swift +internal struct Foo { + fileprivate var bar: String + + ↓fileprivate init(bar: String) { + self.bar = bar + } +} +``` + +```swift +internal struct Foo { + private var bar: String + + ↓private init(bar: String) { + self.bar = bar + } +} +``` + +```swift +struct Foo { + var foo: String + var bar: String + + ↓init(foo: String, bar: String) { + self.foo = foo + self.bar = bar + } +} +``` + +```swift +internal struct Foo { + var bar: String + + ↓internal init(bar: String) { + self.bar = bar + } +} +``` + +```swift +struct Foo { + var bar: String = "" + + ↓init() { + // Empty initializer will be generated automatically + // when all vars have default values. + } +} +``` + +```swift +struct Foo { + var bar: String = "" + + ↓init() { + // Empty initializer + } + + ↓init(bar: String = "") { + self.bar = bar + } +} +``` + +```swift +struct Foo { + var bar = "" + + ↓init(bar: String = "") { + self.bar = bar + } +} +``` + +```swift +struct Outer { + struct Inner { + let prop: Int + + ↓init(prop: Int) { + self.prop = prop + } + } +} +``` \ No newline at end of file diff --git a/docs/description/unowned_variable_capture.md b/docs/description/unowned_variable_capture.md index e619289..cbb0301 100644 --- a/docs/description/unowned_variable_capture.md +++ b/docs/description/unowned_variable_capture.md @@ -1,6 +1,6 @@ # Unowned Variable Capture -Prefer capturing references as weak to avoid potential crashes. +Prefer capturing references as weak to avoid potential crashes * **Identifier:** unowned_variable_capture * **Enabled by default:** No @@ -8,7 +8,22 @@ Prefer capturing references as weak to avoid potential crashes. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -36,6 +51,16 @@ foo { bar in _ } foo { $0 } ``` +```swift +final class First {} +final class Second { + unowned var value: First + init(value: First) { + self.value = value + } +} +``` + ## Triggering Examples ```swift diff --git a/docs/description/untyped_error_in_catch.md b/docs/description/untyped_error_in_catch.md index 3cc3111..c29073d 100644 --- a/docs/description/untyped_error_in_catch.md +++ b/docs/description/untyped_error_in_catch.md @@ -1,6 +1,6 @@ # Untyped Error in Catch -Catch statements should not declare error variables without type casting. +Catch statements should not declare error variables without type casting * **Identifier:** untyped_error_in_catch * **Enabled by default:** No @@ -8,7 +8,22 @@ Catch statements should not declare error variables without type casting. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/unused_capture_list.md b/docs/description/unused_capture_list.md index 9d57c15..6cc9518 100644 --- a/docs/description/unused_capture_list.md +++ b/docs/description/unused_capture_list.md @@ -1,14 +1,29 @@ # Unused Capture List -Unused reference in a capture list should be removed. +Unused reference in a capture list should be removed * **Identifier:** unused_capture_list -* **Enabled by default:** Yes +* **Enabled by default:** No * **Supports autocorrection:** No * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -98,6 +113,15 @@ rx.onViewDidAppear.subscribe(onNext: { [unowned self] in }).disposed(by: disposeBag) ``` +```swift +let closure = { [weak self] in + guard let self else { + return + } + someInstanceFunction() +} +``` + ## Triggering Examples ```swift @@ -142,4 +166,14 @@ withEnvironment(apiService: MockService(fetchProjectResponse: project)) { [↓fo ```swift { [↓foo] in _ }() +``` + +```swift +let closure = { [↓weak a] in + // The new `a` immediatly shadows the captured `a` which thus isn't needed. + guard let a = getOptionalValue() else { + return + } + someInstanceFunction() +} ``` \ No newline at end of file diff --git a/docs/description/unused_closure_parameter.md b/docs/description/unused_closure_parameter.md index bbc6c07..e115054 100644 --- a/docs/description/unused_closure_parameter.md +++ b/docs/description/unused_closure_parameter.md @@ -1,6 +1,6 @@ # Unused Closure Parameter -Unused parameter in a closure should be replaced with _. +Unused parameter in a closure should be replaced with _ * **Identifier:** unused_closure_parameter * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Unused parameter in a closure should be replaced with _. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/unused_control_flow_label.md b/docs/description/unused_control_flow_label.md index 5335866..3329def 100644 --- a/docs/description/unused_control_flow_label.md +++ b/docs/description/unused_control_flow_label.md @@ -1,6 +1,6 @@ # Unused Control Flow Label -Unused control flow label should be removed. +Unused control flow label should be removed * **Identifier:** unused_control_flow_label * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Unused control flow label should be removed. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/unused_declaration.md b/docs/description/unused_declaration.md index 7114eb3..9c025c7 100644 --- a/docs/description/unused_declaration.md +++ b/docs/description/unused_declaration.md @@ -1,6 +1,6 @@ # Unused Declaration -Declarations should be referenced at least once within all files linted. +Declarations should be referenced at least once within all files linted * **Identifier:** unused_declaration * **Enabled by default:** No @@ -8,7 +8,38 @@ Declarations should be referenced at least once within all files linted. * **Kind:** lint * **Analyzer rule:** Yes * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** severity: error, include_public_and_open: false, related_usrs_to_skip: ["s:7SwiftUI15PreviewProviderP"] +* **Default configuration:** + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + error +
+ include_public_and_open + + false +
+ related_usrs_to_skip + + ["s:7SwiftUI15PreviewProviderP"] +
## Non Triggering Examples diff --git a/docs/description/unused_enumerated.md b/docs/description/unused_enumerated.md index e15d678..7bd9eee 100644 --- a/docs/description/unused_enumerated.md +++ b/docs/description/unused_enumerated.md @@ -8,7 +8,22 @@ When the index or the item is not used, `.enumerated()` can be removed. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/unused_import.md b/docs/description/unused_import.md index 89cfcda..b2ed7d4 100644 --- a/docs/description/unused_import.md +++ b/docs/description/unused_import.md @@ -1,6 +1,6 @@ # Unused Import -All imported modules should be required to make the file compile. +All imported modules should be required to make the file compile * **Identifier:** unused_import * **Enabled by default:** No @@ -8,7 +8,46 @@ All imported modules should be required to make the file compile. * **Kind:** lint * **Analyzer rule:** Yes * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** severity: warning, require_explicit_imports: false, allowed_transitive_imports: [], always_keep_imports: [] +* **Default configuration:** + + + + + + + + + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ require_explicit_imports + + false +
+ allowed_transitive_imports + + [] +
+ always_keep_imports + + [] +
## Non Triggering Examples @@ -35,7 +74,6 @@ func foo(error: Swift.Error) {} ```swift import Foundation -import ObjectiveC let 👨‍👩‍👧‍👦 = #selector(NSArray.contains(_:)) 👨‍👩‍👧‍👦 == 👨‍👩‍👧‍👦 ``` diff --git a/docs/description/unused_optional_binding.md b/docs/description/unused_optional_binding.md index 4206e54..b755e2b 100644 --- a/docs/description/unused_optional_binding.md +++ b/docs/description/unused_optional_binding.md @@ -8,7 +8,30 @@ Prefer `!= nil` over `let _ =` * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, ignore_optional_try: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ ignore_optional_try + + false +
## Non Triggering Examples diff --git a/docs/description/unused_setter_value.md b/docs/description/unused_setter_value.md index 03b79a8..34e410c 100644 --- a/docs/description/unused_setter_value.md +++ b/docs/description/unused_setter_value.md @@ -1,6 +1,6 @@ # Unused Setter Value -Setter value is not used. +Setter value is not used * **Identifier:** unused_setter_value * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Setter value is not used. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/valid_ibinspectable.md b/docs/description/valid_ibinspectable.md index 97a750f..8f5b27b 100644 --- a/docs/description/valid_ibinspectable.md +++ b/docs/description/valid_ibinspectable.md @@ -8,7 +8,22 @@ * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/vertical_parameter_alignment.md b/docs/description/vertical_parameter_alignment.md index e8a54bb..9fd9284 100644 --- a/docs/description/vertical_parameter_alignment.md +++ b/docs/description/vertical_parameter_alignment.md @@ -1,6 +1,6 @@ # Vertical Parameter Alignment -Function parameters should be aligned vertically if they're in multiple lines in a declaration. +Function parameters should be aligned vertically if they're in multiple lines in a declaration * **Identifier:** vertical_parameter_alignment * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Function parameters should be aligned vertically if they're in multiple lines in * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/vertical_parameter_alignment_on_call.md b/docs/description/vertical_parameter_alignment_on_call.md index 1b52fcf..6478010 100644 --- a/docs/description/vertical_parameter_alignment_on_call.md +++ b/docs/description/vertical_parameter_alignment_on_call.md @@ -1,6 +1,6 @@ -# Vertical Parameter Alignment On Call +# Vertical Parameter Alignment on Call -Function parameters should be aligned vertically if they're in multiple lines in a method call. +Function parameters should be aligned vertically if they're in multiple lines in a method call * **Identifier:** vertical_parameter_alignment_on_call * **Enabled by default:** No @@ -8,7 +8,22 @@ Function parameters should be aligned vertically if they're in multiple lines in * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/vertical_whitespace.md b/docs/description/vertical_whitespace.md index 03df82f..c94d47f 100644 --- a/docs/description/vertical_whitespace.md +++ b/docs/description/vertical_whitespace.md @@ -8,7 +8,30 @@ Limit vertical whitespace to a single empty line. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, max_empty_lines: 1 +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ max_empty_lines + + 1 +
## Non Triggering Examples diff --git a/docs/description/vertical_whitespace_between_cases.md b/docs/description/vertical_whitespace_between_cases.md index 5e77b5b..a90a0e5 100644 --- a/docs/description/vertical_whitespace_between_cases.md +++ b/docs/description/vertical_whitespace_between_cases.md @@ -1,6 +1,6 @@ -# Vertical Whitespace Between Cases +# Vertical Whitespace between Cases -Include a single empty line between switch cases. +Include a single empty line between switch cases * **Identifier:** vertical_whitespace_between_cases * **Enabled by default:** No @@ -8,7 +8,22 @@ Include a single empty line between switch cases. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/vertical_whitespace_closing_braces.md b/docs/description/vertical_whitespace_closing_braces.md index 2b8b748..ae2b6c0 100644 --- a/docs/description/vertical_whitespace_closing_braces.md +++ b/docs/description/vertical_whitespace_closing_braces.md @@ -1,6 +1,6 @@ # Vertical Whitespace before Closing Braces -Don't include vertical whitespace (empty line) before closing braces. +Don't include vertical whitespace (empty line) before closing braces * **Identifier:** vertical_whitespace_closing_braces * **Enabled by default:** No @@ -8,7 +8,30 @@ Don't include vertical whitespace (empty line) before closing braces. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning, only_enforce_before_trivial_lines: false +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ only_enforce_before_trivial_lines + + false +
## Non Triggering Examples @@ -20,13 +43,6 @@ Don't include vertical whitespace (empty line) before closing braces. ] ``` -```swift -foo( - x: 5, - y:6 -) -``` - ```swift do { print("x is 5") @@ -34,9 +50,16 @@ do { ``` ```swift -do { - print("x is 5") -} +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum + +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul +}]) ``` ```swift @@ -47,6 +70,13 @@ func foo() { } ``` +```swift +foo( + x: 5, + y:6 +) +``` + ```swift print([ 1 @@ -60,16 +90,9 @@ do { ``` ```swift -print([foo { - var sum = 0 - for i in 1...5 { sum += i } - return sum - -}, foo { - var mul = 1 - for i in 1...5 { mul *= i } - return mul -}]) +do { + print("x is 5") +} ``` ```swift @@ -117,28 +140,26 @@ if bool1 { ] ``` -```swift -foo( - x: 5, - y:6 -↓ -) -``` - ```swift do { print("x is 5") ↓ - + } ``` ```swift -do { - print("x is 5") +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum + +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul ↓ - -} +}]) ``` ```swift @@ -150,6 +171,14 @@ func foo() { } ``` +```swift +foo( + x: 5, + y:6 +↓ +) +``` + ```swift print([ 1 @@ -161,19 +190,13 @@ print([ do { print("x is 5") ↓ + } ``` ```swift -print([foo { - var sum = 0 - for i in 1...5 { sum += i } - return sum - -}, foo { - var mul = 1 - for i in 1...5 { mul *= i } - return mul +do { + print("x is 5") ↓ -}]) +} ``` \ No newline at end of file diff --git a/docs/description/vertical_whitespace_opening_braces.md b/docs/description/vertical_whitespace_opening_braces.md index 35c4e99..f64c110 100644 --- a/docs/description/vertical_whitespace_opening_braces.md +++ b/docs/description/vertical_whitespace_opening_braces.md @@ -1,6 +1,6 @@ # Vertical Whitespace after Opening Braces -Don't include vertical whitespace (empty line) after opening braces. +Don't include vertical whitespace (empty line) after opening braces * **Identifier:** vertical_whitespace_opening_braces * **Enabled by default:** No @@ -8,7 +8,22 @@ Don't include vertical whitespace (empty line) after opening braces. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/void_function_in_ternary.md b/docs/description/void_function_in_ternary.md index 842b14e..5df2320 100644 --- a/docs/description/void_function_in_ternary.md +++ b/docs/description/void_function_in_ternary.md @@ -1,6 +1,6 @@ # Void Function in Ternary -Using ternary to call Void functions should be avoided. +Using ternary to call Void functions should be avoided * **Identifier:** void_function_in_ternary * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Using ternary to call Void functions should be avoided. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.1.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/void_return.md b/docs/description/void_return.md index 6e31883..5a58166 100644 --- a/docs/description/void_return.md +++ b/docs/description/void_return.md @@ -1,6 +1,6 @@ # Void Return -Prefer `-> Void` over `-> ()`. +Prefer `-> Void` over `-> ()` * **Identifier:** void_return * **Enabled by default:** Yes @@ -8,7 +8,22 @@ Prefer `-> Void` over `-> ()`. * **Kind:** style * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples @@ -47,6 +62,31 @@ let foo: (ConfigurationTests) -> () -> Void ``` +```swift +let foo: () -> () async -> Void + +``` + +```swift +let foo: () -> () async throws -> Void + +``` + +```swift +let foo: () -> () async -> Void + +``` + +```swift +func foo() -> () async throws -> Void {} + +``` + +```swift +func foo() async throws -> () async -> Void { return {} } + +``` + ## Triggering Examples ```swift @@ -82,4 +122,14 @@ func foo(completion: () -> ↓(Void)) ```swift let foo: (ConfigurationTests) -> () throws -> ↓() +``` + +```swift +func foo() async -> ↓() + +``` + +```swift +func foo() async throws -> ↓() + ``` \ No newline at end of file diff --git a/docs/description/weak_delegate.md b/docs/description/weak_delegate.md index 47ceee6..6a5dda4 100644 --- a/docs/description/weak_delegate.md +++ b/docs/description/weak_delegate.md @@ -1,6 +1,6 @@ # Weak Delegate -Delegates should be weak to avoid reference cycles. +Delegates should be weak to avoid reference cycles * **Identifier:** weak_delegate * **Enabled by default:** No @@ -8,7 +8,22 @@ Delegates should be weak to avoid reference cycles. * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/xct_specific_matcher.md b/docs/description/xct_specific_matcher.md index 93366ea..30ede9c 100644 --- a/docs/description/xct_specific_matcher.md +++ b/docs/description/xct_specific_matcher.md @@ -1,6 +1,6 @@ # XCTest Specific Matcher -Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual` +Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual`. * **Identifier:** xct_specific_matcher * **Enabled by default:** No @@ -8,10 +8,37 @@ Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual` * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ matchers + + [one-argument-asserts, two-argument-asserts] +
## Non Triggering Examples +```swift +XCTAssert(foo +``` + ```swift XCTAssertFalse(foo) ``` @@ -84,6 +111,10 @@ XCTAssertEqual(false, foo?.bar) XCTAssertEqual(true, foo?.bar) ``` +```swift +XCTAssert( foo ) +``` + ```swift XCTAssertFalse( foo ) ``` @@ -148,6 +179,18 @@ XCTAssertEqual(toto(), foo?.bar) XCTAssertEqual(.toto(.zoo), foo?.bar) ``` +```swift +XCTAssert(foo.self == bar) +``` + +```swift +XCTAssertTrue(type(of: foo) != Int.self) +``` + +```swift +XCTAssertTrue(a == (1, 3, 5) +``` + ## Triggering Examples ```swift @@ -300,4 +343,56 @@ XCTAssertEqual(.toto(.zoo), foo?.bar) ```swift ↓XCTAssertEqual(false, false) +``` + +```swift +↓XCTAssert(foo == bar) +``` + +```swift +↓XCTAssertTrue( foo == bar ) +``` + +```swift +↓XCTAssertFalse(1 == foo) +``` + +```swift +↓XCTAssert(foo == bar, "toto") +``` + +```swift +↓XCTAssert(foo != bar) +``` + +```swift +↓XCTAssertTrue( foo != bar ) +``` + +```swift +↓XCTAssertFalse(1 != foo) +``` + +```swift +↓XCTAssert(foo != bar, "toto") +``` + +```swift +↓XCTAssert( foo == nil) +``` + +```swift +↓XCTAssert(nil == foo +``` + +```swift +↓XCTAssertTrue( foo != nil) +``` + +```swift +↓XCTAssertFalse(nil != foo +``` + +```swift +↓XCTAssert(foo == nil, "toto") ``` \ No newline at end of file diff --git a/docs/description/xctfail_message.md b/docs/description/xctfail_message.md index 7d2453a..7666933 100644 --- a/docs/description/xctfail_message.md +++ b/docs/description/xctfail_message.md @@ -1,6 +1,6 @@ # XCTFail Message -An XCTFail call should include a description of the assertion. +An XCTFail call should include a description of the assertion * **Identifier:** xctfail_message * **Enabled by default:** Yes @@ -8,7 +8,22 @@ An XCTFail call should include a description of the assertion. * **Kind:** idiomatic * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/description/yoda_condition.md b/docs/description/yoda_condition.md index 2fc5ecd..b4860d7 100644 --- a/docs/description/yoda_condition.md +++ b/docs/description/yoda_condition.md @@ -1,6 +1,6 @@ -# Yoda condition rule +# Yoda Condition -The constant literal should be placed on the right-hand side of the comparison operator. +The constant literal should be placed on the right-hand side of the comparison operator * **Identifier:** yoda_condition * **Enabled by default:** No @@ -8,7 +8,22 @@ The constant literal should be placed on the right-hand side of the comparison o * **Kind:** lint * **Analyzer rule:** No * **Minimum Swift compiler version:** 5.0.0 -* **Default configuration:** warning +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
## Non Triggering Examples diff --git a/docs/patterns.json b/docs/patterns.json index f7c2004..6bb64b8 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -1,37 +1,37 @@ { "name" : "swiftlint", - "version" : "0.50.3", + "version" : "0.52.4", "patterns" : [ { "patternId" : "accessibility_label_for_image", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "accessibility_trait_for_button", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "anonymous_argument_in_multiline_closure", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "anyobject_protocol", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "array_init", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -50,30 +50,37 @@ "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "blanket_disable_command", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true }, { "patternId" : "block_based_kvo", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "capture_variable", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "class_delegate_protocol", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "closing_brace", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -87,21 +94,21 @@ "enabled" : false }, { "patternId" : "closure_end_indentation", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "closure_parameter_position", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "closure_spacing", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -122,28 +129,28 @@ "enabled" : true }, { "patternId" : "comma", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "comma_inheritance", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "comment_spacing", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "compiler_protocol_init", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -164,42 +171,42 @@ "enabled" : false }, { "patternId" : "contains_over_filter_count", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "contains_over_filter_is_empty", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "contains_over_first_not_nil", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "contains_over_range_nil_comparison", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "control_statement", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "convenience_type", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -225,16 +232,23 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "direct_return", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "discarded_notification_center_observer", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "discouraged_assert", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -248,7 +262,7 @@ "enabled" : true }, { "patternId" : "discouraged_none_name", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -262,49 +276,56 @@ "enabled" : false }, { "patternId" : "discouraged_optional_boolean", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "discouraged_optional_collection", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "duplicate_conditions", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true }, { "patternId" : "duplicate_enum_cases", - "level" : "Error", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "duplicate_imports", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "duplicated_key_in_dictionary_literal", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "dynamic_inline", - "level" : "Error", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "empty_collection_literal", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], @@ -318,28 +339,28 @@ "enabled" : false }, { "patternId" : "empty_enum_arguments", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "empty_parameters", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "empty_parentheses_with_trailing_closure", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "empty_string", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], @@ -367,35 +388,35 @@ "enabled" : false }, { "patternId" : "explicit_acl", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "explicit_enum_raw_value", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "explicit_init", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "explicit_self", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "explicit_top_level_acl", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -409,21 +430,21 @@ "enabled" : false }, { "patternId" : "extension_access_modifier", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "fallthrough", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "fatal_error_message", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -465,14 +486,14 @@ "enabled" : false }, { "patternId" : "first_where", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "flatmap_over_map_reduce", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], @@ -486,21 +507,21 @@ "enabled" : true }, { "patternId" : "force_cast", - "level" : "Error", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "force_try", - "level" : "Error", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "force_unwrapping", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -514,7 +535,7 @@ "enabled" : true }, { "patternId" : "function_default_parameter_at_end", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -535,14 +556,14 @@ "enabled" : true }, { "patternId" : "ibinspectable_in_extension", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "identical_operands", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -556,7 +577,7 @@ "enabled" : true }, { "patternId" : "implicit_getter", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -591,21 +612,28 @@ "enabled" : false }, { "patternId" : "inert_defer", - "level" : "Warning", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "invalid_swiftlint_command", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "is_disjoint", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "joined_default_parameter", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -619,77 +647,77 @@ "enabled" : true }, { "patternId" : "last_where", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "leading_whitespace", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_cggeometry_functions", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_constant", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_constructor", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_hashing", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_multiple", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "legacy_nsgeometry_functions", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_objc_type", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "legacy_random", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "let_var_whitespace", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -703,28 +731,28 @@ "enabled" : true }, { "patternId" : "literal_expression_end_indentation", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "local_doc_comment", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "lower_acl_than_parent", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "mark", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -752,21 +780,21 @@ "enabled" : false }, { "patternId" : "multiline_arguments_brackets", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "multiline_function_chains", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "multiline_literal_brackets", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -780,14 +808,14 @@ "enabled" : false }, { "patternId" : "multiline_parameters_brackets", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "multiple_closures_with_trailing_closure", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -801,77 +829,77 @@ "enabled" : true }, { "patternId" : "nimble_operator", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "no_extension_access_modifier", - "level" : "Error", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "no_fallthrough_only", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "no_grouping_extension", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "no_magic_numbers", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "no_space_in_method_call", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "notification_center_detachment", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "ns_number_init_as_function_reference", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "nslocalizedstring_key", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "nslocalizedstring_require_bundle", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "nsobject_prefer_isequal", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -906,21 +934,21 @@ "enabled" : false }, { "patternId" : "operator_whitespace", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "optional_enum_case_matching", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "orphaned_doc_comment", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -934,42 +962,49 @@ "enabled" : false }, { "patternId" : "override_in_extension", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "pattern_matching_keywords", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "period_spacing", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "prefer_nimble", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "prefer_self_in_static_references", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "prefer_self_type_over_type_of_self", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "prefer_zero_over_explicit_init", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -983,7 +1018,7 @@ "enabled" : false }, { "patternId" : "private_action", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1004,7 +1039,7 @@ "enabled" : true }, { "patternId" : "private_subject", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1018,7 +1053,7 @@ "enabled" : true }, { "patternId" : "prohibited_interface_builder", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1032,112 +1067,119 @@ "enabled" : false }, { "patternId" : "protocol_property_accessors_order", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "quick_discouraged_call", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "quick_discouraged_focused_test", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "quick_discouraged_pending_test", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "raw_value_for_camel_cased_codable_enum", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "reduce_boolean", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "reduce_into", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "redundant_discardable_let", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "redundant_nil_coalescing", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "redundant_objc_attribute", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "redundant_optional_initialization", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "redundant_self_in_closure", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "redundant_set_access_control", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "redundant_string_enum_value", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "redundant_type_annotation", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "redundant_void_return", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "required_deinit", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1151,14 +1193,14 @@ "enabled" : false }, { "patternId" : "return_arrow_whitespace", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "return_value_from_void_function", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1172,21 +1214,21 @@ "enabled" : false }, { "patternId" : "self_in_property_initialization", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "shorthand_operator", - "level" : "Error", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "shorthand_optional_binding", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1198,16 +1240,23 @@ "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "sorted_enum_cases", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "sorted_first_last", - "level" : "Warning", + "level" : "Info", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "sorted_imports", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -1221,32 +1270,39 @@ "enabled" : true }, { "patternId" : "static_operator", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "strict_fileprivate", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "strong_iboutlet", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "superfluous_disable_command", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "superfluous_else", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "switch_case_alignment", "level" : "Info", @@ -1256,14 +1312,14 @@ "enabled" : true }, { "patternId" : "switch_case_on_newline", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "syntactic_sugar", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1277,14 +1333,14 @@ "enabled" : false }, { "patternId" : "todo", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "toggle_bool", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1305,14 +1361,14 @@ "enabled" : true }, { "patternId" : "trailing_newline", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "trailing_semicolon", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1347,70 +1403,84 @@ "enabled" : true }, { "patternId" : "typesafe_array_init", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "unavailable_condition", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "unavailable_function", - "level" : "Warning", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false + }, { + "patternId" : "unhandled_throwing_task", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "unneeded_break_in_switch", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "unneeded_parentheses_in_closure_argument", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "unneeded_synthesized_initializer", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true }, { "patternId" : "unowned_variable_capture", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "untyped_error_in_catch", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "unused_capture_list", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], - "enabled" : true + "enabled" : false }, { "patternId" : "unused_closure_parameter", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "unused_control_flow_label", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1424,7 +1494,7 @@ "enabled" : false }, { "patternId" : "unused_enumerated", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1445,28 +1515,28 @@ "enabled" : true }, { "patternId" : "unused_setter_value", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "valid_ibinspectable", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "vertical_parameter_alignment", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "vertical_parameter_alignment_on_call", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -1480,7 +1550,7 @@ "enabled" : true }, { "patternId" : "vertical_whitespace_between_cases", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -1494,49 +1564,49 @@ "enabled" : false }, { "patternId" : "vertical_whitespace_opening_braces", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "void_function_in_ternary", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "void_return", - "level" : "Warning", + "level" : "Info", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "weak_delegate", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "xct_specific_matcher", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "xctfail_message", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "yoda_condition", - "level" : "Warning", + "level" : "Info", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], diff --git a/project/build.properties b/project/build.properties index 8b9a0b0..875b706 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.0 +sbt.version=1.9.2 From 285e1ab22dc03374d0e43b65893f5a5ea13a635b Mon Sep 17 00:00:00 2001 From: Stefan Vacareanu Date: Wed, 20 Sep 2023 15:11:07 +0200 Subject: [PATCH 092/119] Fix tests part 1 --- docs/tests/block_based_kvo.swift | 4 +- docs/tests/class_delegate_protocol.swift | 4 +- docs/tests/closing_brace.swift | 4 +- docs/tests/closure_end_indentation.swift | 6 +-- docs/tests/comma.swift | 10 ++--- docs/tests/compiler_protocol_init.swift | 4 +- docs/tests/control_statement.swift | 32 +++++++------- ...scarded_notification_center_observer.swift | 6 +-- docs/tests/dynamic_inline.swift | 10 ++--- docs/tests/empty_parameters.swift | 8 ++-- ...ty_parentheses_with_trailing_closure.swift | 8 ++-- docs/tests/explicit_init.swift | 7 ++- docs/tests/extension_access_modifier.swift | 21 --------- docs/tests/fallthrough.swift | 2 +- docs/tests/fatal_error_message.swift | 4 +- docs/tests/file_header.swift | 17 ------- docs/tests/force_cast.swift | 2 +- docs/tests/force_try.swift | 2 +- docs/tests/implicit_getter.swift | 10 ++--- docs/tests/is_disjoint.swift | 4 +- docs/tests/legacy_constant.swift | 20 ++++----- docs/tests/legacy_constructor.swift | 40 ++++++++--------- docs/tests/legacy_nsgeometry_functions.swift | 42 +++++++++--------- docs/tests/mark.swift | 40 ++++++++--------- ...tiple_closures_with_trailing_closure.swift | 4 +- docs/tests/nimble_operator.swift | 18 ++++---- docs/tests/no_extension_access_modifier.swift | 10 ++--- docs/tests/no_grouping_extension.swift | 8 ++-- .../notification_center_detachment.swift | 2 +- docs/tests/operator_whitespace.swift | 12 ++--- docs/tests/override_in_extension.swift | 4 +- docs/tests/private_action.swift | 22 +++++----- .../protocol_property_accessors_order.swift | 2 +- .../redundant_optional_initialization.swift | 8 ++-- docs/tests/redundant_void_return.swift | 8 ++-- docs/tests/return_arrow_whitespace.swift | 16 +++---- docs/tests/scriptFile.scala | 1 + docs/tests/shorthand_operator.swift | 44 +++++++++---------- docs/tests/sorted_first_last.swift | 26 +++++------ docs/tests/sorted_imports.swift | 2 +- docs/tests/todo.swift | 16 +++---- docs/tests/trailing_semicolon.swift | 10 ++--- ...eded_parentheses_in_closure_argument.swift | 10 ++--- docs/tests/unused_closure_parameter.swift | 16 +++---- docs/tests/unused_enumerated.swift | 8 ++-- docs/tests/valid_ibinspectable.swift | 18 ++++---- docs/tests/vertical_parameter_alignment.swift | 8 ++-- docs/tests/void_return.swift | 14 +++--- docs/tests/xctfail_message.swift | 4 +- docs/tests/yoda_condition.swift | 14 +++--- 50 files changed, 287 insertions(+), 325 deletions(-) delete mode 100644 docs/tests/extension_access_modifier.swift delete mode 100644 docs/tests/file_header.swift create mode 100644 docs/tests/scriptFile.scala diff --git a/docs/tests/block_based_kvo.swift b/docs/tests/block_based_kvo.swift index 3f0a797..364719b 100644 --- a/docs/tests/block_based_kvo.swift +++ b/docs/tests/block_based_kvo.swift @@ -1,7 +1,7 @@ //#Patterns: block_based_kvo -//#Issue: {"severity": "Warning", "line": 9, "patternId": "block_based_kvo"} -//#Issue: {"severity": "Warning", "line": 16, "patternId": "block_based_kvo"} +//#Issue: {"severity": "Info", "line": 9, "patternId": "block_based_kvo"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "block_based_kvo"} diff --git a/docs/tests/class_delegate_protocol.swift b/docs/tests/class_delegate_protocol.swift index 33ac6c4..aa0957c 100644 --- a/docs/tests/class_delegate_protocol.swift +++ b/docs/tests/class_delegate_protocol.swift @@ -1,7 +1,7 @@ //#Patterns: class_delegate_protocol -//#Issue: {"severity": "Warning", "line": 6, "patternId": "class_delegate_protocol"} -//#Issue: {"severity": "Warning", "line": 9, "patternId": "class_delegate_protocol"} +//#Issue: {"severity": "Info", "line": 6, "patternId": "class_delegate_protocol"} +//#Issue: {"severity": "Info", "line": 9, "patternId": "class_delegate_protocol"} protocol FooDelegate {} diff --git a/docs/tests/closing_brace.swift b/docs/tests/closing_brace.swift index 9196728..78c9abe 100644 --- a/docs/tests/closing_brace.swift +++ b/docs/tests/closing_brace.swift @@ -1,7 +1,7 @@ //#Patterns: closing_brace -//#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} +//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} [].map({ } ) diff --git a/docs/tests/closure_end_indentation.swift b/docs/tests/closure_end_indentation.swift index 27dea1b..96401cf 100644 --- a/docs/tests/closure_end_indentation.swift +++ b/docs/tests/closure_end_indentation.swift @@ -1,8 +1,8 @@ //#Patterns: closure_end_indentation -//#Issue: {"severity": "Warning", "line": 10, "patternId": "closure_end_indentation"} -//#Issue: {"severity": "Warning", "line": 15, "patternId": "closure_end_indentation"} -//#Issue: {"severity": "Warning", "line": 17, "patternId": "closure_end_indentation"} +//#Issue: {"severity": "Info", "line": 10, "patternId": "closure_end_indentation"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "closure_end_indentation"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "closure_end_indentation"} SignalProducer(values: [1, 2, 3]) .startWithNext { number in diff --git a/docs/tests/comma.swift b/docs/tests/comma.swift index 018cc6f..8ad431a 100644 --- a/docs/tests/comma.swift +++ b/docs/tests/comma.swift @@ -1,10 +1,10 @@ //#Patterns: comma -//#Issue: {"severity": "Warning", "line": 9, "patternId": "comma"} -//#Issue: {"severity": "Warning", "line": 11, "patternId": "comma"} -//#Issue: {"severity": "Warning", "line": 13, "patternId": "comma"} -//#Issue: {"severity": "Warning", "line": 15, "patternId": "comma"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "comma"} +//#Issue: {"severity": "Info", "line": 9, "patternId": "comma"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "comma"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "comma"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "comma"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "comma"} func abc(a: String ,b: String) { } diff --git a/docs/tests/compiler_protocol_init.swift b/docs/tests/compiler_protocol_init.swift index 532ece5..0acb9a1 100644 --- a/docs/tests/compiler_protocol_init.swift +++ b/docs/tests/compiler_protocol_init.swift @@ -1,7 +1,7 @@ //#Patterns: compiler_protocol_init -//#Issue: {"severity": "Warning", "line": 6, "patternId": "compiler_protocol_init"} -//#Issue: {"severity": "Warning", "line": 9, "patternId": "compiler_protocol_init"} +//#Issue: {"severity": "Info", "line": 6, "patternId": "compiler_protocol_init"} +//#Issue: {"severity": "Info", "line": 9, "patternId": "compiler_protocol_init"} let set = Set(arrayLiteral: 1, 2) diff --git a/docs/tests/control_statement.swift b/docs/tests/control_statement.swift index fe8680e..7e04643 100644 --- a/docs/tests/control_statement.swift +++ b/docs/tests/control_statement.swift @@ -1,21 +1,21 @@ //#Patterns: control_statement -//#Issue: {"severity": "Warning", "line": 20, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 23, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 32, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 35, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 38, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 41, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 44, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 47, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 50, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 53, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 56, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 59, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 62, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 65, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 32, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 35, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 38, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 41, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 44, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 47, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 50, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 53, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 56, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 59, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 62, "patternId": "control_statement"} +//#Issue: {"severity": "Info", "line": 65, "patternId": "control_statement"} if (condition) { diff --git a/docs/tests/discarded_notification_center_observer.swift b/docs/tests/discarded_notification_center_observer.swift index 7a963dc..7c390b1 100644 --- a/docs/tests/discarded_notification_center_observer.swift +++ b/docs/tests/discarded_notification_center_observer.swift @@ -1,8 +1,8 @@ //#Patterns: discarded_notification_center_observer -//#Issue: {"severity": "Warning", "line": 7, "patternId": "discarded_notification_center_observer"} -//#Issue: {"severity": "Warning", "line": 10, "patternId": "discarded_notification_center_observer"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "discarded_notification_center_observer"} +//#Issue: {"severity": "Info", "line": 7, "patternId": "discarded_notification_center_observer"} +//#Issue: {"severity": "Info", "line": 10, "patternId": "discarded_notification_center_observer"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "discarded_notification_center_observer"} nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { } diff --git a/docs/tests/dynamic_inline.swift b/docs/tests/dynamic_inline.swift index 7a0c61f..a173305 100644 --- a/docs/tests/dynamic_inline.swift +++ b/docs/tests/dynamic_inline.swift @@ -1,10 +1,10 @@ //#Patterns: dynamic_inline -//#Issue: {"severity": "Error", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Error", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Error", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Error", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Error", "line": 29, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} class C { @inline(__always) dynamic func f() {} diff --git a/docs/tests/empty_parameters.swift b/docs/tests/empty_parameters.swift index 1827bdc..b51bec5 100644 --- a/docs/tests/empty_parameters.swift +++ b/docs/tests/empty_parameters.swift @@ -1,9 +1,9 @@ //#Patterns: empty_parameters -//#Issue: {"severity": "Warning", "line": 8, "patternId": "empty_parameters"} -//#Issue: {"severity": "Warning", "line": 11, "patternId": "empty_parameters"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "empty_parameters"} -//#Issue: {"severity": "Warning", "line": 17, "patternId": "empty_parameters"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "empty_parameters"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "empty_parameters"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "empty_parameters"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "empty_parameters"} let abc: (Void) -> Void = {} diff --git a/docs/tests/empty_parentheses_with_trailing_closure.swift b/docs/tests/empty_parentheses_with_trailing_closure.swift index c2550f9..2b3c2c6 100644 --- a/docs/tests/empty_parentheses_with_trailing_closure.swift +++ b/docs/tests/empty_parentheses_with_trailing_closure.swift @@ -1,9 +1,9 @@ //#Patterns: empty_parentheses_with_trailing_closure -//#Issue: {"severity": "Warning", "line": 8, "patternId": "empty_parentheses_with_trailing_closure"} -//#Issue: {"severity": "Warning", "line": 11, "patternId": "empty_parentheses_with_trailing_closure"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "empty_parentheses_with_trailing_closure"} -//#Issue: {"severity": "Warning", "line": 19, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Info", "line": 19, "patternId": "empty_parentheses_with_trailing_closure"} [1, 2].map() { $0 + 1 } diff --git a/docs/tests/explicit_init.swift b/docs/tests/explicit_init.swift index 4774993..c54c71e 100644 --- a/docs/tests/explicit_init.swift +++ b/docs/tests/explicit_init.swift @@ -1,8 +1,7 @@ //#Patterns: explicit_init //#Issue: {"severity": "Warning", "line": 6, "patternId": "explicit_init"} -//#Issue: {"severity": "Warning", "line": 8, "patternId": "explicit_init"} - [1].flatMap{String.init($0)} - - [String.self].map { Type in Type.init(1) } +func foo() -> [String] { + return [1].flatMap { String↓.init($0) } +} diff --git a/docs/tests/extension_access_modifier.swift b/docs/tests/extension_access_modifier.swift deleted file mode 100644 index 2964c9f..0000000 --- a/docs/tests/extension_access_modifier.swift +++ /dev/null @@ -1,21 +0,0 @@ -//#Patterns: extension_access_modifier - -//#Issue: {"severity": "Warning", "line": 8, "patternId": "extension_access_modifier"} -//#Issue: {"severity": "Warning", "line": 13, "patternId": "extension_access_modifier"} -//#Issue: {"severity": "Warning", "line": 19, "patternId": "extension_access_modifier"} -//#Issue: {"severity": "Warning", "line": 20, "patternId": "extension_access_modifier"} - - extension Foo { - public var bar: Int { return 1 } - public var baz: Int { return 1 } - } - - extension Foo { - public var bar: Int { return 1 } - public func baz() {} - } - - public extension Foo { - public func bar() {} - public func baz() {} - } diff --git a/docs/tests/fallthrough.swift b/docs/tests/fallthrough.swift index 301fe9c..22d38c4 100644 --- a/docs/tests/fallthrough.swift +++ b/docs/tests/fallthrough.swift @@ -1,6 +1,6 @@ //#Patterns: fallthrough -//#Issue: {"severity": "Warning", "line": 9, "patternId": "fallthrough"} +//#Issue: {"severity": "Info", "line": 9, "patternId": "fallthrough"} diff --git a/docs/tests/fatal_error_message.swift b/docs/tests/fatal_error_message.swift index 1a678e9..3820dec 100644 --- a/docs/tests/fatal_error_message.swift +++ b/docs/tests/fatal_error_message.swift @@ -1,7 +1,7 @@ //#Patterns: fatal_error_message -//#Issue: {"severity": "Warning", "line": 7, "patternId": "fatal_error_message"} -//#Issue: {"severity": "Warning", "line": 12, "patternId": "fatal_error_message"} +//#Issue: {"severity": "Info", "line": 7, "patternId": "fatal_error_message"} +//#Issue: {"severity": "Info", "line": 12, "patternId": "fatal_error_message"} func foo() { fatalError("") diff --git a/docs/tests/file_header.swift b/docs/tests/file_header.swift deleted file mode 100644 index 8dac875..0000000 --- a/docs/tests/file_header.swift +++ /dev/null @@ -1,17 +0,0 @@ -//#Patterns: file_header - -//#Issue: {"severity": "Info", "line": 5, "patternId": "file_header"} - - // Copyright - - - // - // Copyright - - // - // FileHeaderRule.swift - // SwiftLint - // - // Created by Marcelo Fabri on 27/11/16. - // Copyright © 2016 Realm. All rights reserved. - // diff --git a/docs/tests/force_cast.swift b/docs/tests/force_cast.swift index c304f04..c31ff9a 100644 --- a/docs/tests/force_cast.swift +++ b/docs/tests/force_cast.swift @@ -1,5 +1,5 @@ //#Patterns: force_cast -//#Issue: {"severity": "Error", "line": 5, "patternId": "force_cast"} +//#Issue: {"severity": "Info", "line": 5, "patternId": "force_cast"} NSNumber() as! Int diff --git a/docs/tests/force_try.swift b/docs/tests/force_try.swift index 7da7517..48f1357 100644 --- a/docs/tests/force_try.swift +++ b/docs/tests/force_try.swift @@ -1,5 +1,5 @@ //#Patterns: force_try -//#Issue: {"severity": "Error", "line": 5, "patternId": "force_try"} +//#Issue: {"severity": "Info", "line": 5, "patternId": "force_try"} func a() throws {}; try! a() diff --git a/docs/tests/implicit_getter.swift b/docs/tests/implicit_getter.swift index 4a1354c..00e8c0c 100644 --- a/docs/tests/implicit_getter.swift +++ b/docs/tests/implicit_getter.swift @@ -1,10 +1,10 @@ //#Patterns: implicit_getter -//#Issue: {"severity": "Warning", "line": 11, "patternId": "implicit_getter"} -//#Issue: {"severity": "Warning", "line": 21, "patternId": "implicit_getter"} -//#Issue: {"severity": "Warning", "line": 31, "patternId": "implicit_getter"} -//#Issue: {"severity": "Warning", "line": 40, "patternId": "implicit_getter"} -//#Issue: {"severity": "Warning", "line": 49, "patternId": "implicit_getter"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "implicit_getter"} +//#Issue: {"severity": "Info", "line": 21, "patternId": "implicit_getter"} +//#Issue: {"severity": "Info", "line": 31, "patternId": "implicit_getter"} +//#Issue: {"severity": "Info", "line": 40, "patternId": "implicit_getter"} +//#Issue: {"severity": "Info", "line": 49, "patternId": "implicit_getter"} class Foo { var foo: Int { diff --git a/docs/tests/is_disjoint.swift b/docs/tests/is_disjoint.swift index 7c7a22b..12befab 100644 --- a/docs/tests/is_disjoint.swift +++ b/docs/tests/is_disjoint.swift @@ -1,7 +1,7 @@ //#Patterns: is_disjoint -//#Issue: {"severity": "Warning", "line": 8, "patternId": "is_disjoint"} -//#Issue: {"severity": "Warning", "line": 11, "patternId": "is_disjoint"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "is_disjoint"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "is_disjoint"} diff --git a/docs/tests/legacy_constant.swift b/docs/tests/legacy_constant.swift index cd0727e..ce1de6e 100644 --- a/docs/tests/legacy_constant.swift +++ b/docs/tests/legacy_constant.swift @@ -1,15 +1,15 @@ //#Patterns: legacy_constant -//#Issue: {"severity": "Warning", "line": 14, "patternId": "legacy_constant"} -//#Issue: {"severity": "Warning", "line": 16, "patternId": "legacy_constant"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "legacy_constant"} -//#Issue: {"severity": "Warning", "line": 20, "patternId": "legacy_constant"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "legacy_constant"} -//#Issue: {"severity": "Warning", "line": 24, "patternId": "legacy_constant"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "legacy_constant"} -//#Issue: {"severity": "Warning", "line": 28, "patternId": "legacy_constant"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "legacy_constant"} -//#Issue: {"severity": "Warning", "line": 32, "patternId": "legacy_constant"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "legacy_constant"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "legacy_constant"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "legacy_constant"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "legacy_constant"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "legacy_constant"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "legacy_constant"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "legacy_constant"} +//#Issue: {"severity": "Info", "line": 28, "patternId": "legacy_constant"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "legacy_constant"} +//#Issue: {"severity": "Info", "line": 32, "patternId": "legacy_constant"} CGRectInfinite diff --git a/docs/tests/legacy_constructor.swift b/docs/tests/legacy_constructor.swift index 3ce126c..ed5af78 100644 --- a/docs/tests/legacy_constructor.swift +++ b/docs/tests/legacy_constructor.swift @@ -1,25 +1,25 @@ //#Patterns: legacy_constructor -//#Issue: {"severity": "Warning", "line": 24, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 28, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 32, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 34, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 36, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 38, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 40, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 42, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 44, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 46, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 48, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 50, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 52, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 54, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 56, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 58, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 60, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Warning", "line": 62, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 28, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 32, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 34, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 36, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 38, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 40, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 42, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 44, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 46, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 48, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 50, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 52, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 54, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 56, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 58, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 60, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Info", "line": 62, "patternId": "legacy_constructor"} CGPointMake(10, 10) diff --git a/docs/tests/legacy_nsgeometry_functions.swift b/docs/tests/legacy_nsgeometry_functions.swift index 83d57e1..0e72904 100644 --- a/docs/tests/legacy_nsgeometry_functions.swift +++ b/docs/tests/legacy_nsgeometry_functions.swift @@ -1,26 +1,26 @@ //#Patterns: legacy_nsgeometry_functions -//#Issue: {"severity": "Warning", "line": 25, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 27, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 31, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 33, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 35, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 37, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 39, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 41, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 43, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 45, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 47, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 49, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 51, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 53, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 55, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 57, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 59, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 61, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 63, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Warning", "line": 65, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 31, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 33, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 35, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 37, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 39, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 41, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 43, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 45, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 47, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 49, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 51, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 53, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 55, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 57, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 59, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 61, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 63, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Info", "line": 65, "patternId": "legacy_nsgeometry_functions"} NSWidth(rect) diff --git a/docs/tests/mark.swift b/docs/tests/mark.swift index 146ba6b..1301746 100644 --- a/docs/tests/mark.swift +++ b/docs/tests/mark.swift @@ -1,25 +1,25 @@ //#Patterns: mark -//#Issue: {"severity": "Warning", "line": 24, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 28, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 32, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 34, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 36, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 38, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 40, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 42, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 44, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 46, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 48, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 50, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 52, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 54, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 56, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 58, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 59, "patternId": "mark"} -//#Issue: {"severity": "Warning", "line": 61, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 28, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 32, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 34, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 36, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 38, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 40, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 42, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 44, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 46, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 48, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 50, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 52, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 54, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 56, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 58, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 59, "patternId": "mark"} +//#Issue: {"severity": "Info", "line": 61, "patternId": "mark"} //MARK: bad diff --git a/docs/tests/multiple_closures_with_trailing_closure.swift b/docs/tests/multiple_closures_with_trailing_closure.swift index 563a950..679d852 100644 --- a/docs/tests/multiple_closures_with_trailing_closure.swift +++ b/docs/tests/multiple_closures_with_trailing_closure.swift @@ -1,7 +1,7 @@ //#Patterns: multiple_closures_with_trailing_closure -//#Issue: {"severity": "Warning", "line": 8, "patternId": "multiple_closures_with_trailing_closure"} -//#Issue: {"severity": "Warning", "line": 13, "patternId": "multiple_closures_with_trailing_closure"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "multiple_closures_with_trailing_closure"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "multiple_closures_with_trailing_closure"} diff --git a/docs/tests/nimble_operator.swift b/docs/tests/nimble_operator.swift index cd51956..5261baf 100644 --- a/docs/tests/nimble_operator.swift +++ b/docs/tests/nimble_operator.swift @@ -1,14 +1,14 @@ //#Patterns: nimble_operator -//#Issue: {"severity": "Warning", "line": 13, "patternId": "nimble_operator"} -//#Issue: {"severity": "Warning", "line": 16, "patternId": "nimble_operator"} -//#Issue: {"severity": "Warning", "line": 19, "patternId": "nimble_operator"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "nimble_operator"} -//#Issue: {"severity": "Warning", "line": 25, "patternId": "nimble_operator"} -//#Issue: {"severity": "Warning", "line": 28, "patternId": "nimble_operator"} -//#Issue: {"severity": "Warning", "line": 31, "patternId": "nimble_operator"} -//#Issue: {"severity": "Warning", "line": 34, "patternId": "nimble_operator"} -//#Issue: {"severity": "Warning", "line": 38, "patternId": "nimble_operator"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "nimble_operator"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "nimble_operator"} +//#Issue: {"severity": "Info", "line": 19, "patternId": "nimble_operator"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "nimble_operator"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "nimble_operator"} +//#Issue: {"severity": "Info", "line": 28, "patternId": "nimble_operator"} +//#Issue: {"severity": "Info", "line": 31, "patternId": "nimble_operator"} +//#Issue: {"severity": "Info", "line": 34, "patternId": "nimble_operator"} +//#Issue: {"severity": "Info", "line": 38, "patternId": "nimble_operator"} expect(seagull.squawk).toNot(equal("Hi")) diff --git a/docs/tests/no_extension_access_modifier.swift b/docs/tests/no_extension_access_modifier.swift index dd17e4c..b601dff 100644 --- a/docs/tests/no_extension_access_modifier.swift +++ b/docs/tests/no_extension_access_modifier.swift @@ -1,10 +1,10 @@ //#Patterns: no_extension_access_modifier -//#Issue: {"severity": "Error", "line": 9, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Error", "line": 11, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Error", "line": 14, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Error", "line": 16, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Error", "line": 18, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Info", "line": 9, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "no_extension_access_modifier"} private extension String {} diff --git a/docs/tests/no_grouping_extension.swift b/docs/tests/no_grouping_extension.swift index ec71e66..cb5845d 100644 --- a/docs/tests/no_grouping_extension.swift +++ b/docs/tests/no_grouping_extension.swift @@ -1,9 +1,9 @@ //#Patterns: no_grouping_extension -//#Issue: {"severity": "Warning", "line": 11, "patternId": "no_grouping_extension"} -//#Issue: {"severity": "Warning", "line": 15, "patternId": "no_grouping_extension"} -//#Issue: {"severity": "Warning", "line": 21, "patternId": "no_grouping_extension"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Info", "line": 21, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "no_grouping_extension"} diff --git a/docs/tests/notification_center_detachment.swift b/docs/tests/notification_center_detachment.swift index a0964c8..14a4779 100644 --- a/docs/tests/notification_center_detachment.swift +++ b/docs/tests/notification_center_detachment.swift @@ -1,6 +1,6 @@ //#Patterns: notification_center_detachment -//#Issue: {"severity": "Warning", "line": 7, "patternId": "notification_center_detachment"} +//#Issue: {"severity": "Info", "line": 7, "patternId": "notification_center_detachment"} class Foo { func bar() { diff --git a/docs/tests/operator_whitespace.swift b/docs/tests/operator_whitespace.swift index f9fefa1..b3aacdb 100644 --- a/docs/tests/operator_whitespace.swift +++ b/docs/tests/operator_whitespace.swift @@ -1,11 +1,11 @@ //#Patterns: operator_whitespace -//#Issue: {"severity": "Warning", "line": 10, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Warning", "line": 13, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Warning", "line": 16, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Warning", "line": 19, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Warning", "line": 25, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Info", "line": 10, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Info", "line": 19, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "operator_whitespace"} func <|(lhs: Int, rhs: Int) -> Int {} diff --git a/docs/tests/override_in_extension.swift b/docs/tests/override_in_extension.swift index 23c84aa..c28a1c3 100644 --- a/docs/tests/override_in_extension.swift +++ b/docs/tests/override_in_extension.swift @@ -1,7 +1,7 @@ //#Patterns: override_in_extension -//#Issue: {"severity": "Warning", "line": 9, "patternId": "override_in_extension"} -//#Issue: {"severity": "Warning", "line": 15, "patternId": "override_in_extension"} +//#Issue: {"severity": "Info", "line": 9, "patternId": "override_in_extension"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "override_in_extension"} diff --git a/docs/tests/private_action.swift b/docs/tests/private_action.swift index a8caaaa..4e3c771 100644 --- a/docs/tests/private_action.swift +++ b/docs/tests/private_action.swift @@ -1,16 +1,16 @@ //#Patterns: private_action -//#Issue: {"severity": "Warning", "line": 17, "patternId": "private_action"} -//#Issue: {"severity": "Warning", "line": 23, "patternId": "private_action"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "private_action"} -//#Issue: {"severity": "Warning", "line": 35, "patternId": "private_action"} -//#Issue: {"severity": "Warning", "line": 41, "patternId": "private_action"} -//#Issue: {"severity": "Warning", "line": 47, "patternId": "private_action"} -//#Issue: {"severity": "Warning", "line": 53, "patternId": "private_action"} -//#Issue: {"severity": "Warning", "line": 59, "patternId": "private_action"} -//#Issue: {"severity": "Warning", "line": 65, "patternId": "private_action"} -//#Issue: {"severity": "Warning", "line": 71, "patternId": "private_action"} -//#Issue: {"severity": "Warning", "line": 77, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 35, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 41, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 47, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 53, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 59, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 65, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 71, "patternId": "private_action"} +//#Issue: {"severity": "Info", "line": 77, "patternId": "private_action"} class Foo { diff --git a/docs/tests/protocol_property_accessors_order.swift b/docs/tests/protocol_property_accessors_order.swift index 1dec6da..6836af9 100644 --- a/docs/tests/protocol_property_accessors_order.swift +++ b/docs/tests/protocol_property_accessors_order.swift @@ -1,6 +1,6 @@ //#Patterns: protocol_property_accessors_order -//#Issue: {"severity": "Warning", "line": 6, "patternId": "protocol_property_accessors_order"} +//#Issue: {"severity": "Info", "line": 6, "patternId": "protocol_property_accessors_order"} protocol Foo { var bar: String { set get } diff --git a/docs/tests/redundant_optional_initialization.swift b/docs/tests/redundant_optional_initialization.swift index 69c122f..8477089 100644 --- a/docs/tests/redundant_optional_initialization.swift +++ b/docs/tests/redundant_optional_initialization.swift @@ -1,9 +1,9 @@ //#Patterns: redundant_optional_initialization -//#Issue: {"severity": "Warning", "line": 8, "patternId": "redundant_optional_initialization"} -//#Issue: {"severity": "Warning", "line": 11, "patternId": "redundant_optional_initialization"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "redundant_optional_initialization"} -//#Issue: {"severity": "Warning", "line": 17, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "redundant_optional_initialization"} var myVar: Int? = nil diff --git a/docs/tests/redundant_void_return.swift b/docs/tests/redundant_void_return.swift index f5e239f..ead3abd 100644 --- a/docs/tests/redundant_void_return.swift +++ b/docs/tests/redundant_void_return.swift @@ -1,9 +1,9 @@ //#Patterns: redundant_void_return -//#Issue: {"severity": "Warning", "line": 8, "patternId": "redundant_void_return"} -//#Issue: {"severity": "Warning", "line": 12, "patternId": "redundant_void_return"} -//#Issue: {"severity": "Warning", "line": 16, "patternId": "redundant_void_return"} -//#Issue: {"severity": "Warning", "line": 20, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Info", "line": 12, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "redundant_void_return"} func foo() -> Void {} diff --git a/docs/tests/return_arrow_whitespace.swift b/docs/tests/return_arrow_whitespace.swift index 2c4b840..c62b57f 100644 --- a/docs/tests/return_arrow_whitespace.swift +++ b/docs/tests/return_arrow_whitespace.swift @@ -1,13 +1,13 @@ //#Patterns: return_arrow_whitespace -//#Issue: {"severity": "Warning", "line": 12, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Warning", "line": 15, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Warning", "line": 21, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Warning", "line": 24, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Warning", "line": 27, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Warning", "line": 33, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Info", "line": 12, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Info", "line": 21, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Info", "line": 33, "patternId": "return_arrow_whitespace"} func abc()->Int {} diff --git a/docs/tests/scriptFile.scala b/docs/tests/scriptFile.scala new file mode 100644 index 0000000..6ce71f7 --- /dev/null +++ b/docs/tests/scriptFile.scala @@ -0,0 +1 @@ +closure_end_indentation \ No newline at end of file diff --git a/docs/tests/shorthand_operator.swift b/docs/tests/shorthand_operator.swift index 87e1d73..cd3d248 100644 --- a/docs/tests/shorthand_operator.swift +++ b/docs/tests/shorthand_operator.swift @@ -1,27 +1,27 @@ //#Patterns: shorthand_operator -//#Issue: {"severity": "Error", "line": 26, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 29, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 32, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 35, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 38, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 41, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 44, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 47, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 50, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 53, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 56, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 59, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 62, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 65, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 68, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 71, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 74, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 77, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 80, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 83, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 86, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Error", "line": 88, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 32, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 35, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 38, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 41, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 44, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 47, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 50, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 53, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 56, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 59, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 62, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 65, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 68, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 71, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 74, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 77, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 80, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 83, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 86, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Info", "line": 88, "patternId": "shorthand_operator"} foo = foo - 1 diff --git a/docs/tests/sorted_first_last.swift b/docs/tests/sorted_first_last.swift index 47dddad..fc2178c 100644 --- a/docs/tests/sorted_first_last.swift +++ b/docs/tests/sorted_first_last.swift @@ -1,18 +1,18 @@ //#Patterns: sorted_first_last -//#Issue: {"severity": "Warning", "line": 18, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 34, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 38, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 42, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 46, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 50, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 54, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 58, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 62, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Warning", "line": 66, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 34, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 38, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 42, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 46, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 50, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 54, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 58, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 62, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Info", "line": 66, "patternId": "sorted_first_last"} myList.sorted().first diff --git a/docs/tests/sorted_imports.swift b/docs/tests/sorted_imports.swift index b57199a..fc3e85e 100644 --- a/docs/tests/sorted_imports.swift +++ b/docs/tests/sorted_imports.swift @@ -1,6 +1,6 @@ //#Patterns: sorted_imports -//#Issue: {"severity": "Warning", "line": 7, "patternId": "sorted_imports"} +//#Issue: {"severity": "Info", "line": 7, "patternId": "sorted_imports"} import AAA import ZZZ diff --git a/docs/tests/todo.swift b/docs/tests/todo.swift index 380b461..7463db7 100644 --- a/docs/tests/todo.swift +++ b/docs/tests/todo.swift @@ -1,13 +1,13 @@ //#Patterns: todo -//#Issue: {"severity": "Warning", "line": 12, "patternId": "todo"} -//#Issue: {"severity": "Warning", "line": 15, "patternId": "todo"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "todo"} -//#Issue: {"severity": "Warning", "line": 21, "patternId": "todo"} -//#Issue: {"severity": "Warning", "line": 24, "patternId": "todo"} -//#Issue: {"severity": "Warning", "line": 27, "patternId": "todo"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "todo"} -//#Issue: {"severity": "Warning", "line": 33, "patternId": "todo"} +//#Issue: {"severity": "Info", "line": 12, "patternId": "todo"} +//#Issue: {"severity": "Info", "line": 15, "patternId": "todo"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "todo"} +//#Issue: {"severity": "Info", "line": 21, "patternId": "todo"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "todo"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "todo"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "todo"} +//#Issue: {"severity": "Info", "line": 33, "patternId": "todo"} // TODO: diff --git a/docs/tests/trailing_semicolon.swift b/docs/tests/trailing_semicolon.swift index 0d562f9..d08f4b2 100644 --- a/docs/tests/trailing_semicolon.swift +++ b/docs/tests/trailing_semicolon.swift @@ -1,10 +1,10 @@ //#Patterns: trailing_semicolon -//#Issue: {"severity": "Warning", "line": 9, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Warning", "line": 12, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Warning", "line": 16, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Warning", "line": 19, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Info", "line": 9, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Info", "line": 12, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Info", "line": 19, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "trailing_semicolon"} let a = 0; diff --git a/docs/tests/unneeded_parentheses_in_closure_argument.swift b/docs/tests/unneeded_parentheses_in_closure_argument.swift index 6fbc13b..7167226 100644 --- a/docs/tests/unneeded_parentheses_in_closure_argument.swift +++ b/docs/tests/unneeded_parentheses_in_closure_argument.swift @@ -1,10 +1,10 @@ //#Patterns: unneeded_parentheses_in_closure_argument -//#Issue: {"severity": "Warning", "line": 10, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Warning", "line": 25, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Info", "line": 10, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Info", "line": 25, "patternId": "unneeded_parentheses_in_closure_argument"} call(arg: { (bar) in }) diff --git a/docs/tests/unused_closure_parameter.swift b/docs/tests/unused_closure_parameter.swift index c0e0f5f..46c93c0 100644 --- a/docs/tests/unused_closure_parameter.swift +++ b/docs/tests/unused_closure_parameter.swift @@ -1,13 +1,13 @@ //#Patterns: unused_closure_parameter -//#Issue: {"severity": "Warning", "line": 12, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Warning", "line": 17, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Warning", "line": 27, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Warning", "line": 32, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Warning", "line": 37, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Warning", "line": 41, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Warning", "line": 45, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Info", "line": 12, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Info", "line": 22, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Info", "line": 32, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Info", "line": 37, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Info", "line": 41, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Info", "line": 45, "patternId": "unused_closure_parameter"} [1, 2].map { number in return 3 diff --git a/docs/tests/unused_enumerated.swift b/docs/tests/unused_enumerated.swift index fefbb13..53932a9 100644 --- a/docs/tests/unused_enumerated.swift +++ b/docs/tests/unused_enumerated.swift @@ -1,9 +1,9 @@ //#Patterns: unused_enumerated -//#Issue: {"severity": "Warning", "line": 8, "patternId": "unused_enumerated"} -//#Issue: {"severity": "Warning", "line": 11, "patternId": "unused_enumerated"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "unused_enumerated"} -//#Issue: {"severity": "Warning", "line": 17, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "unused_enumerated"} for (_, foo) in bar.enumerated() { } diff --git a/docs/tests/valid_ibinspectable.swift b/docs/tests/valid_ibinspectable.swift index e7cc66b..98448c5 100644 --- a/docs/tests/valid_ibinspectable.swift +++ b/docs/tests/valid_ibinspectable.swift @@ -1,14 +1,14 @@ //#Patterns: valid_ibinspectable -//#Issue: {"severity": "Warning", "line": 14, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Warning", "line": 19, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Warning", "line": 24, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Warning", "line": 34, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Warning", "line": 39, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Warning", "line": 44, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Warning", "line": 49, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Warning", "line": 54, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Info", "line": 19, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Info", "line": 34, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Info", "line": 39, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Info", "line": 44, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Info", "line": 49, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Info", "line": 54, "patternId": "valid_ibinspectable"} class Foo { @IBInspectable private let count: Int diff --git a/docs/tests/vertical_parameter_alignment.swift b/docs/tests/vertical_parameter_alignment.swift index eca126f..cabd4f8 100644 --- a/docs/tests/vertical_parameter_alignment.swift +++ b/docs/tests/vertical_parameter_alignment.swift @@ -1,9 +1,9 @@ //#Patterns: vertical_parameter_alignment -//#Issue: {"severity": "Warning", "line": 9, "patternId": "vertical_parameter_alignment"} -//#Issue: {"severity": "Warning", "line": 13, "patternId": "vertical_parameter_alignment"} -//#Issue: {"severity": "Warning", "line": 17, "patternId": "vertical_parameter_alignment"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Info", "line": 9, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Info", "line": 18, "patternId": "vertical_parameter_alignment"} func validateFunction(_ file: File, kind: SwiftDeclarationKind, dictionary: [String: SourceKitRepresentable]) { } diff --git a/docs/tests/void_return.swift b/docs/tests/void_return.swift index e0a4ac7..586b837 100644 --- a/docs/tests/void_return.swift +++ b/docs/tests/void_return.swift @@ -1,12 +1,12 @@ //#Patterns: void_return -//#Issue: {"severity": "Warning", "line": 11, "patternId": "void_return"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "void_return"} -//#Issue: {"severity": "Warning", "line": 17, "patternId": "void_return"} -//#Issue: {"severity": "Warning", "line": 20, "patternId": "void_return"} -//#Issue: {"severity": "Warning", "line": 23, "patternId": "void_return"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "void_return"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "void_return"} +//#Issue: {"severity": "Info", "line": 11, "patternId": "void_return"} +//#Issue: {"severity": "Info", "line": 14, "patternId": "void_return"} +//#Issue: {"severity": "Info", "line": 17, "patternId": "void_return"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "void_return"} +//#Issue: {"severity": "Info", "line": 23, "patternId": "void_return"} +//#Issue: {"severity": "Info", "line": 26, "patternId": "void_return"} +//#Issue: {"severity": "Info", "line": 29, "patternId": "void_return"} let abc: () -> () = {} diff --git a/docs/tests/xctfail_message.swift b/docs/tests/xctfail_message.swift index 7ab9607..61ae9a0 100644 --- a/docs/tests/xctfail_message.swift +++ b/docs/tests/xctfail_message.swift @@ -1,7 +1,7 @@ //#Patterns: xctfail_message -//#Issue: {"severity": "Warning", "line": 8, "patternId": "xctfail_message"} -//#Issue: {"severity": "Warning", "line": 13, "patternId": "xctfail_message"} +//#Issue: {"severity": "Info", "line": 8, "patternId": "xctfail_message"} +//#Issue: {"severity": "Info", "line": 13, "patternId": "xctfail_message"} func testFoo() { diff --git a/docs/tests/yoda_condition.swift b/docs/tests/yoda_condition.swift index 55c302b..09c4bee 100644 --- a/docs/tests/yoda_condition.swift +++ b/docs/tests/yoda_condition.swift @@ -1,12 +1,12 @@ //#Patterns: yoda_condition -//#Issue: {"severity": "Warning", "line": 12, "patternId": "yoda_condition"} -//#Issue: {"severity": "Warning", "line": 16, "patternId": "yoda_condition"} -//#Issue: {"severity": "Warning", "line": 20, "patternId": "yoda_condition"} -//#Issue: {"severity": "Warning", "line": 24, "patternId": "yoda_condition"} -//#Issue: {"severity": "Warning", "line": 27, "patternId": "yoda_condition"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "yoda_condition"} -//#Issue: {"severity": "Warning", "line": 33, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 12, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 16, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 20, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 24, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 27, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 30, "patternId": "yoda_condition"} +//#Issue: {"severity": "Info", "line": 33, "patternId": "yoda_condition"} if 42 == foo {} From fe835b033fec587d0eebefe8b823a0e47aa32d8a Mon Sep 17 00:00:00 2001 From: Stefan Vacareanu Date: Tue, 10 Oct 2023 16:53:47 +0300 Subject: [PATCH 093/119] Bump to v0.53.0 --- Dockerfile | 2 +- Dockerfile.dev | 2 +- .../accessibility_label_for_image.md | 16 +- docs/description/anyobject_protocol.md | 7 - docs/description/array_init.md | 15 -- docs/description/attributes.md | 5 +- docs/description/class_delegate_protocol.md | 15 -- .../description/closure_parameter_position.md | 8 - docs/description/collection_alignment.md | 5 + docs/description/colon.md | 76 ------ docs/description/comma.md | 3 - docs/description/compiler_protocol_init.md | 6 - .../description/contains_over_filter_count.md | 21 -- .../contains_over_filter_is_empty.md | 13 - .../contains_over_first_not_nil.md | 28 --- docs/description/control_statement.md | 129 +++------- docs/description/description.json | 19 +- .../discarded_notification_center_observer.md | 10 +- docs/description/empty_count.md | 19 -- docs/description/empty_parameters.md | 10 - ...empty_parentheses_with_trailing_closure.md | 9 - docs/description/expiring_todo.md | 14 -- docs/description/explicit_acl.md | 10 - docs/description/explicit_init.md | 8 + docs/description/explicit_top_level_acl.md | 13 +- docs/description/file_header.md | 1 - docs/description/first_where.md | 11 - docs/description/force_cast.md | 2 - docs/description/generic_type_name.md | 36 --- docs/description/implicit_return.md | 106 ++++++-- docs/description/invalid_swiftlint_command.md | 38 +-- docs/description/large_tuple.md | 49 ---- docs/description/last_where.md | 11 - docs/description/leading_whitespace.md | 3 - docs/description/legacy_constructor.md | 1 - docs/description/legacy_objc_type.md | 1 - docs/description/legacy_random.md | 6 - docs/description/let_var_whitespace.md | 19 -- docs/description/line_length.md | 6 - docs/description/mark.md | 3 - docs/description/missing_docs.md | 3 - docs/description/multiline_arguments.md | 2 +- ...multiple_closures_with_trailing_closure.md | 4 - docs/description/nimble_operator.md | 22 -- docs/description/no_grouping_extension.md | 7 - docs/description/no_magic_numbers.md | 41 ++++ .../non_overridable_class_declaration.md | 106 ++++++++ .../ns_number_init_as_function_reference.md | 4 + docs/description/number_separator.md | 8 + docs/description/opening_brace.md | 6 - docs/description/operator_usage_whitespace.md | 36 --- docs/description/operator_whitespace.md | 9 - docs/description/override_in_extension.md | 5 - .../prefer_self_in_static_references.md | 11 +- .../description/prefixed_toplevel_constant.md | 10 +- docs/description/private_action.md | 17 -- docs/description/private_outlet.md | 75 ++---- docs/description/private_swiftui_state.md | 226 ++++++++++++++++++ docs/description/private_unit_test.md | 8 + docs/description/redundant_discardable_let.md | 6 - docs/description/redundant_nil_coalescing.md | 2 - .../redundant_optional_initialization.md | 10 - docs/description/redundant_void_return.md | 13 - docs/description/return_arrow_whitespace.md | 19 -- docs/description/shorthand_operator.md | 210 +--------------- docs/description/single_test_class.md | 3 - docs/description/sorted_first_last.md | 18 -- .../superfluous_disable_command.md | 26 +- docs/description/switch_case_alignment.md | 20 +- docs/description/switch_case_on_newline.md | 2 - docs/description/test_case_accessibility.md | 10 + docs/description/todo.md | 10 - docs/description/toggle_bool.md | 6 - docs/description/trailing_closure.md | 10 - docs/description/trailing_comma.md | 15 -- docs/description/trailing_semicolon.md | 2 - docs/description/type_body_length.md | 12 +- docs/description/unneeded_override.md | 207 ++++++++++++++++ ...nneeded_parentheses_in_closure_argument.md | 7 - .../unneeded_synthesized_initializer.md | 12 + docs/description/unused_closure_parameter.md | 59 ++--- docs/description/unused_enumerated.md | 13 - docs/description/unused_optional_binding.md | 47 +--- .../vertical_whitespace_closing_braces.md | 110 ++++----- docs/description/void_return.md | 21 -- docs/description/weak_delegate.md | 10 - docs/description/yoda_condition.md | 8 - docs/patterns.json | 23 +- 88 files changed, 986 insertions(+), 1281 deletions(-) create mode 100644 docs/description/non_overridable_class_declaration.md create mode 100644 docs/description/private_swiftui_state.md create mode 100644 docs/description/unneeded_override.md diff --git a/Dockerfile b/Dockerfile index 0601d6e..4c58549 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM codacy-swiftlint-dev as builder -FROM swift:5.8.1-jammy-slim +FROM swift:5.9.0-jammy-slim COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so diff --git a/Dockerfile.dev b/Dockerfile.dev index b1281c8..3f859b6 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM norionomura/swiftlint:0.52.4_swift-5.8.1 +FROM norionomura/swiftlint:0.53.0_swift-5.9 RUN apt-get update && apt-get install -y openjdk-8-jre-headless diff --git a/docs/description/accessibility_label_for_image.md b/docs/description/accessibility_label_for_image.md index 1aeb4f0..2a483a9 100644 --- a/docs/description/accessibility_label_for_image.md +++ b/docs/description/accessibility_label_for_image.md @@ -35,14 +35,6 @@ struct MyView: View { } ``` -```swift -struct MyView: View { - var body: some View { - Image(systemName: "circle.plus") - } -} -``` - ```swift struct MyView: View { var body: some View { @@ -315,4 +307,12 @@ struct MyView: View { } } } +``` + +```swift +struct MyView: View { + var body: some View { + ↓Image(systemName: "circle.plus") + } +} ``` \ No newline at end of file diff --git a/docs/description/anyobject_protocol.md b/docs/description/anyobject_protocol.md index 33cb871..032a3e8 100644 --- a/docs/description/anyobject_protocol.md +++ b/docs/description/anyobject_protocol.md @@ -29,37 +29,30 @@ Prefer using `AnyObject` over `class` for class-only protocols ```swift protocol SomeProtocol {} - ``` ```swift protocol SomeClassOnlyProtocol: AnyObject {} - ``` ```swift protocol SomeClassOnlyProtocol: AnyObject, SomeInheritedProtocol {} - ``` ```swift @objc protocol SomeClassOnlyProtocol: AnyObject, SomeInheritedProtocol {} - ``` ## Triggering Examples ```swift protocol SomeClassOnlyProtocol: ↓class {} - ``` ```swift protocol SomeClassOnlyProtocol: ↓class, SomeInheritedProtocol {} - ``` ```swift @objc protocol SomeClassOnlyProtocol: ↓class, SomeInheritedProtocol {} - ``` \ No newline at end of file diff --git a/docs/description/array_init.md b/docs/description/array_init.md index d6304a1..488427d 100644 --- a/docs/description/array_init.md +++ b/docs/description/array_init.md @@ -29,69 +29,56 @@ Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Ar ```swift Array(foo) - ``` ```swift foo.map { $0.0 } - ``` ```swift foo.map { $1 } - ``` ```swift foo.map { $0() } - ``` ```swift foo.map { ((), $0) } - ``` ```swift foo.map { $0! } - ``` ```swift foo.map { $0! /* force unwrap */ } - ``` ```swift foo.something { RouteMapper.map($0) } - ``` ```swift foo.map { !$0 } - ``` ```swift foo.map { /* a comment */ !$0 } - ``` ## Triggering Examples ```swift foo.↓map({ $0 }) - ``` ```swift foo.↓map { $0 } - ``` ```swift foo.↓map { return $0 } - ``` ```swift @@ -120,10 +107,8 @@ foo.↓map { return $0 } ```swift foo.↓map { $0 /* a comment */ } - ``` ```swift foo.↓map { /* a comment */ $0 } - ``` \ No newline at end of file diff --git a/docs/description/attributes.md b/docs/description/attributes.md index be1ffa0..6ab8e6a 100644 --- a/docs/description/attributes.md +++ b/docs/description/attributes.md @@ -178,14 +178,13 @@ class Foo: NSObject { ```swift @objc class ⽺ {} - ``` ```swift extension Property { - @available(*, unavailable, renamed: "isOptional") -public var optional: Bool { fatalError() } + @available(*, unavailable, renamed: "isOptional") + public var optional: Bool { fatalError() } } ``` diff --git a/docs/description/class_delegate_protocol.md b/docs/description/class_delegate_protocol.md index a78254a..a839f01 100644 --- a/docs/description/class_delegate_protocol.md +++ b/docs/description/class_delegate_protocol.md @@ -29,78 +29,63 @@ Delegate protocols should be class-only so they can be weakly referenced ```swift protocol FooDelegate: class {} - ``` ```swift protocol FooDelegate: class, BarDelegate {} - ``` ```swift protocol Foo {} - ``` ```swift class FooDelegate {} - ``` ```swift @objc protocol FooDelegate {} - ``` ```swift @objc(MyFooDelegate) protocol FooDelegate {} - ``` ```swift protocol FooDelegate: BarDelegate {} - ``` ```swift protocol FooDelegate: AnyObject {} - ``` ```swift protocol FooDelegate: NSObjectProtocol {} - ``` ```swift protocol FooDelegate where Self: BarDelegate {} - ``` ```swift protocol FooDelegate where Self: AnyObject {} - ``` ```swift protocol FooDelegate where Self: NSObjectProtocol {} - ``` ## Triggering Examples ```swift ↓protocol FooDelegate {} - ``` ```swift ↓protocol FooDelegate: Bar {} - ``` ```swift ↓protocol FooDelegate where Self: StringProtocol {} - ``` \ No newline at end of file diff --git a/docs/description/closure_parameter_position.md b/docs/description/closure_parameter_position.md index 72cf55c..bb5ee5d 100644 --- a/docs/description/closure_parameter_position.md +++ b/docs/description/closure_parameter_position.md @@ -29,52 +29,44 @@ Closure parameters should be on the same line as opening brace ```swift [1, 2].map { $0 + 1 } - ``` ```swift [1, 2].map({ $0 + 1 }) - ``` ```swift [1, 2].map { number in number + 1 } - ``` ```swift [1, 2].map { number -> Int in number + 1 } - ``` ```swift [1, 2].map { (number: Int) -> Int in number + 1 } - ``` ```swift [1, 2].map { [weak self] number in number + 1 } - ``` ```swift [1, 2].something(closure: { number in number + 1 }) - ``` ```swift let isEmpty = [1, 2].isEmpty() - ``` ```swift diff --git a/docs/description/collection_alignment.md b/docs/description/collection_alignment.md index 63d0c20..5857a4b 100644 --- a/docs/description/collection_alignment.md +++ b/docs/description/collection_alignment.md @@ -62,6 +62,11 @@ let meals = [ ] ``` +```swift +NSAttributedString(string: "…", attributes: [.font: UIFont.systemFont(ofSize: 12, weight: .regular), + .foregroundColor: UIColor(white: 0, alpha: 0.2)]) +``` + ```swift let coordinates = [ CLLocationCoordinate2D(latitude: 0, longitude: 33), diff --git a/docs/description/colon.md b/docs/description/colon.md index 808b7f6..008716c 100644 --- a/docs/description/colon.md +++ b/docs/description/colon.md @@ -45,52 +45,42 @@ Colons should be next to the identifier when specifying a type and next to the k ```swift let abc: Void - ``` ```swift let abc: [Void: Void] - ``` ```swift let abc: (Void, Void) - ``` ```swift let abc: ([Void], String, Int) - ``` ```swift let abc: [([Void], String, Int)] - ``` ```swift let abc: String="def" - ``` ```swift let abc: Int=0 - ``` ```swift let abc: Enum=Enum.Value - ``` ```swift func abc(def: Void) {} - ``` ```swift func abc(def: Void, ghi: Void) {} - ``` ```swift @@ -99,82 +89,66 @@ let abc: String = "abc:" ```swift let abc = [Void: Void]() - ``` ```swift let abc = [1: [3: 2], 3: 4] - ``` ```swift let abc = ["string": "string"] - ``` ```swift let abc = ["string:string": "string"] - ``` ```swift let abc: [String: Int] - ``` ```swift func foo(bar: [String: Int]) {} - ``` ```swift func foo() -> [String: Int] { return [:] } - ``` ```swift let abc: Any - ``` ```swift let abc: [Any: Int] - ``` ```swift let abc: [String: Any] - ``` ```swift class Foo: Bar {} - ``` ```swift class Foo: Bar {} - ``` ```swift class Foo: Bar {} - ``` ```swift class Foo: Bar {} - ``` ```swift class Foo {} - ``` ```swift object.method(x: /* comment */ 5) - ``` ```swift @@ -186,7 +160,6 @@ case .bar: ```swift object.method(x: 5, y: "string") - ``` ```swift @@ -196,7 +169,6 @@ object.method(x: 5, y: ```swift object.method(5, y: "string") - ``` ```swift @@ -259,242 +231,194 @@ switch scalar { ```swift let abc↓:Void - ``` ```swift let abc↓: Void - ``` ```swift let abc↓ :Void - ``` ```swift let abc↓ : Void - ``` ```swift let abc↓ : [Void: Void] - ``` ```swift let abc↓ : (Void, String, Int) - ``` ```swift let abc↓ : ([Void], String, Int) - ``` ```swift let abc↓ : [([Void], String, Int)] - ``` ```swift let abc↓: (Void, String, Int) - ``` ```swift let abc↓: ([Void], String, Int) - ``` ```swift let abc↓: [([Void], String, Int)] - ``` ```swift let abc↓ :String="def" - ``` ```swift let abc↓ :Int=0 - ``` ```swift let abc↓ :Int = 0 - ``` ```swift let abc↓:Int=0 - ``` ```swift let abc↓:Int = 0 - ``` ```swift let abc↓:Enum=Enum.Value - ``` ```swift func abc(def↓:Void) {} - ``` ```swift func abc(def↓: Void) {} - ``` ```swift func abc(def↓ :Void) {} - ``` ```swift func abc(def↓ : Void) {} - ``` ```swift func abc(def: Void, ghi↓ :Void) {} - ``` ```swift let abc = [Void↓:Void]() - ``` ```swift let abc = [Void↓ : Void]() - ``` ```swift let abc = [Void↓: Void]() - ``` ```swift let abc = [Void↓ : Void]() - ``` ```swift let abc = [1: [3↓ : 2], 3: 4] - ``` ```swift let abc = [1: [3↓ : 2], 3↓: 4] - ``` ```swift let abc: [String↓ : Int] - ``` ```swift let abc: [String↓:Int] - ``` ```swift func foo(bar: [String↓ : Int]) {} - ``` ```swift func foo(bar: [String↓:Int]) {} - ``` ```swift func foo() -> [String↓ : Int] { return [:] } - ``` ```swift func foo() -> [String↓:Int] { return [:] } - ``` ```swift let abc↓ : Any - ``` ```swift let abc: [Any↓ : Int] - ``` ```swift let abc: [String↓ : Any] - ``` ```swift class Foo↓ : Bar {} - ``` ```swift class Foo↓:Bar {} - ``` ```swift class Foo↓ : Bar {} - ``` ```swift class Foo↓:Bar {} - ``` ```swift class Foo↓:Bar {} - ``` ```swift class Foo↓:Bar {} - ``` ```swift class Foo {} - ``` ```swift class Foo {} - ``` ```swift object.method(x: 5, y↓ : "string") - ``` ```swift object.method(x↓:5, y: "string") - ``` ```swift object.method(x↓: 5, y: "string") - ``` ```swift diff --git a/docs/description/comma.md b/docs/description/comma.md index 7f5a09d..e634498 100644 --- a/docs/description/comma.md +++ b/docs/description/comma.md @@ -45,7 +45,6 @@ func abc( bcd: String // comment ) { } - ``` ```swift @@ -54,7 +53,6 @@ func abc( bcd: String ) { } - ``` ```swift @@ -89,7 +87,6 @@ let result = plus( first: 3↓ , // #683 second: 4 ) - ``` ```swift diff --git a/docs/description/compiler_protocol_init.md b/docs/description/compiler_protocol_init.md index 7fe5d50..b96de6b 100644 --- a/docs/description/compiler_protocol_init.md +++ b/docs/description/compiler_protocol_init.md @@ -29,32 +29,26 @@ The initializers declared in compiler protocols such as `ExpressibleByArrayLiter ```swift let set: Set = [1, 2] - ``` ```swift let set = Set(array) - ``` ## Triggering Examples ```swift let set = ↓Set(arrayLiteral: 1, 2) - ``` ```swift let set = ↓Set (arrayLiteral: 1, 2) - ``` ```swift let set = ↓Set.init(arrayLiteral: 1, 2) - ``` ```swift let set = ↓Set.init(arrayLiteral : 1, 2) - ``` \ No newline at end of file diff --git a/docs/description/contains_over_filter_count.md b/docs/description/contains_over_filter_count.md index aa13654..1f6225d 100644 --- a/docs/description/contains_over_filter_count.md +++ b/docs/description/contains_over_filter_count.md @@ -29,107 +29,86 @@ Prefer `contains` over comparing `filter(where:).count` to 0 ```swift let result = myList.filter(where: { $0 % 2 == 0 }).count > 1 - ``` ```swift let result = myList.filter { $0 % 2 == 0 }.count > 1 - ``` ```swift let result = myList.filter(where: { $0 % 2 == 0 }).count > 01 - ``` ```swift let result = myList.filter(where: { $0 % 2 == 0 }).count == 1 - ``` ```swift let result = myList.filter { $0 % 2 == 0 }.count == 1 - ``` ```swift let result = myList.filter(where: { $0 % 2 == 0 }).count == 01 - ``` ```swift let result = myList.filter(where: { $0 % 2 == 0 }).count != 1 - ``` ```swift let result = myList.filter { $0 % 2 == 0 }.count != 1 - ``` ```swift let result = myList.filter(where: { $0 % 2 == 0 }).count != 01 - ``` ```swift let result = myList.contains(where: { $0 % 2 == 0 }) - ``` ```swift let result = !myList.contains(where: { $0 % 2 == 0 }) - ``` ```swift let result = myList.contains(10) - ``` ## Triggering Examples ```swift let result = ↓myList.filter(where: { $0 % 2 == 0 }).count > 0 - ``` ```swift let result = ↓myList.filter { $0 % 2 == 0 }.count > 0 - ``` ```swift let result = ↓myList.filter(where: someFunction).count > 0 - ``` ```swift let result = ↓myList.filter(where: { $0 % 2 == 0 }).count == 0 - ``` ```swift let result = ↓myList.filter { $0 % 2 == 0 }.count == 0 - ``` ```swift let result = ↓myList.filter(where: someFunction).count == 0 - ``` ```swift let result = ↓myList.filter(where: { $0 % 2 == 0 }).count != 0 - ``` ```swift let result = ↓myList.filter { $0 % 2 == 0 }.count != 0 - ``` ```swift let result = ↓myList.filter(where: someFunction).count != 0 - ``` \ No newline at end of file diff --git a/docs/description/contains_over_filter_is_empty.md b/docs/description/contains_over_filter_is_empty.md index 0a31422..7ad18a3 100644 --- a/docs/description/contains_over_filter_is_empty.md +++ b/docs/description/contains_over_filter_is_empty.md @@ -29,67 +29,54 @@ Prefer `contains` over using `filter(where:).isEmpty` ```swift let result = myList.filter(where: { $0 % 2 == 0 }).count > 1 - ``` ```swift let result = myList.filter { $0 % 2 == 0 }.count > 1 - ``` ```swift let result = myList.filter(where: { $0 % 2 == 0 }).count == 1 - ``` ```swift let result = myList.filter { $0 % 2 == 0 }.count == 1 - ``` ```swift let result = myList.filter(where: { $0 % 2 == 0 }).count != 1 - ``` ```swift let result = myList.filter { $0 % 2 == 0 }.count != 1 - ``` ```swift let result = myList.contains(where: { $0 % 2 == 0 }) - ``` ```swift let result = !myList.contains(where: { $0 % 2 == 0 }) - ``` ```swift let result = myList.contains(10) - ``` ## Triggering Examples ```swift let result = ↓myList.filter(where: { $0 % 2 == 0 }).isEmpty - ``` ```swift let result = !↓myList.filter(where: { $0 % 2 == 0 }).isEmpty - ``` ```swift let result = ↓myList.filter { $0 % 2 == 0 }.isEmpty - ``` ```swift let result = ↓myList.filter(where: someFunction).isEmpty - ``` \ No newline at end of file diff --git a/docs/description/contains_over_first_not_nil.md b/docs/description/contains_over_first_not_nil.md index be216f2..bfdaccc 100644 --- a/docs/description/contains_over_first_not_nil.md +++ b/docs/description/contains_over_first_not_nil.md @@ -29,142 +29,114 @@ Prefer `contains` over `first(where:) != nil` and `firstIndex(where:) != nil`. ```swift let first = myList.first(where: { $0 % 2 == 0 }) - ``` ```swift let first = myList.first { $0 % 2 == 0 } - ``` ```swift let firstIndex = myList.firstIndex(where: { $0 % 2 == 0 }) - ``` ```swift let firstIndex = myList.firstIndex { $0 % 2 == 0 } - ``` ## Triggering Examples ```swift ↓myList.first { $0 % 2 == 0 } != nil - ``` ```swift ↓myList.first(where: { $0 % 2 == 0 }) != nil - ``` ```swift ↓myList.map { $0 + 1 }.first(where: { $0 % 2 == 0 }) != nil - ``` ```swift ↓myList.first(where: someFunction) != nil - ``` ```swift ↓myList.map { $0 + 1 }.first { $0 % 2 == 0 } != nil - ``` ```swift (↓myList.first { $0 % 2 == 0 }) != nil - ``` ```swift ↓myList.first { $0 % 2 == 0 } == nil - ``` ```swift ↓myList.first(where: { $0 % 2 == 0 }) == nil - ``` ```swift ↓myList.map { $0 + 1 }.first(where: { $0 % 2 == 0 }) == nil - ``` ```swift ↓myList.first(where: someFunction) == nil - ``` ```swift ↓myList.map { $0 + 1 }.first { $0 % 2 == 0 } == nil - ``` ```swift (↓myList.first { $0 % 2 == 0 }) == nil - ``` ```swift ↓myList.firstIndex { $0 % 2 == 0 } != nil - ``` ```swift ↓myList.firstIndex(where: { $0 % 2 == 0 }) != nil - ``` ```swift ↓myList.map { $0 + 1 }.firstIndex(where: { $0 % 2 == 0 }) != nil - ``` ```swift ↓myList.firstIndex(where: someFunction) != nil - ``` ```swift ↓myList.map { $0 + 1 }.firstIndex { $0 % 2 == 0 } != nil - ``` ```swift (↓myList.firstIndex { $0 % 2 == 0 }) != nil - ``` ```swift ↓myList.firstIndex { $0 % 2 == 0 } == nil - ``` ```swift ↓myList.firstIndex(where: { $0 % 2 == 0 }) == nil - ``` ```swift ↓myList.map { $0 + 1 }.firstIndex(where: { $0 % 2 == 0 }) == nil - ``` ```swift ↓myList.firstIndex(where: someFunction) == nil - ``` ```swift ↓myList.map { $0 + 1 }.firstIndex { $0 % 2 == 0 } == nil - ``` ```swift (↓myList.firstIndex { $0 % 2 == 0 }) == nil - ``` \ No newline at end of file diff --git a/docs/description/control_statement.md b/docs/description/control_statement.md index 2be7e2b..75723e5 100644 --- a/docs/description/control_statement.md +++ b/docs/description/control_statement.md @@ -28,84 +28,51 @@ ## Non Triggering Examples ```swift -if condition { - +if condition {} ``` ```swift -if (a, b) == (0, 1) { - +if (a, b) == (0, 1) {} ``` ```swift -if (a || b) && (c || d) { - +if (a || b) && (c || d) {} ``` ```swift -if (min...max).contains(value) { - +if (min...max).contains(value) {} ``` ```swift -if renderGif(data) { - +if renderGif(data) {} ``` ```swift renderGif(data) - -``` - -```swift -for item in collection { - ``` ```swift -for (key, value) in dictionary { - +guard condition else {} ``` ```swift -for (index, value) in enumerate(array) { - +while condition {} ``` ```swift -for var index = 0; index < 42; index++ { - +do {} while condition {} ``` ```swift -guard condition else { - +do { ; } while condition {} ``` ```swift -while condition { - +switch foo {} ``` ```swift -} while condition { - -``` - -```swift -do { ; } while condition { - -``` - -```swift -switch foo { - -``` - -```swift -do { -} catch let error as NSError { -} +do {} catch let error as NSError {} ``` ```swift @@ -113,109 +80,71 @@ foo().catch(all: true) {} ``` ```swift -if max(a, b) < c { - +if max(a, b) < c {} ``` ```swift -switch (lhs, rhs) { - +switch (lhs, rhs) {} ``` -## Triggering Examples - ```swift -↓if (condition) { - -``` - -```swift -↓if(condition) { - +if (f() { g() {} }) {} ``` ```swift -↓if (condition == endIndex) { - +if (a + f() {} == 1) {} ``` -```swift -↓if ((a || b) && (c || d)) { - -``` - -```swift -↓if ((min...max).contains(value)) { - -``` - -```swift -↓for (item in collection) { - -``` +## Triggering Examples ```swift -↓for (var index = 0; index < 42; index++) { - +↓if (condition) {} ``` ```swift -↓for(item in collection) { - +↓if(condition) {} ``` ```swift -↓for(var index = 0; index < 42; index++) { - +↓if (condition == endIndex) {} ``` ```swift -↓guard (condition) else { - +↓if ((a || b) && (c || d)) {} ``` ```swift -↓while (condition) { - +↓if ((min...max).contains(value)) {} ``` ```swift -↓while(condition) { - +↓guard (condition) else {} ``` ```swift -} ↓while (condition) { - +↓while (condition) {} ``` ```swift -} ↓while(condition) { - +↓while(condition) {} ``` ```swift -do { ; } ↓while(condition) { - +do { ; } ↓while(condition) {} ``` ```swift -do { ; } ↓while (condition) { - +do { ; } ↓while (condition) {} ``` ```swift -↓switch (foo) { - +↓switch (foo) {} ``` ```swift -do { -} ↓catch(let error as NSError) { -} +do {} ↓catch(let error as NSError) {} ``` ```swift -↓if (max(a, b) < c) { - +↓if (max(a, b) < c) {} ``` \ No newline at end of file diff --git a/docs/description/description.json b/docs/description/description.json index 4e671bf..b1746a1 100644 --- a/docs/description/description.json +++ b/docs/description/description.json @@ -441,7 +441,7 @@ }, { "patternId" : "invalid_swiftlint_command", "title" : "Invalid SwiftLint Command", - "description" : "swiftlint command does not have a valid action or modifier", + "description" : "swiftlint command is invalid", "parameters" : [ ] }, { "patternId" : "is_disjoint", @@ -618,6 +618,11 @@ "title" : "No Space in Method Call", "description" : "Don't add a space between the method name and the parentheses", "parameters" : [ ] +}, { + "patternId" : "non_overridable_class_declaration", + "title" : "Class Declaration in Final Class", + "description" : "Class methods and properties in final classes should themselves be final, just as if the declarations", + "parameters" : [ ] }, { "patternId" : "notification_center_detachment", "title" : "Notification Center Detachment", @@ -743,6 +748,11 @@ "title" : "Private Combine Subject", "description" : "Combine Subject should be private", "parameters" : [ ] +}, { + "patternId" : "private_swiftui_state", + "title" : "Private SwiftUI State Properties", + "description" : "SwiftUI state properties should be private", + "parameters" : [ ] }, { "patternId" : "private_unit_test", "title" : "Private Unit Test", @@ -931,7 +941,7 @@ }, { "patternId" : "switch_case_alignment", "title" : "Switch and Case Statement Alignment", - "description" : "Case statements should vertically align with their enclosing switch statement, or indented if configured otherwise.", + "description" : "Case statements should vertically align with their closing brace, or indented if configured otherwise.", "parameters" : [ ] }, { "patternId" : "switch_case_on_newline", @@ -1023,6 +1033,11 @@ "title" : "Unneeded Break in Switch", "description" : "Avoid using unneeded break statements", "parameters" : [ ] +}, { + "patternId" : "unneeded_override", + "title" : "Unneeded Overridden Functions", + "description" : "Remove overridden functions that don't do anything except call their super", + "parameters" : [ ] }, { "patternId" : "unneeded_parentheses_in_closure_argument", "title" : "Unneeded Parentheses in Closure Argument", diff --git a/docs/description/discarded_notification_center_observer.md b/docs/description/discarded_notification_center_observer.md index 76bb793..7e22cfb 100644 --- a/docs/description/discarded_notification_center_observer.md +++ b/docs/description/discarded_notification_center_observer.md @@ -29,7 +29,6 @@ When registering for a notification using a block, the opaque observer that is r ```swift let foo = nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { } - ``` ```swift @@ -38,15 +37,13 @@ let foo = nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue ```swift func foo() -> Any { - return nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { }) + return nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { }) } - ``` ```swift var obs: [Any?] = [] obs.append(nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { })) - ``` ```swift @@ -57,7 +54,6 @@ obs["foo"] = nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, qu ```swift var obs: [Any?] = [] obs.append(nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { })) - ``` ```swift @@ -65,7 +61,6 @@ func foo(_ notif: Any) { obs.append(notif) } foo(nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { })) - ``` ```swift @@ -79,17 +74,14 @@ var obs: [NSObjectProtocol] = [ ```swift ↓nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { } - ``` ```swift _ = ↓nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { } - ``` ```swift ↓nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil, using: { }) - ``` ```swift diff --git a/docs/description/empty_count.md b/docs/description/empty_count.md index c5da195..01f0e78 100644 --- a/docs/description/empty_count.md +++ b/docs/description/empty_count.md @@ -37,97 +37,78 @@ Prefer checking `isEmpty` over comparing `count` to zero ```swift var count = 0 - ``` ```swift [Int]().isEmpty - ``` ```swift [Int]().count > 1 - ``` ```swift [Int]().count == 1 - ``` ```swift [Int]().count == 0xff - ``` ```swift [Int]().count == 0b01 - ``` ```swift [Int]().count == 0o07 - ``` ```swift discount == 0 - ``` ```swift order.discount == 0 - ``` ## Triggering Examples ```swift [Int]().↓count == 0 - ``` ```swift 0 == [Int]().↓count - ``` ```swift [Int]().↓count==0 - ``` ```swift [Int]().↓count > 0 - ``` ```swift [Int]().↓count != 0 - ``` ```swift [Int]().↓count == 0x0 - ``` ```swift [Int]().↓count == 0x00_00 - ``` ```swift [Int]().↓count == 0b00 - ``` ```swift [Int]().↓count == 0o00 - ``` ```swift ↓count == 0 - ``` \ No newline at end of file diff --git a/docs/description/empty_parameters.md b/docs/description/empty_parameters.md index f28a205..4e4166e 100644 --- a/docs/description/empty_parameters.md +++ b/docs/description/empty_parameters.md @@ -29,52 +29,42 @@ Prefer `() -> ` over `Void -> ` ```swift let abc: () -> Void = {} - ``` ```swift func foo(completion: () -> Void) - ``` ```swift func foo(completion: () throws -> Void) - ``` ```swift let foo: (ConfigurationTests) -> Void throws -> Void) - ``` ```swift let foo: (ConfigurationTests) -> Void throws -> Void) - ``` ```swift let foo: (ConfigurationTests) ->Void throws -> Void) - ``` ## Triggering Examples ```swift let abc: ↓(Void) -> Void = {} - ``` ```swift func foo(completion: ↓(Void) -> Void) - ``` ```swift func foo(completion: ↓(Void) throws -> Void) - ``` ```swift let foo: ↓(Void) -> () throws -> Void) - ``` \ No newline at end of file diff --git a/docs/description/empty_parentheses_with_trailing_closure.md b/docs/description/empty_parentheses_with_trailing_closure.md index b2a8250..2e285ad 100644 --- a/docs/description/empty_parentheses_with_trailing_closure.md +++ b/docs/description/empty_parentheses_with_trailing_closure.md @@ -29,12 +29,10 @@ When using trailing closures, empty parentheses should be avoided after the meth ```swift [1, 2].map { $0 + 1 } - ``` ```swift [1, 2].map({ $0 + 1 }) - ``` ```swift @@ -45,12 +43,10 @@ When using trailing closures, empty parentheses should be avoided after the meth [1, 2].map { number in number + 1 } - ``` ```swift let isEmpty = [1, 2].isEmpty() - ``` ```swift @@ -65,31 +61,26 @@ UIView.animateWithDuration(0.3, animations: { ```swift [1, 2].map↓() { $0 + 1 } - ``` ```swift [1, 2].map↓( ) { $0 + 1 } - ``` ```swift [1, 2].map↓() { number in number + 1 } - ``` ```swift [1, 2].map↓( ) { number in number + 1 } - ``` ```swift func foo() -> [Int] { return [1, 2].map↓() { $0 + 1 } } - ``` \ No newline at end of file diff --git a/docs/description/expiring_todo.md b/docs/description/expiring_todo.md index 835ec81..e450dc7 100644 --- a/docs/description/expiring_todo.md +++ b/docs/description/expiring_todo.md @@ -99,72 +99,58 @@ TODOs and FIXMEs should be resolved prior to their expiry date. ```swift // notaTODO: - ``` ```swift // notaFIXME: - ``` ```swift // TODO: [12/31/9999] - ``` ```swift // TODO(note) - ``` ```swift // FIXME(note) - ``` ```swift /* FIXME: */ - ``` ```swift /* TODO: */ - ``` ```swift /** FIXME: */ - ``` ```swift /** TODO: */ - ``` ## Triggering Examples ```swift // TODO: [↓10/14/2019] - ``` ```swift // FIXME: [↓10/14/2019] - ``` ```swift // FIXME: [↓1/14/2019] - ``` ```swift // FIXME: [↓10/14/2019] - ``` ```swift // TODO: [↓9999/14/10] - ``` \ No newline at end of file diff --git a/docs/description/explicit_acl.md b/docs/description/explicit_acl.md index 5cc74d0..18154cb 100644 --- a/docs/description/explicit_acl.md +++ b/docs/description/explicit_acl.md @@ -29,17 +29,14 @@ All declarations should specify Access Control Level keywords explicitly ```swift internal enum A {} - ``` ```swift public final class B {} - ``` ```swift private struct C {} - ``` ```swift @@ -61,7 +58,6 @@ class Foo { ```swift internal func a() { let a = } - ``` ```swift @@ -138,33 +134,27 @@ extension Foo { ```swift ↓enum A {} - ``` ```swift final ↓class B {} - ``` ```swift internal struct C { ↓let d = 5 } - ``` ```swift public struct C { ↓let d = 5 } - ``` ```swift func a() {} - ``` ```swift internal let a = 0 ↓func b() {} - ``` ```swift diff --git a/docs/description/explicit_init.md b/docs/description/explicit_init.md index e91e820..b49d8c2 100644 --- a/docs/description/explicit_init.md +++ b/docs/description/explicit_init.md @@ -22,6 +22,14 @@ Explicitly calling .init() should be avoided warning + + + include_bare_init + + + false + + diff --git a/docs/description/explicit_top_level_acl.md b/docs/description/explicit_top_level_acl.md index cb223e7..9ba015b 100644 --- a/docs/description/explicit_top_level_acl.md +++ b/docs/description/explicit_top_level_acl.md @@ -29,23 +29,18 @@ Top-level declarations should specify Access Control Level keywords explicitly ```swift internal enum A {} - ``` ```swift public final class B {} - ``` ```swift private struct C {} - ``` ```swift -internal enum A { - enum B {} -} +internal enum A { enum B {} } ``` ```swift @@ -59,7 +54,6 @@ class Foo {} ```swift internal func a() {} - ``` ```swift @@ -74,26 +68,21 @@ extension A {} ```swift ↓enum A {} - ``` ```swift final ↓class B {} - ``` ```swift ↓struct C {} - ``` ```swift ↓func a() {} - ``` ```swift internal let a = 0 ↓func b() {} - ``` \ No newline at end of file diff --git a/docs/description/file_header.md b/docs/description/file_header.md index 68e3e1b..2769a2b 100644 --- a/docs/description/file_header.md +++ b/docs/description/file_header.md @@ -44,7 +44,6 @@ let foo = 2 ```swift // ↓Copyright - ``` ```swift diff --git a/docs/description/first_where.md b/docs/description/first_where.md index c90c3e6..5b102bc 100644 --- a/docs/description/first_where.md +++ b/docs/description/first_where.md @@ -29,22 +29,18 @@ Prefer using `.first(where:)` over `.filter { }.first` in collections ```swift kinds.filter(excludingKinds.contains).isEmpty && kinds.first == .identifier - ``` ```swift myList.first(where: { $0 % 2 == 0 }) - ``` ```swift match(pattern: pattern).filter { $0.first == .identifier } - ``` ```swift (myList.filter { $0 == 1 }.suffix(2)).first - ``` ```swift @@ -63,38 +59,31 @@ if let pause = timeTracker.pauses.filter("beginDate < %@", beginDate).first { pr ```swift ↓myList.filter { $0 % 2 == 0 }.first - ``` ```swift ↓myList.filter({ $0 % 2 == 0 }).first - ``` ```swift ↓myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).first - ``` ```swift ↓myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).first?.something() - ``` ```swift ↓myList.filter(someFunction).first - ``` ```swift ↓myList.filter({ $0 % 2 == 0 }) .first - ``` ```swift (↓myList.filter { $0 == 1 }).first - ``` ```swift diff --git a/docs/description/force_cast.md b/docs/description/force_cast.md index a63d644..b1d364e 100644 --- a/docs/description/force_cast.md +++ b/docs/description/force_cast.md @@ -29,12 +29,10 @@ Force casts should be avoided ```swift NSNumber() as? Int - ``` ## Triggering Examples ```swift NSNumber() ↓as! Int - ``` \ No newline at end of file diff --git a/docs/description/generic_type_name.md b/docs/description/generic_type_name.md index 043f8aa..26d1596 100644 --- a/docs/description/generic_type_name.md +++ b/docs/description/generic_type_name.md @@ -113,182 +113,146 @@ Generic type name should only contain alphanumeric characters, start with an upp ```swift func foo() {} - ``` ```swift func foo() -> T {} - ``` ```swift func foo(param: U) -> T {} - ``` ```swift func foo(param: U) -> T {} - ``` ```swift struct Foo {} - ``` ```swift class Foo {} - ``` ```swift enum Foo {} - ``` ```swift func run(_ options: NoOptions>) {} - ``` ```swift func foo(_ options: Set) {} - ``` ```swift func < (lhs: T?, rhs: T?) -> Bool - ``` ```swift func configureWith(data: Either) - ``` ```swift typealias StringDictionary = Dictionary - ``` ```swift typealias BackwardTriple = (T3, T2, T1) - ``` ```swift typealias DictionaryOfStrings = Dictionary - ``` ## Triggering Examples ```swift func foo<↓T_Foo>() {} - ``` ```swift func foo(param: U_Foo) -> T {} - ``` ```swift func foo<↓TTTTTTTTTTTTTTTTTTTTT>() {} - ``` ```swift func foo<↓type>() {} - ``` ```swift typealias StringDictionary<↓T_Foo> = Dictionary - ``` ```swift typealias BackwardTriple = (T3, T2_Bar, T1) - ``` ```swift typealias DictionaryOfStrings<↓T_Foo: Hashable> = Dictionary - ``` ```swift class Foo<↓T_Foo> {} - ``` ```swift class Foo {} - ``` ```swift class Foo<↓T_Foo, ↓U_Foo> {} - ``` ```swift class Foo<↓TTTTTTTTTTTTTTTTTTTTT> {} - ``` ```swift class Foo<↓type> {} - ``` ```swift struct Foo<↓T_Foo> {} - ``` ```swift struct Foo {} - ``` ```swift struct Foo<↓T_Foo, ↓U_Foo> {} - ``` ```swift struct Foo<↓TTTTTTTTTTTTTTTTTTTTT> {} - ``` ```swift struct Foo<↓type> {} - ``` ```swift enum Foo<↓T_Foo> {} - ``` ```swift enum Foo {} - ``` ```swift enum Foo<↓T_Foo, ↓U_Foo> {} - ``` ```swift enum Foo<↓TTTTTTTTTTTTTTTTTTTTT> {} - ``` ```swift enum Foo<↓type> {} - ``` \ No newline at end of file diff --git a/docs/description/implicit_return.md b/docs/description/implicit_return.md index d8a358a..b6479b0 100644 --- a/docs/description/implicit_return.md +++ b/docs/description/implicit_return.md @@ -27,7 +27,7 @@ Prefer implicit returns in closures, functions and getters included - [closure, function, getter] + [closure, function, getter, initializer, subscript] @@ -35,12 +35,6 @@ Prefer implicit returns in closures, functions and getters ## Non Triggering Examples -```swift -if foo { - return 0 -} -``` - ```swift foo.map { $0 + 1 } ``` @@ -81,6 +75,27 @@ func fetch() -> Data? { } ``` +```swift +func f() -> Int { + let i = 4 + return i +} +``` + +```swift +func f() -> Int { + return 3 + let i = 2 +} +``` + +```swift +func f() -> Int { + return g() + func g() -> Int { 4 } +} +``` + ```swift var foo: Bool { true } ``` @@ -103,51 +118,86 @@ class Foo { } ``` +```swift +class C { + let i: Int + init(i: Int) { + if i < 3 { + self.i = 1 + return + } + self.i = 2 + } +} +``` + +```swift +class C { + init?() { + let i = 1 + return nil + } +} +``` + +```swift +class C { + subscript(i: Int) -> Int { + let res = i + return res + } +} +``` + ## Triggering Examples ```swift foo.map { value in - return value + 1 + ↓return value + 1 } ``` ```swift foo.map { - return $0 + 1 + ↓return $0 + 1 } ``` ```swift -foo.map({ return $0 + 1}) +foo.map({ ↓return $0 + 1}) ``` ```swift [1, 2].first(where: { - return true + ↓return true }) ``` ```swift func foo() -> Int { - return 0 + ↓return 0 } ``` ```swift class Foo { - func foo() -> Int { return 0 } + func foo() -> Int { ↓return 0 } } ``` ```swift -var foo: Bool { return true } +func f() { ↓return } +``` + +```swift +var foo: Bool { ↓return true } ``` ```swift class Foo { var bar: Int { get { - return 0 + ↓return 0 } } } @@ -156,7 +206,31 @@ class Foo { ```swift class Foo { static var bar: Int { - return 0 + ↓return 0 + } +} +``` + +```swift +class C { + init() { + ↓return + } +} +``` + +```swift +class C { + init?() { + ↓return nil + } +} +``` + +```swift +class C { + subscript(i: Int) -> Int { + ↓return i } } ``` \ No newline at end of file diff --git a/docs/description/invalid_swiftlint_command.md b/docs/description/invalid_swiftlint_command.md index a45c387..90a650f 100644 --- a/docs/description/invalid_swiftlint_command.md +++ b/docs/description/invalid_swiftlint_command.md @@ -1,6 +1,6 @@ # Invalid SwiftLint Command -swiftlint command does not have a valid action or modifier +swiftlint command is invalid * **Identifier:** invalid_swiftlint_command * **Enabled by default:** Yes @@ -47,60 +47,68 @@ swiftlint command does not have a valid action or modifier // swiftlint:disable:this unused_import ``` +```swift +//swiftlint:disable:this unused_import +``` + ## Triggering Examples ```swift -// swiftlint: +// ↓swiftlint: +``` + +```swift +// ↓swiftlint: ``` ```swift -// swiftlint: +// ↓swiftlint:: ``` ```swift -// swiftlint:: +// ↓swiftlint:: ``` ```swift -// swiftlint:: +// ↓swiftlint:disable ``` ```swift -// swiftlint:disable +// ↓swiftlint:dissable unused_import ``` ```swift -// swiftlint:dissable unused_import +// ↓swiftlint:enaaaable unused_import ``` ```swift -// swiftlint:enaaaable unused_import +// ↓swiftlint:disable:nxt unused_import ``` ```swift -// swiftlint:disable:nxt unused_import +// ↓swiftlint:enable:prevus unused_import ``` ```swift -// swiftlint:enable:prevus unused_import +// ↓swiftlint:enable:ths unused_import ``` ```swift -// swiftlint:enable:ths unused_import +// ↓swiftlint:enable ``` ```swift -// swiftlint:enable +// ↓swiftlint:enable: ``` ```swift -// swiftlint:enable: +// ↓swiftlint:enable: ``` ```swift -// swiftlint:enable: +// ↓swiftlint:disable: unused_import ``` ```swift -// swiftlint:disable: unused_import +// s↓swiftlint:disable unused_import ``` \ No newline at end of file diff --git a/docs/description/large_tuple.md b/docs/description/large_tuple.md index bb0117d..b99a4d4 100644 --- a/docs/description/large_tuple.md +++ b/docs/description/large_tuple.md @@ -37,247 +37,198 @@ Tuples shouldn't have too many members. Create a custom type instead. ```swift let foo: (Int, Int) - ``` ```swift let foo: (start: Int, end: Int) - ``` ```swift let foo: (Int, (Int, String)) - ``` ```swift func foo() -> (Int, Int) - ``` ```swift func foo() -> (Int, Int) {} - ``` ```swift func foo(bar: String) -> (Int, Int) - ``` ```swift func foo(bar: String) -> (Int, Int) {} - ``` ```swift func foo() throws -> (Int, Int) - ``` ```swift func foo() throws -> (Int, Int) {} - ``` ```swift let foo: (Int, Int, Int) -> Void - ``` ```swift let foo: (Int, Int, Int) throws -> Void - ``` ```swift func foo(bar: (Int, String, Float) -> Void) - ``` ```swift func foo(bar: (Int, String, Float) throws -> Void) - ``` ```swift var completionHandler: ((_ data: Data?, _ resp: URLResponse?, _ e: NSError?) -> Void)! - ``` ```swift func getDictionaryAndInt() -> (Dictionary, Int)? - ``` ```swift func getGenericTypeAndInt() -> (Type, Int)? - ``` ```swift func foo() async -> (Int, Int) - ``` ```swift func foo() async -> (Int, Int) {} - ``` ```swift func foo(bar: String) async -> (Int, Int) - ``` ```swift func foo(bar: String) async -> (Int, Int) {} - ``` ```swift func foo() async throws -> (Int, Int) - ``` ```swift func foo() async throws -> (Int, Int) {} - ``` ```swift let foo: (Int, Int, Int) async -> Void - ``` ```swift let foo: (Int, Int, Int) async throws -> Void - ``` ```swift func foo(bar: (Int, String, Float) async -> Void) - ``` ```swift func foo(bar: (Int, String, Float) async throws -> Void) - ``` ```swift func getDictionaryAndInt() async -> (Dictionary, Int)? - ``` ```swift func getGenericTypeAndInt() async -> (Type, Int)? - ``` ## Triggering Examples ```swift let foo: ↓(Int, Int, Int) - ``` ```swift let foo: ↓(start: Int, end: Int, value: String) - ``` ```swift let foo: (Int, ↓(Int, Int, Int)) - ``` ```swift func foo(bar: ↓(Int, Int, Int)) - ``` ```swift func foo() -> ↓(Int, Int, Int) - ``` ```swift func foo() -> ↓(Int, Int, Int) {} - ``` ```swift func foo(bar: String) -> ↓(Int, Int, Int) - ``` ```swift func foo(bar: String) -> ↓(Int, Int, Int) {} - ``` ```swift func foo() throws -> ↓(Int, Int, Int) - ``` ```swift func foo() throws -> ↓(Int, Int, Int) {} - ``` ```swift func foo() throws -> ↓(Int, ↓(String, String, String), Int) {} - ``` ```swift func getDictionaryAndInt() -> (Dictionary, Int)? - ``` ```swift func foo(bar: ↓(Int, Int, Int)) async - ``` ```swift func foo() async -> ↓(Int, Int, Int) - ``` ```swift func foo() async -> ↓(Int, Int, Int) {} - ``` ```swift func foo(bar: String) async -> ↓(Int, Int, Int) - ``` ```swift func foo(bar: String) async -> ↓(Int, Int, Int) {} - ``` ```swift func foo() async throws -> ↓(Int, Int, Int) - ``` ```swift func foo() async throws -> ↓(Int, Int, Int) {} - ``` ```swift func foo() async throws -> ↓(Int, ↓(String, String, String), Int) {} - ``` ```swift func getDictionaryAndInt() async -> (Dictionary, Int)? - ``` \ No newline at end of file diff --git a/docs/description/last_where.md b/docs/description/last_where.md index f3666dc..c9c899f 100644 --- a/docs/description/last_where.md +++ b/docs/description/last_where.md @@ -29,22 +29,18 @@ Prefer using `.last(where:)` over `.filter { }.last` in collections ```swift kinds.filter(excludingKinds.contains).isEmpty && kinds.last == .identifier - ``` ```swift myList.last(where: { $0 % 2 == 0 }) - ``` ```swift match(pattern: pattern).filter { $0.last == .identifier } - ``` ```swift (myList.filter { $0 == 1 }.suffix(2)).last - ``` ```swift @@ -55,36 +51,29 @@ collection.filter("stringCol = '3'").last ```swift ↓myList.filter { $0 % 2 == 0 }.last - ``` ```swift ↓myList.filter({ $0 % 2 == 0 }).last - ``` ```swift ↓myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).last - ``` ```swift ↓myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).last?.something() - ``` ```swift ↓myList.filter(someFunction).last - ``` ```swift ↓myList.filter({ $0 % 2 == 0 }) .last - ``` ```swift (↓myList.filter { $0 == 1 }).last - ``` \ No newline at end of file diff --git a/docs/description/leading_whitespace.md b/docs/description/leading_whitespace.md index e87facd..d5ba707 100644 --- a/docs/description/leading_whitespace.md +++ b/docs/description/leading_whitespace.md @@ -29,7 +29,6 @@ Files should not contain leading whitespace ```swift // - ``` ## Triggering Examples @@ -37,10 +36,8 @@ Files should not contain leading whitespace ```swift // - ``` ```swift // - ``` \ No newline at end of file diff --git a/docs/description/legacy_constructor.md b/docs/description/legacy_constructor.md index 3c0839f..bb30a1a 100644 --- a/docs/description/legacy_constructor.md +++ b/docs/description/legacy_constructor.md @@ -127,7 +127,6 @@ UIOffset(horizontal: horizontal, vertical: vertical) ```swift ↓CGPointMake(calculateX(), 10) - ``` ```swift diff --git a/docs/description/legacy_objc_type.md b/docs/description/legacy_objc_type.md index 5942b0a..39c534c 100644 --- a/docs/description/legacy_objc_type.md +++ b/docs/description/legacy_objc_type.md @@ -29,7 +29,6 @@ Prefer Swift value types to bridged Objective-C reference types ```swift var array = Array() - ``` ```swift diff --git a/docs/description/legacy_random.md b/docs/description/legacy_random.md index e1a4ec1..9c0c058 100644 --- a/docs/description/legacy_random.md +++ b/docs/description/legacy_random.md @@ -29,32 +29,26 @@ Prefer using `type.random(in:)` over legacy functions ```swift Int.random(in: 0..<10) - ``` ```swift Double.random(in: 8.6...111.34) - ``` ```swift Float.random(in: 0 ..< 1) - ``` ## Triggering Examples ```swift ↓arc4random() - ``` ```swift ↓arc4random_uniform(83) - ``` ```swift ↓drand48() - ``` \ No newline at end of file diff --git a/docs/description/let_var_whitespace.md b/docs/description/let_var_whitespace.md index 36f13b9..2a45d16 100644 --- a/docs/description/let_var_whitespace.md +++ b/docs/description/let_var_whitespace.md @@ -32,35 +32,30 @@ let a = 0 var x = 1 x = 2 - ``` ```swift a = 5 var x = 1 - ``` ```swift struct X { var a = 0 } - ``` ```swift let a = 1 + 2 let b = 5 - ``` ```swift var x: Int { return 0 } - ``` ```swift @@ -69,32 +64,27 @@ var x: Int { return a } - ``` ```swift #if os(macOS) let a = 0 #endif - ``` ```swift #warning("TODO: remove it") let a = 0 - ``` ```swift #error("TODO: remove it") let a = 0 - ``` ```swift @available(swift 4) let a = 0 - ``` ```swift @@ -117,14 +107,12 @@ class C { lazy var y = 0 } - ``` ```swift @available(OSX, introduced: 10.6) @available(*, deprecated) var x = 0 - ``` ```swift @@ -148,7 +136,6 @@ var x: Int { let a = 0 return a } - ``` ## Triggering Examples @@ -156,14 +143,12 @@ var x: Int { ```swift var x = 1 ↓x = 2 - ``` ```swift a = 5 ↓var x = 1 - ``` ```swift @@ -171,27 +156,23 @@ struct X { let a ↓func x() {} } - ``` ```swift var x = 0 ↓@objc func f() {} - ``` ```swift var x = 0 ↓@objc func f() {} - ``` ```swift @objc func f() { } ↓var x = 0 - ``` ```swift diff --git a/docs/description/line_length.md b/docs/description/line_length.md index 403c672..1bb7935 100644 --- a/docs/description/line_length.md +++ b/docs/description/line_length.md @@ -69,32 +69,26 @@ Lines should not span too many characters. ```swift //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ``` ```swift #colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1) - ``` ```swift #imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg") - ``` ## Triggering Examples ```swift ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ``` ```swift #colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1) - ``` ```swift #imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg")#imageLiteral(resourceName: "image.jpg") - ``` \ No newline at end of file diff --git a/docs/description/mark.md b/docs/description/mark.md index 2a870db..52c747a 100644 --- a/docs/description/mark.md +++ b/docs/description/mark.md @@ -29,17 +29,14 @@ MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...' ```swift // MARK: good - ``` ```swift // MARK: - good - ``` ```swift // MARK: - - ``` ```swift diff --git a/docs/description/missing_docs.md b/docs/description/missing_docs.md index 7d3d43c..9d5adeb 100644 --- a/docs/description/missing_docs.md +++ b/docs/description/missing_docs.md @@ -91,19 +91,16 @@ public class A { ```swift public func a() {} - ``` ```swift // regular comment public func a() {} - ``` ```swift /* regular comment */ public func a() {} - ``` ```swift diff --git a/docs/description/multiline_arguments.md b/docs/description/multiline_arguments.md index abe2608..0f98592 100644 --- a/docs/description/multiline_arguments.md +++ b/docs/description/multiline_arguments.md @@ -58,7 +58,7 @@ foo { } ```swift foo { - + } ``` diff --git a/docs/description/multiple_closures_with_trailing_closure.md b/docs/description/multiple_closures_with_trailing_closure.md index 14e2cb2..eaf11a5 100644 --- a/docs/description/multiple_closures_with_trailing_closure.md +++ b/docs/description/multiple_closures_with_trailing_closure.md @@ -29,24 +29,20 @@ Trailing closure syntax should not be used when passing more than one closure ar ```swift foo.map { $0 + 1 } - ``` ```swift foo.reduce(0) { $0 + $1 } - ``` ```swift if let foo = bar.map({ $0 + 1 }) { } - ``` ```swift foo.something(param1: { $0 }, param2: { $0 + 1 }) - ``` ```swift diff --git a/docs/description/nimble_operator.md b/docs/description/nimble_operator.md index 648f125..d1ffdce 100644 --- a/docs/description/nimble_operator.md +++ b/docs/description/nimble_operator.md @@ -29,32 +29,26 @@ Prefer Nimble operator overloads over free matcher functions ```swift expect(seagull.squawk) != "Hi!" - ``` ```swift expect("Hi!") == "Hi!" - ``` ```swift expect(10) > 2 - ``` ```swift expect(10) >= 10 - ``` ```swift expect(10) < 11 - ``` ```swift expect(10) <= 10 - ``` ```swift @@ -79,12 +73,10 @@ expect(value) != nil ```swift expect(object.asyncFunction()).toEventually(equal(1)) - ``` ```swift expect(actual).to(haveCount(expected)) - ``` ```swift @@ -98,71 +90,57 @@ foo.method { ```swift ↓expect(seagull.squawk).toNot(equal("Hi")) - ``` ```swift ↓expect(12).toNot(equal(10)) - ``` ```swift ↓expect(10).to(equal(10)) - ``` ```swift ↓expect(10, line: 1).to(equal(10)) - ``` ```swift ↓expect(10).to(beGreaterThan(8)) - ``` ```swift ↓expect(10).to(beGreaterThanOrEqualTo(10)) - ``` ```swift ↓expect(10).to(beLessThan(11)) - ``` ```swift ↓expect(10).to(beLessThanOrEqualTo(10)) - ``` ```swift ↓expect(x).to(beIdenticalTo(x)) - ``` ```swift ↓expect(success).to(beTrue()) - ``` ```swift ↓expect(success).to(beFalse()) - ``` ```swift ↓expect(value).to(beNil()) - ``` ```swift ↓expect(value).toNot(beNil()) - ``` ```swift expect(10) > 2 ↓expect(10).to(beGreaterThan(2)) - ``` \ No newline at end of file diff --git a/docs/description/no_grouping_extension.md b/docs/description/no_grouping_extension.md index 120abd0..e5c26bf 100644 --- a/docs/description/no_grouping_extension.md +++ b/docs/description/no_grouping_extension.md @@ -30,19 +30,16 @@ Extensions shouldn't be used to group code within the same source file ```swift protocol Food {} extension Food {} - ``` ```swift class Apples {} extension Oranges {} - ``` ```swift class Box {} extension Box where T: Vegetable {} - ``` ## Triggering Examples @@ -50,23 +47,19 @@ extension Box where T: Vegetable {} ```swift enum Fruit {} ↓extension Fruit {} - ``` ```swift ↓extension Tea: Error {} struct Tea {} - ``` ```swift class Ham { class Spam {}} ↓extension Ham.Spam {} - ``` ```swift extension External { struct Gotcha {}} ↓extension External.Gotcha {} - ``` \ No newline at end of file diff --git a/docs/description/no_magic_numbers.md b/docs/description/no_magic_numbers.md index 6e3169e..56a2371 100644 --- a/docs/description/no_magic_numbers.md +++ b/docs/description/no_magic_numbers.md @@ -110,6 +110,40 @@ class FooTests: XCTestCase { } ``` +```swift +class MyTest: XCTestCase {} +extension MyTest { + let a = Int(3) +} +``` + +```swift +extension MyTest { + let a = Int(3) +} +class MyTest: XCTestCase {} +``` + +```swift +let foo = 1 << 2 +``` + +```swift +let foo = 1 >> 2 +``` + +```swift +let foo = 2 >> 2 +``` + +```swift +let foo = 2 << 2 +``` + +```swift +let a = b / 100.0 +``` + ## Triggering Examples ```swift @@ -134,4 +168,11 @@ let a = b + ↓2.0 ```swift Color.primary.opacity(isAnimate ? ↓0.1 : ↓1.5) +``` + +```swift + class MyTest: XCTestCase {} + extension NSObject { + let a = Int(↓3) + } ``` \ No newline at end of file diff --git a/docs/description/non_overridable_class_declaration.md b/docs/description/non_overridable_class_declaration.md new file mode 100644 index 0000000..2c95887 --- /dev/null +++ b/docs/description/non_overridable_class_declaration.md @@ -0,0 +1,106 @@ +# Class Declaration in Final Class + +Class methods and properties in final classes should themselves be final, just as if the declarations +are private. In both cases, they cannot be overriden. Using `final class` or `static` makes this explicit. + +* **Identifier:** non_overridable_class_declaration +* **Enabled by default:** No +* **Supports autocorrection:** Yes +* **Kind:** style +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ final_class_modifier + + final class +
+ +## Non Triggering Examples + +```swift +final class C { + final class var b: Bool { true } + final class func f() {} +} +``` + +```swift +class C { + final class var b: Bool { true } + final class func f() {} +} +``` + +```swift +class C { + class var b: Bool { true } + class func f() {} +} +``` + +```swift +class C { + static var b: Bool { true } + static func f() {} +} +``` + +```swift +final class C { + static var b: Bool { true } + static func f() {} +} +``` + +```swift +final class C { + class D { + class var b: Bool { true } + class func f() {} + } +} +``` + +## Triggering Examples + +```swift +final class C { + ↓class var b: Bool { true } + ↓class func f() {} +} +``` + +```swift +class C { + final class D { + ↓class var b: Bool { true } + ↓class func f() {} + } +} +``` + +```swift +class C { + private ↓class var b: Bool { true } + private ↓class func f() {} +} +``` \ No newline at end of file diff --git a/docs/description/ns_number_init_as_function_reference.md b/docs/description/ns_number_init_as_function_reference.md index 513fdfd..0886207 100644 --- a/docs/description/ns_number_init_as_function_reference.md +++ b/docs/description/ns_number_init_as_function_reference.md @@ -31,6 +31,10 @@ Passing `NSNumber.init` or `NSDecimalNumber.init` as a function reference is dan [0, 0.2].map(NSNumber.init(value:)) ``` +```swift +let value = NSNumber.init(value: 0.0) +``` + ```swift [0, 0.2].map { NSNumber(value: $0) } ``` diff --git a/docs/description/number_separator.md b/docs/description/number_separator.md index 8fa1320..6bf5d01 100644 --- a/docs/description/number_separator.md +++ b/docs/description/number_separator.md @@ -30,6 +30,14 @@ Underscores should be used as thousand separator in large numbers with a configu 0 + + + exclude_ranges + + + [] + + diff --git a/docs/description/opening_brace.md b/docs/description/opening_brace.md index 631c701..14310ae 100644 --- a/docs/description/opening_brace.md +++ b/docs/description/opening_brace.md @@ -86,7 +86,6 @@ guard ```swift struct Rule {} - ``` ```swift @@ -95,7 +94,6 @@ struct Parent { let foo: Int } } - ``` ```swift @@ -183,14 +181,12 @@ guard ```swift struct Rule↓{} - ``` ```swift struct Rule ↓{ } - ``` ```swift @@ -198,7 +194,6 @@ struct Rule ↓{ } - ``` ```swift @@ -208,7 +203,6 @@ struct Parent { let foo: Int } } - ``` ```swift diff --git a/docs/description/operator_usage_whitespace.md b/docs/description/operator_usage_whitespace.md index 5c109c5..cfb12a8 100644 --- a/docs/description/operator_usage_whitespace.md +++ b/docs/description/operator_usage_whitespace.md @@ -53,100 +53,81 @@ Operators should be surrounded by a single whitespace when they are being used ```swift let foo = 1 + 2 - ``` ```swift let foo = 1 > 2 - ``` ```swift let foo = !false - ``` ```swift let foo: Int? - ``` ```swift let foo: Array - ``` ```swift let model = CustomView, NSAttributedString>() - ``` ```swift let foo: [String] - ``` ```swift let foo = 1 + 2 - ``` ```swift let range = 1...3 - ``` ```swift let range = 1 ... 3 - ``` ```swift let range = 1..<3 - ``` ```swift #if swift(>=3.0) foo() #endif - ``` ```swift array.removeAtIndex(-200) - ``` ```swift let name = "image-1" - ``` ```swift button.setImage(#imageLiteral(resourceName: "image-1"), for: .normal) - ``` ```swift let doubleValue = -9e-11 - ``` ```swift let foo = GenericType<(UIViewController) -> Void>() - ``` ```swift let foo = Foo, Baz>() - ``` ```swift let foo = SignalProducer, Error>([ self.signal, next ]).flatten(.concat) - ``` ```swift @@ -220,88 +201,71 @@ tabbedViewController.title = nil ```swift let foo = 1↓+2 - ``` ```swift let foo = 1↓ + 2 - ``` ```swift let foo = 1↓ + 2 - ``` ```swift let foo = 1↓ + 2 - ``` ```swift let foo↓=1↓+2 - ``` ```swift let foo↓=1 + 2 - ``` ```swift let foo↓=bar - ``` ```swift let range = 1↓ ..< 3 - ``` ```swift let foo = bar↓ ?? 0 - ``` ```swift let foo = bar↓ != 0 - ``` ```swift let foo = bar↓ !== bar2 - ``` ```swift let v8 = Int8(1)↓ << 6 - ``` ```swift let v8 = 1↓ << (6) - ``` ```swift let v8 = 1↓ << (6) let foo = 1 > 2 - ``` ```swift let foo↓ = [1] - ``` ```swift let foo↓ = "1" - ``` ```swift let foo↓ = "1" - ``` ```swift diff --git a/docs/description/operator_whitespace.md b/docs/description/operator_whitespace.md index ade7e3b..eb3ef4f 100644 --- a/docs/description/operator_whitespace.md +++ b/docs/description/operator_whitespace.md @@ -29,47 +29,38 @@ Operators should be surrounded by a single whitespace when defining them ```swift func <| (lhs: Int, rhs: Int) -> Int {} - ``` ```swift func <|<
(lhs: A, rhs: A) -> A {} - ``` ```swift func abc(lhs: Int, rhs: Int) -> Int {} - ``` ## Triggering Examples ```swift ↓func <|(lhs: Int, rhs: Int) -> Int {} - ``` ```swift ↓func <|<(lhs: A, rhs: A) -> A {} - ``` ```swift ↓func <| (lhs: Int, rhs: Int) -> Int {} - ``` ```swift ↓func <|< (lhs: A, rhs: A) -> A {} - ``` ```swift ↓func <| (lhs: Int, rhs: Int) -> Int {} - ``` ```swift ↓func <|< (lhs: A, rhs: A) -> A {} - ``` \ No newline at end of file diff --git a/docs/description/override_in_extension.md b/docs/description/override_in_extension.md index fdc5127..dc93ac9 100644 --- a/docs/description/override_in_extension.md +++ b/docs/description/override_in_extension.md @@ -31,21 +31,18 @@ Extensions shouldn't override declarations extension Person { var age: Int { return 42 } } - ``` ```swift extension Person { func celebrateBirthday() {} } - ``` ```swift class Employee: Person { override func celebrateBirthday() {} } - ``` ```swift @@ -70,12 +67,10 @@ extension Foo.Bar { extension Person { override ↓var age: Int { return 42 } } - ``` ```swift extension Person { override ↓func celebrateBirthday() {} } - ``` \ No newline at end of file diff --git a/docs/description/prefer_self_in_static_references.md b/docs/description/prefer_self_in_static_references.md index 81def90..d980281 100644 --- a/docs/description/prefer_self_in_static_references.md +++ b/docs/description/prefer_self_in_static_references.md @@ -69,14 +69,11 @@ final class CheckCellView: NSTableCellView { ```swift class C { - struct S { - static let i = 2 - let h = ↓S.i - } static let i = 1 - let h = C.i - var j: Int { ↓C.i } - func f() -> Int { ↓C.i + h } + var j: Int { + let ii = ↓C.i + return ii + } } ``` diff --git a/docs/description/prefixed_toplevel_constant.md b/docs/description/prefixed_toplevel_constant.md index d100a81..5da3e1a 100644 --- a/docs/description/prefixed_toplevel_constant.md +++ b/docs/description/prefixed_toplevel_constant.md @@ -57,7 +57,7 @@ let Foo = true ```swift struct Foo { - let bar = 20.0 + let bar = 20.0 } ``` @@ -87,18 +87,18 @@ var foo = true, let kFoo = true ```swift let - kFoo = true + kFoo = true ``` ```swift var foo: Int { - return a + b + return a + b } ``` ```swift let kFoo = { - return a + b + return a + b }() ``` @@ -155,6 +155,6 @@ let ```swift let ↓foo = { - return a + b + return a + b }() ``` \ No newline at end of file diff --git a/docs/description/private_action.md b/docs/description/private_action.md index 8faff71..0dfc9c3 100644 --- a/docs/description/private_action.md +++ b/docs/description/private_action.md @@ -31,42 +31,36 @@ IBActions should be private class Foo { @IBAction private func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift struct Foo { @IBAction private func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift class Foo { @IBAction fileprivate func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift struct Foo { @IBAction fileprivate func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift private extension Foo { @IBAction func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift fileprivate extension Foo { @IBAction func barButtonTapped(_ sender: UIButton) {} } - ``` ## Triggering Examples @@ -75,75 +69,64 @@ fileprivate extension Foo { class Foo { @IBAction ↓func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift struct Foo { @IBAction ↓func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift class Foo { @IBAction public ↓func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift struct Foo { @IBAction public ↓func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift class Foo { @IBAction internal ↓func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift struct Foo { @IBAction internal ↓func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift extension Foo { @IBAction ↓func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift extension Foo { @IBAction public ↓func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift extension Foo { @IBAction internal ↓func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift public extension Foo { @IBAction ↓func barButtonTapped(_ sender: UIButton) {} } - ``` ```swift internal extension Foo { @IBAction ↓func barButtonTapped(_ sender: UIButton) {} } - ``` \ No newline at end of file diff --git a/docs/description/private_outlet.md b/docs/description/private_outlet.md index a6ae706..d039321 100644 --- a/docs/description/private_outlet.md +++ b/docs/description/private_outlet.md @@ -36,108 +36,63 @@ IBOutlets should be private to avoid leaking UIKit to higher layers ## Non Triggering Examples ```swift -class Foo { - @IBOutlet private var label: UILabel? -} - +class Foo { @IBOutlet private var label: UILabel? } ``` ```swift -class Foo { - @IBOutlet private var label: UILabel! -} - +class Foo { @IBOutlet private var label: UILabel! } ``` ```swift -class Foo { - var notAnOutlet: UILabel -} - +class Foo { var notAnOutlet: UILabel } ``` ```swift -class Foo { - @IBOutlet weak private var label: UILabel? -} - +class Foo { @IBOutlet weak private var label: UILabel? } ``` ```swift -class Foo { - @IBOutlet private weak var label: UILabel? -} - +class Foo { @IBOutlet private weak var label: UILabel? } ``` ```swift -class Foo { - @IBOutlet fileprivate weak var label: UILabel? -} - +class Foo { @IBOutlet fileprivate weak var label: UILabel? } ``` ```swift -class Foo { - @IBOutlet private(set) var label: UILabel? -} - +class Foo { @IBOutlet private(set) var label: UILabel? } ``` ```swift -class Foo { - @IBOutlet private(set) var label: UILabel! -} - +class Foo { @IBOutlet private(set) var label: UILabel! } ``` ```swift -class Foo { - @IBOutlet weak private(set) var label: UILabel? -} - +class Foo { @IBOutlet weak private(set) var label: UILabel? } ``` ```swift -class Foo { - @IBOutlet private(set) weak var label: UILabel? -} - +class Foo { @IBOutlet private(set) weak var label: UILabel? } ``` ```swift -class Foo { - @IBOutlet fileprivate(set) weak var label: UILabel? -} - +class Foo { @IBOutlet fileprivate(set) weak var label: UILabel? } ``` ## Triggering Examples ```swift -class Foo { - @IBOutlet ↓var label: UILabel? -} - +class Foo { @IBOutlet ↓var label: UILabel? } ``` ```swift -class Foo { - @IBOutlet ↓var label: UILabel! -} - +class Foo { @IBOutlet ↓var label: UILabel! } ``` ```swift -class Foo { - @IBOutlet private(set) ↓var label: UILabel? -} - +class Foo { @IBOutlet private(set) ↓var label: UILabel? } ``` ```swift -class Foo { - @IBOutlet fileprivate(set) ↓var label: UILabel? -} - +class Foo { @IBOutlet fileprivate(set) ↓var label: UILabel? } ``` \ No newline at end of file diff --git a/docs/description/private_swiftui_state.md b/docs/description/private_swiftui_state.md new file mode 100644 index 0000000..6bbe95c --- /dev/null +++ b/docs/description/private_swiftui_state.md @@ -0,0 +1,226 @@ +# Private SwiftUI State Properties + +SwiftUI state properties should be private + +* **Identifier:** private_swiftui_state +* **Enabled by default:** No +* **Supports autocorrection:** No +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ +## Non Triggering Examples + +```swift +struct MyApp: App { + @State private var isPlaying: Bool = false +} +``` + +```swift +struct MyScene: Scene { + @State private var isPlaying: Bool = false +} +``` + +```swift +struct ContentView: View { + @State private var isPlaying: Bool = false +} +``` + +```swift +struct ContentView: View { + @State fileprivate var isPlaying: Bool = false +} +``` + +```swift +struct ContentView: View { + @State private var isPlaying: Bool = false + + struct InnerView: View { + @State private var showsIndicator: Bool = false + } +} +``` + +```swift +struct MyStruct { + struct ContentView: View { + @State private var isPlaying: Bool = false + } +} +``` + +```swift +struct MyStruct { + struct ContentView: View { + @State private var isPlaying: Bool = false + } + + @State var nonTriggeringState: Bool = false +} +``` + +```swift +struct ContentView: View { + var isPlaying = false +} +``` + +```swift +struct MyApp: App { + @StateObject private var model = DataModel() +} +``` + +```swift +struct MyScene: Scene { + @StateObject private var model = DataModel() +} +``` + +```swift +struct ContentView: View { + @StateObject private var model = DataModel() +} +``` + +```swift +struct MyStruct { + struct ContentView: View { + @StateObject private var dataModel = DataModel() + } + + @StateObject var nonTriggeringObject = MyModel() +} +``` + +```swift +struct Foo { + @State var bar = false +} +``` + +```swift +class Foo: ObservableObject { + @State var bar = Bar() +} +``` + +```swift +extension MyObject { + struct ContentView: View { + @State private var isPlaying: Bool = false + } +} +``` + +```swift +actor ContentView: View { + @State private var isPlaying: Bool = false +} +``` + +## Triggering Examples + +```swift +struct MyApp: App { + @State ↓var isPlaying: Bool = false +} +``` + +```swift +struct MyScene: Scene { + @State ↓var isPlaying: Bool = false +} +``` + +```swift +struct ContentView: View { + @State ↓var isPlaying: Bool = false +} +``` + +```swift +struct ContentView: View { + struct InnerView: View { + @State private var showsIndicator: Bool = false + } + + @State ↓var isPlaying: Bool = false +} +``` + +```swift +struct MyStruct { + struct ContentView: View { + @State ↓var isPlaying: Bool = false + } +} +``` + +```swift +struct MyStruct { + struct ContentView: View { + @State ↓var isPlaying: Bool = false + } + + @State var isPlaying: Bool = false +} +``` + +```swift +final class ContentView: View { + @State ↓var isPlaying: Bool = false +} +``` + +```swift +extension MyObject { + struct ContentView: View { + @State ↓var isPlaying: Bool = false + } +} +``` + +```swift +actor ContentView: View { + @State ↓var isPlaying: Bool = false +} +``` + +```swift +struct MyApp: App { + @StateObject ↓var model = DataModel() +} +``` + +```swift +struct MyScene: Scene { + @StateObject ↓var model = DataModel() +} +``` + +```swift +struct ContentView: View { + @StateObject ↓var model = DataModel() +} +``` \ No newline at end of file diff --git a/docs/description/private_unit_test.md b/docs/description/private_unit_test.md index 8c24e17..5bb6154 100644 --- a/docs/description/private_unit_test.md +++ b/docs/description/private_unit_test.md @@ -24,6 +24,14 @@ Unit tests marked private are silently skipped + test_parent_classes + + + ["QuickSpec", "XCTestCase"] + + + + regex diff --git a/docs/description/redundant_discardable_let.md b/docs/description/redundant_discardable_let.md index c4d6a35..b7fc9a2 100644 --- a/docs/description/redundant_discardable_let.md +++ b/docs/description/redundant_discardable_let.md @@ -29,17 +29,14 @@ Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function ```swift _ = foo() - ``` ```swift if let _ = foo() { } - ``` ```swift guard let _ = foo() else { return } - ``` ```swift @@ -48,7 +45,6 @@ let _: ExplicitType = foo() ```swift while let _ = SplashStyle(rawValue: maxValue) { maxValue += 1 } - ``` ```swift @@ -59,10 +55,8 @@ async let _ = await foo() ```swift ↓let _ = foo() - ``` ```swift if _ = foo() { ↓let _ = bar() } - ``` \ No newline at end of file diff --git a/docs/description/redundant_nil_coalescing.md b/docs/description/redundant_nil_coalescing.md index dd4abf2..17b87ca 100644 --- a/docs/description/redundant_nil_coalescing.md +++ b/docs/description/redundant_nil_coalescing.md @@ -29,12 +29,10 @@ nil coalescing operator is only evaluated if the lhs is nil, coalescing operator ```swift var myVar: Int?; myVar ?? 0 - ``` ## Triggering Examples ```swift var myVar: Int? = nil; myVar ↓?? nil - ``` \ No newline at end of file diff --git a/docs/description/redundant_optional_initialization.md b/docs/description/redundant_optional_initialization.md index d4fc4b8..a790d2b 100644 --- a/docs/description/redundant_optional_initialization.md +++ b/docs/description/redundant_optional_initialization.md @@ -29,37 +29,30 @@ Initializing an optional variable with nil is redundant ```swift var myVar: Int? - ``` ```swift let myVar: Int? = nil - ``` ```swift var myVar: Int? = 0 - ``` ```swift func foo(bar: Int? = 0) { } - ``` ```swift var myVar: Optional - ``` ```swift let myVar: Optional = nil - ``` ```swift var myVar: Optional = 0 - ``` ```swift @@ -96,17 +89,14 @@ func funcName() { ```swift var myVar: Int?↓ = nil - ``` ```swift var myVar: Optional↓ = nil - ``` ```swift var myVar: Int?↓=nil - ``` ```swift diff --git a/docs/description/redundant_void_return.md b/docs/description/redundant_void_return.md index d423a75..2997019 100644 --- a/docs/description/redundant_void_return.md +++ b/docs/description/redundant_void_return.md @@ -29,57 +29,46 @@ Returning Void in a function declaration is redundant ```swift func foo() {} - ``` ```swift func foo() -> Int {} - ``` ```swift func foo() -> Int -> Void {} - ``` ```swift func foo() -> VoidResponse - ``` ```swift let foo: (Int) -> Void - ``` ```swift func foo() -> Int -> () {} - ``` ```swift let foo: (Int) -> () - ``` ```swift func foo() -> ()? - ``` ```swift func foo() -> ()! - ``` ```swift func foo() -> Void? - ``` ```swift func foo() -> Void! - ``` ```swift @@ -94,7 +83,6 @@ struct A { ```swift func foo()↓ -> Void {} - ``` ```swift @@ -105,7 +93,6 @@ protocol Foo { ```swift func foo()↓ -> () {} - ``` ```swift diff --git a/docs/description/return_arrow_whitespace.md b/docs/description/return_arrow_whitespace.md index a456e68..82a8a13 100644 --- a/docs/description/return_arrow_whitespace.md +++ b/docs/description/return_arrow_whitespace.md @@ -29,34 +29,28 @@ Return arrow and return type should be separated by a single space or on a separ ```swift func abc() -> Int {} - ``` ```swift func abc() -> [Int] {} - ``` ```swift func abc() -> (Int, Int) {} - ``` ```swift var abc = {(param: Int) -> Void in } - ``` ```swift func abc() -> Int {} - ``` ```swift func abc() -> Int {} - ``` ```swift @@ -74,47 +68,38 @@ typealias SuccessBlock = ((Data) -> Void) ```swift func abc()↓->Int {} - ``` ```swift func abc()↓->[Int] {} - ``` ```swift func abc()↓->(Int, Int) {} - ``` ```swift func abc()↓-> Int {} - ``` ```swift func abc()↓-> Int {} - ``` ```swift func abc()↓ ->Int {} - ``` ```swift func abc()↓ -> Int {} - ``` ```swift var abc = {(param: Int)↓ ->Bool in } - ``` ```swift var abc = {(param: Int)↓->Bool in } - ``` ```swift @@ -124,23 +109,19 @@ typealias SuccessBlock = ((Data)↓->Void) ```swift func abc() ↓-> Int {} - ``` ```swift func abc() ↓-> Int {} - ``` ```swift func abc()↓ -> Int {} - ``` ```swift func abc()↓ -> Int {} - ``` \ No newline at end of file diff --git a/docs/description/shorthand_operator.md b/docs/description/shorthand_operator.md index f8338ab..1fe2682 100644 --- a/docs/description/shorthand_operator.md +++ b/docs/description/shorthand_operator.md @@ -31,134 +31,20 @@ Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigni foo -= 1 ``` -```swift -foo -= variable -``` - -```swift -foo -= bar.method() -``` - -```swift -self.foo = foo - 1 -``` - -```swift -foo = self.foo - 1 -``` - -```swift -page = ceilf(currentOffset - pageWidth) -``` - -```swift -foo = aMethod(foo - bar) -``` - -```swift -foo = aMethod(bar - foo) -``` - -```swift -public func -= (lhs: inout Foo, rhs: Int) { - lhs = lhs - rhs -} -``` - -```swift -foo /= 1 -``` - -```swift -foo /= variable -``` - -```swift -foo /= bar.method() -``` - -```swift -self.foo = foo / 1 -``` - -```swift -foo = self.foo / 1 -``` - -```swift -page = ceilf(currentOffset / pageWidth) -``` - -```swift -foo = aMethod(foo / bar) -``` - -```swift -foo = aMethod(bar / foo) -``` - -```swift -public func /= (lhs: inout Foo, rhs: Int) { - lhs = lhs / rhs -} -``` - -```swift -foo += 1 -``` - ```swift foo += variable ``` -```swift -foo += bar.method() -``` - -```swift -self.foo = foo + 1 -``` - -```swift -foo = self.foo + 1 -``` - -```swift -page = ceilf(currentOffset + pageWidth) -``` - -```swift -foo = aMethod(foo + bar) -``` - -```swift -foo = aMethod(bar + foo) -``` - -```swift -public func += (lhs: inout Foo, rhs: Int) { - lhs = lhs + rhs -} -``` - -```swift -foo *= 1 -``` - -```swift -foo *= variable -``` - ```swift foo *= bar.method() ``` ```swift -self.foo = foo * 1 +self.foo = foo / 1 ``` ```swift -foo = self.foo * 1 +foo = self.foo + 1 ``` ```swift @@ -166,16 +52,16 @@ page = ceilf(currentOffset * pageWidth) ``` ```swift -foo = aMethod(foo * bar) +foo = aMethod(foo / bar) ``` ```swift -foo = aMethod(bar * foo) +foo = aMethod(bar + foo) ``` ```swift -public func *= (lhs: inout Foo, rhs: Int) { - lhs = lhs * rhs +public func -= (lhs: inout Foo, rhs: Int) { + lhs = lhs - rhs } ``` @@ -195,103 +81,23 @@ seconds = seconds * 60 + value ## Triggering Examples ```swift -↓foo = foo - 1 - +↓foo = foo * 1 ``` ```swift -↓foo = foo - aVariable - +↓foo = foo / aVariable ``` ```swift ↓foo = foo - bar.method() - ``` ```swift ↓foo.aProperty = foo.aProperty - 1 - -``` - -```swift -↓self.aProperty = self.aProperty - 1 - -``` - -```swift -↓foo = foo / 1 - -``` - -```swift -↓foo = foo / aVariable - -``` - -```swift -↓foo = foo / bar.method() - -``` - -```swift -↓foo.aProperty = foo.aProperty / 1 - -``` - -```swift -↓self.aProperty = self.aProperty / 1 - -``` - -```swift -↓foo = foo + 1 - -``` - -```swift -↓foo = foo + aVariable - -``` - -```swift -↓foo = foo + bar.method() - -``` - -```swift -↓foo.aProperty = foo.aProperty + 1 - -``` - -```swift -↓self.aProperty = self.aProperty + 1 - -``` - -```swift -↓foo = foo * 1 - -``` - -```swift -↓foo = foo * aVariable - -``` - -```swift -↓foo = foo * bar.method() - -``` - -```swift -↓foo.aProperty = foo.aProperty * 1 - ``` ```swift ↓self.aProperty = self.aProperty * 1 - ``` ```swift diff --git a/docs/description/single_test_class.md b/docs/description/single_test_class.md index 2b78337..c111365 100644 --- a/docs/description/single_test_class.md +++ b/docs/description/single_test_class.md @@ -37,17 +37,14 @@ Test files should contain a single QuickSpec or XCTestCase class. ```swift class FooTests { } - ``` ```swift class FooTests: QuickSpec { } - ``` ```swift class FooTests: XCTestCase { } - ``` ## Triggering Examples diff --git a/docs/description/sorted_first_last.md b/docs/description/sorted_first_last.md index 19aee1b..47f16de 100644 --- a/docs/description/sorted_first_last.md +++ b/docs/description/sorted_first_last.md @@ -29,27 +29,22 @@ Prefer using `min()` or `max()` over `sorted().first` or `sorted().last` ```swift let min = myList.min() - ``` ```swift let min = myList.min(by: { $0 < $1 }) - ``` ```swift let min = myList.min(by: >) - ``` ```swift let max = myList.max() - ``` ```swift let max = myList.max(by: { $0 < $1 }) - ``` ```swift @@ -104,65 +99,52 @@ myList.sorted().last { $0 == key } ```swift ↓myList.sorted().first - ``` ```swift ↓myList.sorted(by: { $0.description < $1.description }).first - ``` ```swift ↓myList.sorted(by: >).first - ``` ```swift ↓myList.map { $0 + 1 }.sorted().first - ``` ```swift ↓myList.sorted(by: someFunction).first - ``` ```swift ↓myList.map { $0 + 1 }.sorted { $0.description < $1.description }.first - ``` ```swift ↓myList.sorted().last - ``` ```swift ↓myList.sorted().last?.something() - ``` ```swift ↓myList.sorted(by: { $0.description < $1.description }).last - ``` ```swift ↓myList.map { $0 + 1 }.sorted().last - ``` ```swift ↓myList.sorted(by: someFunction).last - ``` ```swift ↓myList.map { $0 + 1 }.sorted { $0.description < $1.description }.last - ``` ```swift ↓myList.map { $0 + 1 }.sorted { $0.first < $1.first }.last - ``` \ No newline at end of file diff --git a/docs/description/superfluous_disable_command.md b/docs/description/superfluous_disable_command.md index fbe85b2..4746f93 100644 --- a/docs/description/superfluous_disable_command.md +++ b/docs/description/superfluous_disable_command.md @@ -23,4 +23,28 @@ SwiftLint 'disable' commands are superfluous when the disabled rule would not ha - \ No newline at end of file + + +## Non Triggering Examples + +```swift +let abc:Void // swiftlint:disable:this colon +``` + +```swift +// swiftlint:disable colon +let abc:Void +// swiftlint:enable colon +``` + +## Triggering Examples + +```swift +let abc: Void // swiftlint:disable:this colon +``` + +```swift +// swiftlint:disable colon +let abc: Void +// swiftlint:enable colon +``` \ No newline at end of file diff --git a/docs/description/switch_case_alignment.md b/docs/description/switch_case_alignment.md index a0298d9..d51122a 100644 --- a/docs/description/switch_case_alignment.md +++ b/docs/description/switch_case_alignment.md @@ -1,6 +1,6 @@ # Switch and Case Statement Alignment -Case statements should vertically align with their enclosing switch statement, or indented if configured otherwise. +Case statements should vertically align with their closing brace, or indented if configured otherwise. * **Identifier:** switch_case_alignment * **Enabled by default:** Yes @@ -77,9 +77,11 @@ default: ``` ```swift -let a = switch i { +func f() -> Int { + return switch i { case 1: 1 default: 2 + } } ``` @@ -116,6 +118,13 @@ switch someInt { } ``` +```swift +let a = switch i { + ↓case 1: 1 + ↓default: 2 +} +``` + ```swift switch someBool { case true: @@ -134,4 +143,11 @@ if aBool { print('blue') } } +``` + +```swift +let a = switch i { +case 1: 1 + ↓default: 2 +} ``` \ No newline at end of file diff --git a/docs/description/switch_case_on_newline.md b/docs/description/switch_case_on_newline.md index d8c248d..68c2a7e 100644 --- a/docs/description/switch_case_on_newline.md +++ b/docs/description/switch_case_on_newline.md @@ -129,7 +129,6 @@ return false switch foo { case #selector(aFunction(_:)): return false - } ``` @@ -181,7 +180,6 @@ switch foo { ```swift switch foo { ↓case #selector(aFunction(_:)): return false - } ``` diff --git a/docs/description/test_case_accessibility.md b/docs/description/test_case_accessibility.md index 0725e91..9630fe6 100644 --- a/docs/description/test_case_accessibility.md +++ b/docs/description/test_case_accessibility.md @@ -92,6 +92,16 @@ class FooTests: XCTestCase { } ``` +```swift +class FooTests: XCTestCase { + override init() { + super.init() + let foo = 1 + var bar = 2 + } +} +``` + ```swift class FooTests: XCTestCase { func allowedPrefixTestFoo() {} diff --git a/docs/description/todo.md b/docs/description/todo.md index 03980fa..d89bfdf 100644 --- a/docs/description/todo.md +++ b/docs/description/todo.md @@ -29,52 +29,42 @@ TODOs and FIXMEs should be resolved. ```swift // notaTODO: - ``` ```swift // notaFIXME: - ``` ## Triggering Examples ```swift // ↓TODO: - ``` ```swift // ↓FIXME: - ``` ```swift // ↓TODO(note) - ``` ```swift // ↓FIXME(note) - ``` ```swift /* ↓FIXME: */ - ``` ```swift /* ↓TODO: */ - ``` ```swift /** ↓FIXME: */ - ``` ```swift /** ↓TODO: */ - ``` \ No newline at end of file diff --git a/docs/description/toggle_bool.md b/docs/description/toggle_bool.md index 3b13186..99a4c68 100644 --- a/docs/description/toggle_bool.md +++ b/docs/description/toggle_bool.md @@ -29,12 +29,10 @@ Prefer `someBool.toggle()` over `someBool = !someBool` ```swift isHidden.toggle() - ``` ```swift view.clipsToBounds.toggle() - ``` ```swift @@ -43,12 +41,10 @@ func foo() { abc.toggle() } ```swift view.clipsToBounds = !clipsToBounds - ``` ```swift disconnected = !connected - ``` ```swift @@ -59,12 +55,10 @@ result = !result.toggle() ```swift ↓isHidden = !isHidden - ``` ```swift ↓view.clipsToBounds = !view.clipsToBounds - ``` ```swift diff --git a/docs/description/trailing_closure.md b/docs/description/trailing_closure.md index edf1d5a..67f8fd5 100644 --- a/docs/description/trailing_closure.md +++ b/docs/description/trailing_closure.md @@ -37,32 +37,26 @@ Trailing closure syntax should be used whenever possible ```swift foo.map { $0 + 1 } - ``` ```swift foo.bar() - ``` ```swift foo.reduce(0) { $0 + 1 } - ``` ```swift if let foo = bar.map({ $0 + 1 }) { } - ``` ```swift foo.something(param1: { $0 }, param2: { $0 + 1 }) - ``` ```swift offsets.sorted { $0.offset < $1.offset } - ``` ```swift @@ -81,20 +75,16 @@ foo.something(0, { return 1 }()) ```swift ↓foo.map({ $0 + 1 }) - ``` ```swift ↓foo.reduce(0, combine: { $0 + 1 }) - ``` ```swift ↓offsets.sorted(by: { $0.offset < $1.offset }) - ``` ```swift ↓foo.something(0, { $0 + 1 }) - ``` \ No newline at end of file diff --git a/docs/description/trailing_comma.md b/docs/description/trailing_comma.md index a945b4c..5c37989 100644 --- a/docs/description/trailing_comma.md +++ b/docs/description/trailing_comma.md @@ -37,27 +37,22 @@ Trailing commas in arrays and dictionaries should be avoided/enforced. ```swift let foo = [1, 2, 3] - ``` ```swift let foo = [] - ``` ```swift let foo = [:] - ``` ```swift let foo = [1: 2, 2: 3] - ``` ```swift let foo = [Void]() - ``` ```swift @@ -69,46 +64,38 @@ let example = [ 1, ```swift foo([1: "\(error)"]) - ``` ```swift let foo = [Int]() - ``` ## Triggering Examples ```swift let foo = [1, 2, 3↓,] - ``` ```swift let foo = [1, 2, 3↓, ] - ``` ```swift let foo = [1, 2, 3 ↓,] - ``` ```swift let foo = [1: 2, 2: 3↓, ] - ``` ```swift struct Bar { let foo = [1: 2, 2: 3↓, ] } - ``` ```swift let foo = [1, 2, 3↓,] + [4, 5, 6↓,] - ``` ```swift @@ -120,7 +107,6 @@ let example = [ 1, ```swift let foo = ["אבג", "αβγ", "🇺🇸"↓,] - ``` ```swift @@ -135,5 +121,4 @@ class C { ```swift foo([1: "\(error)"↓,]) - ``` \ No newline at end of file diff --git a/docs/description/trailing_semicolon.md b/docs/description/trailing_semicolon.md index 2b15404..6ecc4d3 100644 --- a/docs/description/trailing_semicolon.md +++ b/docs/description/trailing_semicolon.md @@ -29,7 +29,6 @@ Lines should not have trailing semicolons ```swift let a = 0 - ``` ```swift @@ -46,7 +45,6 @@ let a = 0↓; ```swift let a = 0↓; let b = 1 - ``` ```swift diff --git a/docs/description/type_body_length.md b/docs/description/type_body_length.md index de49b47..2515741 100644 --- a/docs/description/type_body_length.md +++ b/docs/description/type_body_length.md @@ -1058,8 +1058,7 @@ let abc = 0 /* this is a multiline comment -*/ -} +*/} ``` @@ -2086,8 +2085,7 @@ let abc = 0 /* this is a multiline comment -*/ -} +*/} ``` @@ -3114,8 +3112,7 @@ let abc = 0 /* this is a multiline comment -*/ -} +*/} ``` @@ -4142,8 +4139,7 @@ let abc = 0 /* this is a multiline comment -*/ -} +*/} ``` diff --git a/docs/description/unneeded_override.md b/docs/description/unneeded_override.md new file mode 100644 index 0000000..29719ef --- /dev/null +++ b/docs/description/unneeded_override.md @@ -0,0 +1,207 @@ +# Unneeded Overridden Functions + +Remove overridden functions that don't do anything except call their super + +* **Identifier:** unneeded_override +* **Enabled by default:** Yes +* **Supports autocorrection:** Yes +* **Kind:** lint +* **Analyzer rule:** No +* **Minimum Swift compiler version:** 5.0.0 +* **Default configuration:** + + + + + + + + + + +
KeyValue
+ severity + + warning +
+ +## Non Triggering Examples + +```swift +class Foo { + override func bar() { + super.bar() + print("hi") + } +} +``` + +```swift +class Foo { + @available(*, unavailable) + override func bar() { + super.bar() + } +} +``` + +```swift +class Foo { + override func bar() { + super.bar() + super.bar() + } +} +``` + +```swift +class Foo { + override func bar() throws { + // Doing a different variation of 'try' changes behavior + try! super.bar() + } +} +``` + +```swift +class Foo { + override func bar() throws { + // Doing a different variation of 'try' changes behavior + try? super.bar() + } +} +``` + +```swift +class Foo { + override func bar() async throws { + // Doing a different variation of 'try' changes behavior + await try! super.bar() + } +} +``` + +```swift +class Foo { + override func bar(arg: Bool) { + // Flipping the argument changes behavior + super.bar(arg: !arg) + } +} +``` + +```swift +class Foo { + override func bar(_ arg: Int) { + // Changing the argument changes behavior + super.bar(arg + 1) + } +} +``` + +```swift +class Foo { + override func bar(arg: Int) { + // Changing the argument changes behavior + super.bar(arg: arg.var) + } +} +``` + +```swift +class Foo { + override func bar(_ arg: Int) { + // Not passing arguments because they have default values changes behavior + super.bar() + } +} +``` + +```swift +class Foo { + override func bar(arg: Int, _ arg3: Bool) { + // Calling a super function with different argument labels changes behavior + super.bar(arg2: arg, arg3: arg3) + } +} +``` + +```swift +class Foo { + override func bar(animated: Bool, completion: () -> Void) { + super.bar(animated: animated) { + // This likely changes behavior + } + } +} +``` + +```swift +class Foo { + override func bar(animated: Bool, completion: () -> Void) { + super.bar(animated: animated, completion: { + // This likely changes behavior + }) + } +} +``` + +## Triggering Examples + +```swift +class Foo { + ↓override func bar() { + super.bar() + } +} +``` + +```swift +class Foo { + ↓override func bar() { + return super.bar() + } +} +``` + +```swift +class Foo { + ↓override func bar() { + super.bar() + // comments don't affect this + } +} +``` + +```swift +class Foo { + ↓override func bar() async { + await super.bar() + } +} +``` + +```swift +class Foo { + ↓override func bar() throws { + try super.bar() + // comments don't affect this + } +} +``` + +```swift +class Foo { + ↓override func bar(arg: Bool) throws { + try super.bar(arg: arg) + } +} +``` + +```swift +class Foo { + ↓override func bar(animated: Bool, completion: () -> Void) { + super.bar(animated: animated, completion: completion) + } +} +``` \ No newline at end of file diff --git a/docs/description/unneeded_parentheses_in_closure_argument.md b/docs/description/unneeded_parentheses_in_closure_argument.md index 2793742..c232d69 100644 --- a/docs/description/unneeded_parentheses_in_closure_argument.md +++ b/docs/description/unneeded_parentheses_in_closure_argument.md @@ -29,22 +29,18 @@ Parentheses are not needed when declaring closure arguments ```swift let foo = { (bar: Int) in } - ``` ```swift let foo = { bar, _ in } - ``` ```swift let foo = { bar in } - ``` ```swift let foo = { bar -> Bool in return true } - ``` ```swift @@ -57,17 +53,14 @@ DispatchQueue.main.async { () -> Void in ```swift call(arg: { ↓(bar) in }) - ``` ```swift call(arg: { ↓(bar, _) in }) - ``` ```swift let foo = { ↓(bar) -> Bool in return true } - ``` ```swift diff --git a/docs/description/unneeded_synthesized_initializer.md b/docs/description/unneeded_synthesized_initializer.md index d189482..ba5f4e2 100644 --- a/docs/description/unneeded_synthesized_initializer.md +++ b/docs/description/unneeded_synthesized_initializer.md @@ -370,4 +370,16 @@ struct Outer { } } } +``` + +```swift +class Foo { + struct Bar { + let baz: Int + + ↓init(baz: Int) { + self.baz = baz + } + } +} ``` \ No newline at end of file diff --git a/docs/description/unused_closure_parameter.md b/docs/description/unused_closure_parameter.md index e115054..445f172 100644 --- a/docs/description/unused_closure_parameter.md +++ b/docs/description/unused_closure_parameter.md @@ -29,75 +29,65 @@ Unused parameter in a closure should be replaced with _ ```swift [1, 2].map { $0 + 1 } - ``` ```swift [1, 2].map({ $0 + 1 }) - ``` ```swift [1, 2].map { number in number + 1 } - ``` ```swift [1, 2].map { _ in 3 } - ``` ```swift [1, 2].something { number, idx in return number * idx } - ``` ```swift let isEmpty = [1, 2].isEmpty() - ``` ```swift violations.sorted(by: { lhs, rhs in return lhs.location > rhs.location }) - ``` ```swift rlmConfiguration.migrationBlock.map { rlmMigration in -return { migration, schemaVersion in -rlmMigration(migration.rlmMigration, schemaVersion) -} + return { migration, schemaVersion in + rlmMigration(migration.rlmMigration, schemaVersion) + } } ``` ```swift genericsFunc { (a: Type, b) in -a + b + a + b } - ``` ```swift var label: UILabel = { (lbl: UILabel) -> UILabel in - lbl.backgroundColor = .red - return lbl + lbl.backgroundColor = .red + return lbl }(UILabel()) - ``` ```swift hoge(arg: num) { num in - return num + return num } - ``` ```swift @@ -152,62 +142,49 @@ let closure: (Int) -> Void = { foo in _ = `foo` } ```swift [1, 2].map { ↓number in - return 3 -} - + return 3 } ``` ```swift [1, 2].map { ↓number in - return numberWithSuffix -} - + return numberWithSuffix } ``` ```swift [1, 2].map { ↓number in - return 3 // number -} - + return 3 // number } ``` ```swift [1, 2].map { ↓number in - return 3 "number" -} - + return 3 "number" } ``` ```swift [1, 2].something { number, ↓idx in - return number -} - + return number } ``` ```swift -genericsFunc { (↓number: TypeA, idx: TypeB) in return idx -} +genericsFunc { (↓number: TypeA, idx: TypeB) in return idx } +``` +```swift +let c: (Int) -> Void = { foo in _ = .foo } ``` ```swift hoge(arg: num) { ↓num in } - ``` ```swift -fooFunc { ↓아 in - } +fooFunc { ↓아 in } ``` ```swift func foo () { - bar { ↓number in - return 3 -} - + bar { ↓number in return 3 } ``` ```swift diff --git a/docs/description/unused_enumerated.md b/docs/description/unused_enumerated.md index 7bd9eee..f66e3a1 100644 --- a/docs/description/unused_enumerated.md +++ b/docs/description/unused_enumerated.md @@ -29,67 +29,54 @@ When the index or the item is not used, `.enumerated()` can be removed. ```swift for (idx, foo) in bar.enumerated() { } - ``` ```swift for (_, foo) in bar.enumerated().something() { } - ``` ```swift for (_, foo) in bar.something() { } - ``` ```swift for foo in bar.enumerated() { } - ``` ```swift for foo in bar { } - ``` ```swift for (idx, _) in bar.enumerated().something() { } - ``` ```swift for (idx, _) in bar.something() { } - ``` ```swift for idx in bar.indices { } - ``` ```swift for (section, (event, _)) in data.enumerated() {} - ``` ## Triggering Examples ```swift for (↓_, foo) in bar.enumerated() { } - ``` ```swift for (↓_, foo) in abc.bar.enumerated() { } - ``` ```swift for (↓_, foo) in abc.something().enumerated() { } - ``` ```swift for (idx, ↓_) in bar.enumerated() { } - ``` \ No newline at end of file diff --git a/docs/description/unused_optional_binding.md b/docs/description/unused_optional_binding.md index b755e2b..2a56e05 100644 --- a/docs/description/unused_optional_binding.md +++ b/docs/description/unused_optional_binding.md @@ -36,31 +36,23 @@ Prefer `!= nil` over `let _ =` ## Non Triggering Examples ```swift -if let bar = Foo.optionalValue { -} - +if let bar = Foo.optionalValue {} ``` ```swift -if let (_, second) = getOptionalTuple() { -} - +if let (_, second) = getOptionalTuple() {} ``` ```swift -if let (_, asd, _) = getOptionalTuple(), let bar = Foo.optionalValue { -} - +if let (_, asd, _) = getOptionalTuple(), let bar = Foo.optionalValue {} ``` ```swift if foo() { let _ = bar() } - ``` ```swift if foo() { _ = bar() } - ``` ```swift @@ -74,50 +66,33 @@ if let point = state.find({ _ in true }) {} ## Triggering Examples ```swift -if let ↓_ = Foo.optionalValue { -} - +if let ↓_ = Foo.optionalValue {} ``` ```swift -if let a = Foo.optionalValue, let ↓_ = Foo.optionalValue2 { -} - +if let a = Foo.optionalValue, let ↓_ = Foo.optionalValue2 {} ``` ```swift -guard let a = Foo.optionalValue, let ↓_ = Foo.optionalValue2 { -} - +guard let a = Foo.optionalValue, let ↓_ = Foo.optionalValue2 {} ``` ```swift -if let (first, second) = getOptionalTuple(), let ↓_ = Foo.optionalValue { -} - +if let (first, second) = getOptionalTuple(), let ↓_ = Foo.optionalValue {} ``` ```swift -if let (first, _) = getOptionalTuple(), let ↓_ = Foo.optionalValue { -} - +if let (first, _) = getOptionalTuple(), let ↓_ = Foo.optionalValue {} ``` ```swift -if let (_, second) = getOptionalTuple(), let ↓_ = Foo.optionalValue { -} - +if let (_, second) = getOptionalTuple(), let ↓_ = Foo.optionalValue {} ``` ```swift -if let ↓(_, _, _) = getOptionalTuple(), let bar = Foo.optionalValue { -} - +if let ↓(_, _, _) = getOptionalTuple(), let bar = Foo.optionalValue {} ``` ```swift -func foo() { -if let ↓_ = bar { -} - +func foo() { if let ↓_ = bar {} } ``` \ No newline at end of file diff --git a/docs/description/vertical_whitespace_closing_braces.md b/docs/description/vertical_whitespace_closing_braces.md index ae2b6c0..81abc79 100644 --- a/docs/description/vertical_whitespace_closing_braces.md +++ b/docs/description/vertical_whitespace_closing_braces.md @@ -50,23 +50,14 @@ do { ``` ```swift -print([foo { - var sum = 0 - for i in 1...5 { sum += i } - return sum - -}, foo { - var mul = 1 - for i in 1...5 { mul *= i } - return mul -}]) +do { + print("x is 5") +} ``` ```swift -func foo() { - run(5) { x in - print(x) - } +do { + print("x is 5") } ``` @@ -77,6 +68,14 @@ foo( ) ``` +```swift +func foo() { + run(5) { x in + print(x) + } +} +``` + ```swift print([ 1 @@ -84,15 +83,16 @@ print([ ``` ```swift -do { - print("x is 5") -} -``` +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum -```swift -do { - print("x is 5") -} +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul +}]) ``` ```swift @@ -113,22 +113,6 @@ do { */ ``` -```swift -if bool1 { - // do something - // do something - -} else if bool2 { - // do something - // do something - // do something - -} else { - // do something - // do something -} -``` - ## Triggering Examples ```swift @@ -144,29 +128,21 @@ if bool1 { do { print("x is 5") ↓ - + } ``` ```swift -print([foo { - var sum = 0 - for i in 1...5 { sum += i } - return sum - -}, foo { - var mul = 1 - for i in 1...5 { mul *= i } - return mul +do { + print("x is 5") ↓ -}]) + +} ``` ```swift -func foo() { - run(5) { x in - print(x) - } +do { + print("x is 5") ↓ } ``` @@ -180,23 +156,31 @@ foo( ``` ```swift -print([ - 1 +func foo() { + run(5) { x in + print(x) + } ↓ -]) +} ``` ```swift -do { - print("x is 5") +print([ + 1 ↓ - -} +]) ``` ```swift -do { - print("x is 5") +print([foo { + var sum = 0 + for i in 1...5 { sum += i } + return sum + +}, foo { + var mul = 1 + for i in 1...5 { mul *= i } + return mul ↓ -} +}]) ``` \ No newline at end of file diff --git a/docs/description/void_return.md b/docs/description/void_return.md index 5a58166..e8f306a 100644 --- a/docs/description/void_return.md +++ b/docs/description/void_return.md @@ -29,107 +29,86 @@ Prefer `-> Void` over `-> ()` ```swift let abc: () -> Void = {} - ``` ```swift let abc: () -> (VoidVoid) = {} - ``` ```swift func foo(completion: () -> Void) - ``` ```swift let foo: (ConfigurationTests) -> () throws -> Void - ``` ```swift let foo: (ConfigurationTests) -> () throws -> Void - ``` ```swift let foo: (ConfigurationTests) ->() throws -> Void - ``` ```swift let foo: (ConfigurationTests) -> () -> Void - ``` ```swift let foo: () -> () async -> Void - ``` ```swift let foo: () -> () async throws -> Void - ``` ```swift let foo: () -> () async -> Void - ``` ```swift func foo() -> () async throws -> Void {} - ``` ```swift func foo() async throws -> () async -> Void { return {} } - ``` ## Triggering Examples ```swift let abc: () -> ↓() = {} - ``` ```swift let abc: () -> ↓(Void) = {} - ``` ```swift let abc: () -> ↓( Void ) = {} - ``` ```swift func foo(completion: () -> ↓()) - ``` ```swift func foo(completion: () -> ↓( )) - ``` ```swift func foo(completion: () -> ↓(Void)) - ``` ```swift let foo: (ConfigurationTests) -> () throws -> ↓() - ``` ```swift func foo() async -> ↓() - ``` ```swift func foo() async throws -> ↓() - ``` \ No newline at end of file diff --git a/docs/description/weak_delegate.md b/docs/description/weak_delegate.md index 6a5dda4..817b76b 100644 --- a/docs/description/weak_delegate.md +++ b/docs/description/weak_delegate.md @@ -31,49 +31,42 @@ Delegates should be weak to avoid reference cycles class Foo { weak var delegate: SomeProtocol? } - ``` ```swift class Foo { weak var someDelegate: SomeDelegateProtocol? } - ``` ```swift class Foo { weak var delegateScroll: ScrollDelegate? } - ``` ```swift class Foo { var scrollHandler: ScrollDelegate? } - ``` ```swift func foo() { var delegate: SomeDelegate } - ``` ```swift class Foo { var delegateNotified: Bool? } - ``` ```swift protocol P { var delegate: AnyObject? { get set } } - ``` ```swift @@ -82,7 +75,6 @@ class Foo { var delegate: AnyObject? { get set } } } - ``` ```swift @@ -135,14 +127,12 @@ class Foo { class Foo { ↓var delegate: SomeProtocol? } - ``` ```swift class Foo { ↓var scrollDelegate: ScrollDelegate? } - ``` ```swift diff --git a/docs/description/yoda_condition.md b/docs/description/yoda_condition.md index b4860d7..1a0be33 100644 --- a/docs/description/yoda_condition.md +++ b/docs/description/yoda_condition.md @@ -29,17 +29,14 @@ The constant literal should be placed on the right-hand side of the comparison o ```swift if foo == 42 {} - ``` ```swift if foo <= 42.42 {} - ``` ```swift guard foo >= 42 else { return } - ``` ```swift @@ -48,12 +45,10 @@ guard foo != "str str" else { return } ```swift while foo < 10 { } - ``` ```swift while foo > 1 { } - ``` ```swift @@ -76,17 +71,14 @@ if flags & 1 == 1 {} ```swift if ↓42 == foo {} - ``` ```swift if ↓42.42 >= foo {} - ``` ```swift guard ↓42 <= foo else { return } - ``` ```swift diff --git a/docs/patterns.json b/docs/patterns.json index 6bb64b8..d755883 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -1,6 +1,6 @@ { "name" : "swiftlint", - "version" : "0.52.4", + "version" : "0.53.0", "patterns" : [ { "patternId" : "accessibility_label_for_image", "level" : "Info", @@ -869,6 +869,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "non_overridable_class_declaration", + "level" : "Info", + "category" : "CodeStyle", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "notification_center_detachment", "level" : "Info", @@ -1044,6 +1051,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : false + }, { + "patternId" : "private_swiftui_state", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : false }, { "patternId" : "private_unit_test", "level" : "Info", @@ -1436,6 +1450,13 @@ "parameters" : [ ], "languages" : [ ], "enabled" : true + }, { + "patternId" : "unneeded_override", + "level" : "Info", + "category" : "ErrorProne", + "parameters" : [ ], + "languages" : [ ], + "enabled" : true }, { "patternId" : "unneeded_parentheses_in_closure_argument", "level" : "Info", From 3e170563d0b673258c18eb9de52ffdf9355faffa Mon Sep 17 00:00:00 2001 From: Stefan Vacareanu Date: Wed, 22 Nov 2023 15:36:14 +0200 Subject: [PATCH 094/119] Bump to 0.54.0 --- .circleci/config.yml | 2 +- Dockerfile.dev | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 07a942f..ca2f018 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codacy: codacy/base@10.8.0 + codacy: codacy/base@10.11.1 codacy_plugins_test: codacy/plugins-test@1.1.1 workflows: diff --git a/Dockerfile.dev b/Dockerfile.dev index 3f859b6..e2450d1 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM norionomura/swiftlint:0.53.0_swift-5.9 +FROM norionomura/swiftlint:0.54.0_swift-5.9 RUN apt-get update && apt-get install -y openjdk-8-jre-headless From 176ba84b0c9555431f299d473b92593c7abe2685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Thu, 7 Dec 2023 17:22:36 +0000 Subject: [PATCH 095/119] change swiftlint base image --- .gitignore | 1 + Dockerfile | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8f82c4b..0025cc8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ target .bloop .vscode .bsp +metals.sbt \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4c58549..bdeca1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,6 @@ FROM codacy-swiftlint-dev as builder -FROM swift:5.9.0-jammy-slim - -COPY --from=builder /usr/bin/swiftlint /usr/bin/swiftlint -COPY --from=builder /usr/lib/libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so +FROM ghcr.io/realm/swiftlint:0.54.0 COPY --from=builder /docs /docs COPY target/native-image/codacy-swiftlint /workdir/ From 9a5e50420b02542cbfc9438de5fbb1c54f26e90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Thu, 7 Dec 2023 18:04:26 +0000 Subject: [PATCH 096/119] fix fallthrough test and config file key --- docs/multiple-tests/filter-files/src/.swiftlint.yml | 2 +- docs/multiple-tests/multiple-files/src/.swiftlint.yml | 2 +- docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml | 2 +- docs/multiple-tests/with-config/src/.swiftlint.yml | 2 +- docs/tests/fallthrough.swift | 9 +++++---- docs/tests/scriptFile.scala | 1 - src/main/scala/codacy/swiftlint/SwiftLint.scala | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 docs/tests/scriptFile.scala diff --git a/docs/multiple-tests/filter-files/src/.swiftlint.yml b/docs/multiple-tests/filter-files/src/.swiftlint.yml index 9744d80..8807964 100644 --- a/docs/multiple-tests/filter-files/src/.swiftlint.yml +++ b/docs/multiple-tests/filter-files/src/.swiftlint.yml @@ -1,3 +1,3 @@ -whitelist_rules: +only_rules: - closing_brace - dynamic_inline diff --git a/docs/multiple-tests/multiple-files/src/.swiftlint.yml b/docs/multiple-tests/multiple-files/src/.swiftlint.yml index 9744d80..8807964 100644 --- a/docs/multiple-tests/multiple-files/src/.swiftlint.yml +++ b/docs/multiple-tests/multiple-files/src/.swiftlint.yml @@ -1,3 +1,3 @@ -whitelist_rules: +only_rules: - closing_brace - dynamic_inline diff --git a/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml b/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml index 750359b..22259b0 100644 --- a/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml +++ b/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml @@ -1,2 +1,2 @@ -whitelist_rules: +only_rules: - closing_brace diff --git a/docs/multiple-tests/with-config/src/.swiftlint.yml b/docs/multiple-tests/with-config/src/.swiftlint.yml index 750359b..22259b0 100644 --- a/docs/multiple-tests/with-config/src/.swiftlint.yml +++ b/docs/multiple-tests/with-config/src/.swiftlint.yml @@ -1,2 +1,2 @@ -whitelist_rules: +only_rules: - closing_brace diff --git a/docs/tests/fallthrough.swift b/docs/tests/fallthrough.swift index 22d38c4..21c1fb0 100644 --- a/docs/tests/fallthrough.swift +++ b/docs/tests/fallthrough.swift @@ -4,9 +4,10 @@ -switch foo { -case .bar: +switch myvar { +case 1: + var a = 1 fallthrough -case .bar2: - something() +case 2: + var a = 2 } diff --git a/docs/tests/scriptFile.scala b/docs/tests/scriptFile.scala deleted file mode 100644 index 6ce71f7..0000000 --- a/docs/tests/scriptFile.scala +++ /dev/null @@ -1 +0,0 @@ -closure_end_indentation \ No newline at end of file diff --git a/src/main/scala/codacy/swiftlint/SwiftLint.scala b/src/main/scala/codacy/swiftlint/SwiftLint.scala index 05907f5..78610ba 100755 --- a/src/main/scala/codacy/swiftlint/SwiftLint.scala +++ b/src/main/scala/codacy/swiftlint/SwiftLint.scala @@ -125,7 +125,7 @@ object SwiftLint extends Tool { private def writeConfigFile(patternsToLint: List[Pattern.Definition]): Path = { val rules = patternsToLint.map(_.patternId.toString) val content = - s"""whitelist_rules: + s"""only_rules: | - ${rules.mkString("\n - ")}\n """.stripMargin From 6424761c772766b134306f97f3ffbb735fab33e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Thu, 7 Dec 2023 18:47:07 +0000 Subject: [PATCH 097/119] fix: docgenerator severity parse --- .../src/main/scala/doc-generator.scala | 12 +- docs/description/redundant_self_in_closure.md | 24 ++++ docs/description/unused_declaration.md | 110 ++++++++++++++++++ docs/patterns.json | 20 ++-- docs/tests/control_statement.swift | 8 +- docs/tests/fallthrough.swift | 2 +- docs/tests/multiline_arguments.swift | 4 +- 7 files changed, 158 insertions(+), 22 deletions(-) diff --git a/doc-generator/src/main/scala/doc-generator.scala b/doc-generator/src/main/scala/doc-generator.scala index 0375b6b..3ab06a5 100644 --- a/doc-generator/src/main/scala/doc-generator.scala +++ b/doc-generator/src/main/scala/doc-generator.scala @@ -53,11 +53,13 @@ object Main extends App { ) } - def configurationToLevel(kind: String) = kind match { - case "warning" => Result.Level.Warn - case "error" => Result.Level.Err - case _ => Result.Level.Info - } + def configurationToLevel(kind: String) = + Option(kind) + .collectFirst { + case s if s.startsWith("warning") => Result.Level.Warn + case s if s.startsWith("error") => Result.Level.Err + } + .getOrElse(Result.Level.Info) def kindToCategory(kind: String) = kind match { case "style" => Pattern.Category.CodeStyle diff --git a/docs/description/redundant_self_in_closure.md b/docs/description/redundant_self_in_closure.md index 8276f69..adf6716 100644 --- a/docs/description/redundant_self_in_closure.md +++ b/docs/description/redundant_self_in_closure.md @@ -192,4 +192,28 @@ Explicit use of 'self' is not required } } } +``` + +```swift + class C { + var x = 0 + func f(_ work: @escaping () -> Void) { work() } + func g() { + f { [weak self] in + self?.x = 1 + guard let self else { return } + ↓self.x = 1 + } + f { [weak self] in + self?.x = 1 + if let self = self else { ↓self.x = 1 } + self?.x = 1 + } + f { [weak self] in + self?.x = 1 + while let self else { ↓self.x = 1 } + self?.x = 1 + } + } + } ``` \ No newline at end of file diff --git a/docs/description/unused_declaration.md b/docs/description/unused_declaration.md index 9c025c7..971700d 100644 --- a/docs/description/unused_declaration.md +++ b/docs/description/unused_declaration.md @@ -180,6 +180,72 @@ acceptComponentBuilder { } ``` +```swift +import Cocoa + +@NSApplicationMain +final class AppDelegate: NSObject, NSApplicationDelegate { + func applicationWillFinishLaunching(_ notification: Notification) {} + func applicationWillBecomeActive(_ notification: Notification) {} +} +``` + +```swift +import Foundation + +public final class Foo: NSObject { + @IBAction private func foo() {} +} +``` + +```swift +import Foundation + +public final class Foo: NSObject { + @objc func foo() {} +} +``` + +```swift +import Foundation + +public final class Foo: NSObject { + @IBInspectable private var innerPaddingWidth: Int { + set { self.backgroundView.innerPaddingWidth = newValue } + get { return self.backgroundView.innerPaddingWidth } + } +} +``` + +```swift +import Foundation + +public final class Foo: NSObject { + @IBOutlet private var bar: NSObject! { + set { fatalError() } + get { fatalError() } + } + + @IBOutlet private var baz: NSObject! { + willSet { print("willSet") } + } + + @IBOutlet private var buzz: NSObject! { + didSet { print("didSet") } + } +} +``` + +```swift + struct S { + var i: Int? = nil + func f() { + if let i { print(i) } + } + } + S().f() +``` + ## Triggering Examples ```swift @@ -255,4 +321,48 @@ struct ComponentBuilder { } _ = ComponentBuilder() +``` + +```swift +import Cocoa + +@NSApplicationMain +final class AppDelegate: NSObject, NSApplicationDelegate { + func ↓appWillFinishLaunching(_ notification: Notification) {} + func applicationWillBecomeActive(_ notification: Notification) {} +} +``` + +```swift +import Cocoa + +final class ↓AppDelegate: NSObject, NSApplicationDelegate { + func applicationWillFinishLaunching(_ notification: Notification) {} + func applicationWillBecomeActive(_ notification: Notification) {} +} +``` + +```swift +import Foundation + +public final class Foo: NSObject { + @IBOutlet var ↓bar: NSObject! +} +``` + +```swift +import Foundation + +public final class Foo: NSObject { + @IBInspectable var ↓bar: String! +} +``` + +```swift +import Foundation + +final class Foo: NSObject {} +final class ↓Bar { + var ↓foo = Foo() +} ``` \ No newline at end of file diff --git a/docs/patterns.json b/docs/patterns.json index d755883..344392e 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -87,7 +87,7 @@ "enabled" : true }, { "patternId" : "closure_body_length", - "level" : "Info", + "level" : "Warning", "category" : "Complexity", "parameters" : [ ], "languages" : [ ], @@ -220,7 +220,7 @@ "enabled" : false }, { "patternId" : "cyclomatic_complexity", - "level" : "Info", + "level" : "Warning", "category" : "Complexity", "parameters" : [ ], "languages" : [ ], @@ -374,7 +374,7 @@ "enabled" : false }, { "patternId" : "enum_case_associated_values_count", - "level" : "Info", + "level" : "Warning", "category" : "Complexity", "parameters" : [ ], "languages" : [ ], @@ -458,7 +458,7 @@ "enabled" : false }, { "patternId" : "file_length", - "level" : "Info", + "level" : "Warning", "category" : "Complexity", "parameters" : [ ], "languages" : [ ], @@ -528,7 +528,7 @@ "enabled" : false }, { "patternId" : "function_body_length", - "level" : "Info", + "level" : "Warning", "category" : "Complexity", "parameters" : [ ], "languages" : [ ], @@ -542,7 +542,7 @@ "enabled" : false }, { "patternId" : "function_parameter_count", - "level" : "Info", + "level" : "Warning", "category" : "Complexity", "parameters" : [ ], "languages" : [ ], @@ -640,7 +640,7 @@ "enabled" : false }, { "patternId" : "large_tuple", - "level" : "Info", + "level" : "Warning", "category" : "Complexity", "parameters" : [ ], "languages" : [ ], @@ -724,7 +724,7 @@ "enabled" : false }, { "patternId" : "line_length", - "level" : "Info", + "level" : "Warning", "category" : "Complexity", "parameters" : [ ], "languages" : [ ], @@ -759,7 +759,7 @@ "enabled" : true }, { "patternId" : "missing_docs", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -1396,7 +1396,7 @@ "enabled" : true }, { "patternId" : "type_body_length", - "level" : "Info", + "level" : "Warning", "category" : "Complexity", "parameters" : [ ], "languages" : [ ], diff --git a/docs/tests/control_statement.swift b/docs/tests/control_statement.swift index 7e04643..85a4ccc 100644 --- a/docs/tests/control_statement.swift +++ b/docs/tests/control_statement.swift @@ -29,16 +29,16 @@ if ((min...max).contains(value)) { - for (item in collection) { - for (var index = 0; index < 42; index++) { - for(item in collection) { - for(var index = 0; index < 42; index++) { + + + + guard (condition) else { diff --git a/docs/tests/fallthrough.swift b/docs/tests/fallthrough.swift index 21c1fb0..e19281d 100644 --- a/docs/tests/fallthrough.swift +++ b/docs/tests/fallthrough.swift @@ -1,6 +1,6 @@ //#Patterns: fallthrough -//#Issue: {"severity": "Info", "line": 9, "patternId": "fallthrough"} +//#Issue: {"severity": "Info", "line": 10, "patternId": "fallthrough"} diff --git a/docs/tests/multiline_arguments.swift b/docs/tests/multiline_arguments.swift index 59851d8..960de1c 100644 --- a/docs/tests/multiline_arguments.swift +++ b/docs/tests/multiline_arguments.swift @@ -10,14 +10,14 @@ foo(0, - param1: 1, param2: true, ↓param3: [3]) + param1: 1, param2: true, param3: [3]) foo(0, param1: 1, param2: true, param3: [3]) -foo(0, param1: 1, ↓param2: true, +foo(0, param1: 1, param2: true, param3: [3]) From e161686452fcc548d9bdb0e005b3c71233c23967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Cort=C3=AAs?= Date: Thu, 7 Dec 2023 19:15:55 +0000 Subject: [PATCH 098/119] fix: doc generator severity --- .../src/main/scala/doc-generator.scala | 14 +- .../filter-files/src/closing_brace.swift | 4 +- .../filter-files/src/dynamic_inline.swift | 10 +- .../multiple-files/src/closing_brace.swift | 4 +- .../multiple-files/src/dynamic_inline.swift | 10 +- .../use-codacy-conf/src/closing_brace.swift | 4 +- .../use-codacy-conf/src/dynamic_inline.swift | 10 +- .../with-config/src/closing_brace.swift | 4 +- .../with-config/src/dynamic_inline.swift | 10 +- docs/patterns.json | 446 +++++++++--------- docs/tests/block_based_kvo.swift | 4 +- docs/tests/class_delegate_protocol.swift | 4 +- docs/tests/closing_brace.swift | 4 +- docs/tests/closure_end_indentation.swift | 6 +- docs/tests/colon.swift | 88 ++-- docs/tests/comma.swift | 10 +- docs/tests/compiler_protocol_init.swift | 4 +- .../conditional_returns_on_newline.swift | 10 +- docs/tests/control_statement.swift | 32 +- docs/tests/cyclomatic_complexity.swift | 2 +- ...scarded_notification_center_observer.swift | 6 +- docs/tests/discouraged_direct_init.swift | 20 +- docs/tests/discouraged_object_literal.swift | 4 +- docs/tests/dynamic_inline.swift | 10 +- docs/tests/empty_count.swift | 8 +- docs/tests/empty_parameters.swift | 8 +- ...ty_parentheses_with_trailing_closure.swift | 8 +- docs/tests/explicit_type_interface.swift | 8 +- docs/tests/fallthrough.swift | 2 +- docs/tests/fatal_error_message.swift | 4 +- docs/tests/file_length.swift | 2 +- docs/tests/for_where.swift | 2 +- docs/tests/force_cast.swift | 2 +- docs/tests/force_try.swift | 2 +- docs/tests/function_parameter_count.swift | 8 +- docs/tests/implicit_getter.swift | 10 +- docs/tests/is_disjoint.swift | 4 +- docs/tests/legacy_constant.swift | 20 +- docs/tests/legacy_constructor.swift | 40 +- docs/tests/legacy_nsgeometry_functions.swift | 42 +- docs/tests/line_length.swift | 6 +- docs/tests/mark.swift | 40 +- docs/tests/multiline_arguments.swift | 12 +- ...tiple_closures_with_trailing_closure.swift | 4 +- docs/tests/nesting.swift | 12 +- docs/tests/nimble_operator.swift | 18 +- docs/tests/no_extension_access_modifier.swift | 10 +- docs/tests/no_grouping_extension.swift | 8 +- .../notification_center_detachment.swift | 2 +- docs/tests/object_literal.swift | 32 +- docs/tests/operator_whitespace.swift | 12 +- docs/tests/overridden_super_call.swift | 6 +- docs/tests/override_in_extension.swift | 4 +- docs/tests/private_action.swift | 22 +- docs/tests/private_outlet.swift | 4 +- docs/tests/private_over_fileprivate.swift | 4 +- docs/tests/private_unit_test.swift | 8 +- docs/tests/prohibited_super_call.swift | 8 +- .../protocol_property_accessors_order.swift | 2 +- .../redundant_optional_initialization.swift | 8 +- docs/tests/redundant_void_return.swift | 8 +- docs/tests/return_arrow_whitespace.swift | 16 +- docs/tests/shorthand_operator.swift | 44 +- docs/tests/sorted_first_last.swift | 26 +- docs/tests/sorted_imports.swift | 2 +- docs/tests/statement_position.swift | 8 +- docs/tests/switch_case_alignment.swift | 10 +- docs/tests/todo.swift | 16 +- docs/tests/trailing_closure.swift | 8 +- docs/tests/trailing_comma.swift | 16 +- docs/tests/trailing_semicolon.swift | 10 +- docs/tests/type_name.swift | 44 +- ...eded_parentheses_in_closure_argument.swift | 10 +- docs/tests/unused_closure_parameter.swift | 16 +- docs/tests/unused_enumerated.swift | 8 +- docs/tests/valid_ibinspectable.swift | 18 +- docs/tests/vertical_parameter_alignment.swift | 8 +- docs/tests/vertical_whitespace.swift | 4 +- docs/tests/void_return.swift | 14 +- docs/tests/xctfail_message.swift | 4 +- docs/tests/yoda_condition.swift | 14 +- 81 files changed, 710 insertions(+), 706 deletions(-) diff --git a/doc-generator/src/main/scala/doc-generator.scala b/doc-generator/src/main/scala/doc-generator.scala index 3ab06a5..550affb 100644 --- a/doc-generator/src/main/scala/doc-generator.scala +++ b/doc-generator/src/main/scala/doc-generator.scala @@ -9,7 +9,8 @@ object Main extends App { println("Generated docs using swiftlint generate-docs") - val rulesOutput = os.proc("swiftlint", "rules").call().out.lines().map(_.split('|').map(_.trim).toList.tail).tail + val rulesOutput = + os.proc("swiftlint", "rules", "-v").call().out.lines().map(_.split('|').map(_.trim).toList.tail).tail val version = os.proc("swiftlint", "version").call().out.text().trim @@ -41,7 +42,7 @@ object Main extends App { ) val swiftLintRules = rulesOutput.tail - .filter(_.length == ids.size) + .filter(_.length > 0) .map { arr => def toBoolean(s: String) = s == "yes" SwiftlintRule( @@ -56,10 +57,10 @@ object Main extends App { def configurationToLevel(kind: String) = Option(kind) .collectFirst { - case s if s.startsWith("warning") => Result.Level.Warn - case s if s.startsWith("error") => Result.Level.Err + case s if s.startsWith("severity: error") => Result.Level.Err + case s if s.startsWith("severity: warning") => Result.Level.Warn } - .getOrElse(Result.Level.Info) + .getOrElse(Result.Level.Warn) def kindToCategory(kind: String) = kind match { case "style" => Pattern.Category.CodeStyle @@ -71,6 +72,9 @@ object Main extends App { val patternSpecifications = swiftLintRules.map { swiftLintRule => println(s"Generating patterns specification for ${swiftLintRule.identifier}") + println( + s"Converting severity ${swiftLintRule.configuration} => ${configurationToLevel(swiftLintRule.configuration)}" + ) Pattern.Specification( Pattern.Id(swiftLintRule.identifier), configurationToLevel(swiftLintRule.configuration), diff --git a/docs/multiple-tests/filter-files/src/closing_brace.swift b/docs/multiple-tests/filter-files/src/closing_brace.swift index 78c9abe..9196728 100644 --- a/docs/multiple-tests/filter-files/src/closing_brace.swift +++ b/docs/multiple-tests/filter-files/src/closing_brace.swift @@ -1,7 +1,7 @@ //#Patterns: closing_brace -//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} [].map({ } ) diff --git a/docs/multiple-tests/filter-files/src/dynamic_inline.swift b/docs/multiple-tests/filter-files/src/dynamic_inline.swift index a173305..da8e096 100644 --- a/docs/multiple-tests/filter-files/src/dynamic_inline.swift +++ b/docs/multiple-tests/filter-files/src/dynamic_inline.swift @@ -1,10 +1,10 @@ //#Patterns: dynamic_inline -//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "dynamic_inline"} class C { @inline(__always) dynamic func f() {} diff --git a/docs/multiple-tests/multiple-files/src/closing_brace.swift b/docs/multiple-tests/multiple-files/src/closing_brace.swift index 78c9abe..9196728 100644 --- a/docs/multiple-tests/multiple-files/src/closing_brace.swift +++ b/docs/multiple-tests/multiple-files/src/closing_brace.swift @@ -1,7 +1,7 @@ //#Patterns: closing_brace -//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} [].map({ } ) diff --git a/docs/multiple-tests/multiple-files/src/dynamic_inline.swift b/docs/multiple-tests/multiple-files/src/dynamic_inline.swift index a173305..da8e096 100644 --- a/docs/multiple-tests/multiple-files/src/dynamic_inline.swift +++ b/docs/multiple-tests/multiple-files/src/dynamic_inline.swift @@ -1,10 +1,10 @@ //#Patterns: dynamic_inline -//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "dynamic_inline"} class C { @inline(__always) dynamic func f() {} diff --git a/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift b/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift index 78c9abe..9196728 100644 --- a/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift +++ b/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift @@ -1,7 +1,7 @@ //#Patterns: closing_brace -//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} [].map({ } ) diff --git a/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift b/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift index a173305..da8e096 100644 --- a/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift +++ b/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift @@ -1,10 +1,10 @@ //#Patterns: dynamic_inline -//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "dynamic_inline"} class C { @inline(__always) dynamic func f() {} diff --git a/docs/multiple-tests/with-config/src/closing_brace.swift b/docs/multiple-tests/with-config/src/closing_brace.swift index 78c9abe..9196728 100644 --- a/docs/multiple-tests/with-config/src/closing_brace.swift +++ b/docs/multiple-tests/with-config/src/closing_brace.swift @@ -1,7 +1,7 @@ //#Patterns: closing_brace -//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} [].map({ } ) diff --git a/docs/multiple-tests/with-config/src/dynamic_inline.swift b/docs/multiple-tests/with-config/src/dynamic_inline.swift index a173305..da8e096 100644 --- a/docs/multiple-tests/with-config/src/dynamic_inline.swift +++ b/docs/multiple-tests/with-config/src/dynamic_inline.swift @@ -1,10 +1,10 @@ //#Patterns: dynamic_inline -//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "dynamic_inline"} class C { @inline(__always) dynamic func f() {} diff --git a/docs/patterns.json b/docs/patterns.json index 344392e..414ce31 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -3,84 +3,84 @@ "version" : "0.53.0", "patterns" : [ { "patternId" : "accessibility_label_for_image", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "accessibility_trait_for_button", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "anonymous_argument_in_multiline_closure", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "anyobject_protocol", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "array_init", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "attributes", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "balanced_xctest_lifecycle", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "blanket_disable_command", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "block_based_kvo", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "capture_variable", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "class_delegate_protocol", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "closing_brace", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -94,126 +94,126 @@ "enabled" : false }, { "patternId" : "closure_end_indentation", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "closure_parameter_position", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "closure_spacing", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "collection_alignment", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "colon", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "comma", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "comma_inheritance", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "comment_spacing", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "compiler_protocol_init", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "computed_accessors_order", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "conditional_returns_on_newline", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "contains_over_filter_count", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "contains_over_filter_is_empty", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "contains_over_first_not_nil", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "contains_over_range_nil_comparison", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "control_statement", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "convenience_type", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "custom_rules", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -227,147 +227,147 @@ "enabled" : true }, { "patternId" : "deployment_target", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "direct_return", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "discarded_notification_center_observer", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "discouraged_assert", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "discouraged_direct_init", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "discouraged_none_name", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "discouraged_object_literal", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "discouraged_optional_boolean", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "discouraged_optional_collection", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "duplicate_conditions", - "level" : "Info", + "level" : "Error", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "duplicate_enum_cases", - "level" : "Info", + "level" : "Error", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "duplicate_imports", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "duplicated_key_in_dictionary_literal", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "dynamic_inline", - "level" : "Info", + "level" : "Error", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "empty_collection_literal", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "empty_count", - "level" : "Info", + "level" : "Error", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "empty_enum_arguments", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "empty_parameters", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "empty_parentheses_with_trailing_closure", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "empty_string", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "empty_xctest_method", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -381,77 +381,77 @@ "enabled" : false }, { "patternId" : "expiring_todo", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "explicit_acl", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "explicit_enum_raw_value", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "explicit_init", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "explicit_self", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "explicit_top_level_acl", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "explicit_type_interface", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "extension_access_modifier", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "fallthrough", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "fatal_error_message", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "file_header", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -465,63 +465,63 @@ "enabled" : true }, { "patternId" : "file_name", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "file_name_no_space", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "file_types_order", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "first_where", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "flatmap_over_map_reduce", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "for_where", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "force_cast", - "level" : "Info", + "level" : "Error", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "force_try", - "level" : "Info", + "level" : "Error", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "force_unwrapping", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -535,7 +535,7 @@ "enabled" : true }, { "patternId" : "function_default_parameter_at_end", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -549,91 +549,91 @@ "enabled" : true }, { "patternId" : "generic_type_name", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "ibinspectable_in_extension", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "identical_operands", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "identifier_name", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "implicit_getter", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "implicit_return", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "implicitly_unwrapped_optional", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "inclusive_language", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "indentation_width", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "inert_defer", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "invalid_swiftlint_command", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "is_disjoint", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "joined_default_parameter", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -647,77 +647,77 @@ "enabled" : true }, { "patternId" : "last_where", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "leading_whitespace", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_cggeometry_functions", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_constant", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_constructor", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_hashing", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_multiple", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "legacy_nsgeometry_functions", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "legacy_objc_type", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "legacy_random", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "let_var_whitespace", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -731,28 +731,28 @@ "enabled" : true }, { "patternId" : "literal_expression_end_indentation", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "local_doc_comment", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "lower_acl_than_parent", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "mark", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], @@ -766,630 +766,630 @@ "enabled" : false }, { "patternId" : "modifier_order", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "multiline_arguments", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "multiline_arguments_brackets", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "multiline_function_chains", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "multiline_literal_brackets", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "multiline_parameters", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "multiline_parameters_brackets", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "multiple_closures_with_trailing_closure", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "nesting", - "level" : "Info", + "level" : "Warning", "category" : "Complexity", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "nimble_operator", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "no_extension_access_modifier", - "level" : "Info", + "level" : "Error", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "no_fallthrough_only", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "no_grouping_extension", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "no_magic_numbers", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "no_space_in_method_call", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "non_overridable_class_declaration", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "notification_center_detachment", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "ns_number_init_as_function_reference", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "nslocalizedstring_key", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "nslocalizedstring_require_bundle", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "nsobject_prefer_isequal", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "number_separator", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "object_literal", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "opening_brace", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "operator_usage_whitespace", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "operator_whitespace", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "optional_enum_case_matching", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "orphaned_doc_comment", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "overridden_super_call", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "override_in_extension", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "pattern_matching_keywords", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "period_spacing", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "prefer_nimble", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "prefer_self_in_static_references", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "prefer_self_type_over_type_of_self", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "prefer_zero_over_explicit_init", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "prefixed_toplevel_constant", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "private_action", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "private_outlet", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "private_over_fileprivate", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "private_subject", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "private_swiftui_state", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "private_unit_test", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "prohibited_interface_builder", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "prohibited_super_call", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "protocol_property_accessors_order", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "quick_discouraged_call", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "quick_discouraged_focused_test", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "quick_discouraged_pending_test", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "raw_value_for_camel_cased_codable_enum", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "reduce_boolean", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "reduce_into", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "redundant_discardable_let", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "redundant_nil_coalescing", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "redundant_objc_attribute", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "redundant_optional_initialization", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "redundant_self_in_closure", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "redundant_set_access_control", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "redundant_string_enum_value", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "redundant_type_annotation", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "redundant_void_return", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "required_deinit", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "required_enum_case", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "return_arrow_whitespace", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "return_value_from_void_function", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "self_binding", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "self_in_property_initialization", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "shorthand_operator", - "level" : "Info", + "level" : "Error", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "shorthand_optional_binding", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "single_test_class", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "sorted_enum_cases", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "sorted_first_last", - "level" : "Info", + "level" : "Warning", "category" : "Performance", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "sorted_imports", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "statement_position", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "static_operator", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "strict_fileprivate", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "strong_iboutlet", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "superfluous_disable_command", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "superfluous_else", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "switch_case_alignment", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "switch_case_on_newline", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "syntactic_sugar", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "test_case_accessibility", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "todo", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "toggle_bool", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "trailing_closure", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "trailing_comma", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "trailing_newline", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "trailing_semicolon", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "trailing_whitespace", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], @@ -1403,231 +1403,231 @@ "enabled" : true }, { "patternId" : "type_contents_order", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "type_name", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "typesafe_array_init", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "unavailable_condition", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "unavailable_function", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "unhandled_throwing_task", - "level" : "Info", + "level" : "Error", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "unneeded_break_in_switch", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "unneeded_override", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "unneeded_parentheses_in_closure_argument", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "unneeded_synthesized_initializer", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "unowned_variable_capture", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "untyped_error_in_catch", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "unused_capture_list", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "unused_closure_parameter", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "unused_control_flow_label", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "unused_declaration", - "level" : "Info", + "level" : "Error", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "unused_enumerated", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "unused_import", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "unused_optional_binding", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "unused_setter_value", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "valid_ibinspectable", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "vertical_parameter_alignment", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "vertical_parameter_alignment_on_call", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "vertical_whitespace", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "vertical_whitespace_between_cases", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "vertical_whitespace_closing_braces", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "vertical_whitespace_opening_braces", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "void_function_in_ternary", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "void_return", - "level" : "Info", + "level" : "Warning", "category" : "CodeStyle", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "weak_delegate", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "xct_specific_matcher", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : false }, { "patternId" : "xctfail_message", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], "enabled" : true }, { "patternId" : "yoda_condition", - "level" : "Info", + "level" : "Warning", "category" : "ErrorProne", "parameters" : [ ], "languages" : [ ], diff --git a/docs/tests/block_based_kvo.swift b/docs/tests/block_based_kvo.swift index 364719b..3f0a797 100644 --- a/docs/tests/block_based_kvo.swift +++ b/docs/tests/block_based_kvo.swift @@ -1,7 +1,7 @@ //#Patterns: block_based_kvo -//#Issue: {"severity": "Info", "line": 9, "patternId": "block_based_kvo"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "block_based_kvo"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "block_based_kvo"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "block_based_kvo"} diff --git a/docs/tests/class_delegate_protocol.swift b/docs/tests/class_delegate_protocol.swift index aa0957c..33ac6c4 100644 --- a/docs/tests/class_delegate_protocol.swift +++ b/docs/tests/class_delegate_protocol.swift @@ -1,7 +1,7 @@ //#Patterns: class_delegate_protocol -//#Issue: {"severity": "Info", "line": 6, "patternId": "class_delegate_protocol"} -//#Issue: {"severity": "Info", "line": 9, "patternId": "class_delegate_protocol"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "class_delegate_protocol"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "class_delegate_protocol"} protocol FooDelegate {} diff --git a/docs/tests/closing_brace.swift b/docs/tests/closing_brace.swift index 78c9abe..9196728 100644 --- a/docs/tests/closing_brace.swift +++ b/docs/tests/closing_brace.swift @@ -1,7 +1,7 @@ //#Patterns: closing_brace -//#Issue: {"severity": "Info", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Info", "line": 8, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} [].map({ } ) diff --git a/docs/tests/closure_end_indentation.swift b/docs/tests/closure_end_indentation.swift index 96401cf..27dea1b 100644 --- a/docs/tests/closure_end_indentation.swift +++ b/docs/tests/closure_end_indentation.swift @@ -1,8 +1,8 @@ //#Patterns: closure_end_indentation -//#Issue: {"severity": "Info", "line": 10, "patternId": "closure_end_indentation"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "closure_end_indentation"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "closure_end_indentation"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "closure_end_indentation"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "closure_end_indentation"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "closure_end_indentation"} SignalProducer(values: [1, 2, 3]) .startWithNext { number in diff --git a/docs/tests/colon.swift b/docs/tests/colon.swift index c9d8642..de217cd 100644 --- a/docs/tests/colon.swift +++ b/docs/tests/colon.swift @@ -1,49 +1,49 @@ //#Patterns: colon -//#Issue: {"severity": "Info", "line": 48, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 51, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 57, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 60, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 63, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 66, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 69, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 72, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 75, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 78, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 81, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 84, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 87, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 90, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 93, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 96, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 99, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 102, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 105, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 108, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 111, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 114, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 117, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 120, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 123, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 126, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 129, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 132, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 135, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 138, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 141, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 144, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 147, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 150, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 153, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 156, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 159, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 162, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 165, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 168, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 171, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 174, "patternId": "colon"} -//#Issue: {"severity": "Info", "line": 177, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 48, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 51, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 57, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 60, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 63, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 66, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 69, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 72, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 75, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 78, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 81, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 84, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 87, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 90, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 93, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 96, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 99, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 102, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 105, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 108, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 111, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 114, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 117, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 120, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 123, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 126, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 129, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 132, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 135, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 138, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 141, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 144, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 147, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 150, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 153, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 156, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 159, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 162, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 165, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 168, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 171, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 174, "patternId": "colon"} +//#Issue: {"severity": "Warning", "line": 177, "patternId": "colon"} let abc:Void diff --git a/docs/tests/comma.swift b/docs/tests/comma.swift index 8ad431a..018cc6f 100644 --- a/docs/tests/comma.swift +++ b/docs/tests/comma.swift @@ -1,10 +1,10 @@ //#Patterns: comma -//#Issue: {"severity": "Info", "line": 9, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "comma"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "comma"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "comma"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "comma"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "comma"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "comma"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "comma"} func abc(a: String ,b: String) { } diff --git a/docs/tests/compiler_protocol_init.swift b/docs/tests/compiler_protocol_init.swift index 0acb9a1..532ece5 100644 --- a/docs/tests/compiler_protocol_init.swift +++ b/docs/tests/compiler_protocol_init.swift @@ -1,7 +1,7 @@ //#Patterns: compiler_protocol_init -//#Issue: {"severity": "Info", "line": 6, "patternId": "compiler_protocol_init"} -//#Issue: {"severity": "Info", "line": 9, "patternId": "compiler_protocol_init"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "compiler_protocol_init"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "compiler_protocol_init"} let set = Set(arrayLiteral: 1, 2) diff --git a/docs/tests/conditional_returns_on_newline.swift b/docs/tests/conditional_returns_on_newline.swift index bd91447..ece920f 100644 --- a/docs/tests/conditional_returns_on_newline.swift +++ b/docs/tests/conditional_returns_on_newline.swift @@ -1,10 +1,10 @@ //#Patterns: conditional_returns_on_newline -//#Issue: {"severity": "Info", "line": 9, "patternId": "conditional_returns_on_newline"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "conditional_returns_on_newline"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "conditional_returns_on_newline"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "conditional_returns_on_newline"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "conditional_returns_on_newline"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "conditional_returns_on_newline"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "conditional_returns_on_newline"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "conditional_returns_on_newline"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "conditional_returns_on_newline"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "conditional_returns_on_newline"} guard true else { return } diff --git a/docs/tests/control_statement.swift b/docs/tests/control_statement.swift index 85a4ccc..8ce7e63 100644 --- a/docs/tests/control_statement.swift +++ b/docs/tests/control_statement.swift @@ -1,21 +1,21 @@ //#Patterns: control_statement -//#Issue: {"severity": "Info", "line": 20, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 53, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "control_statement"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 41, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 47, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 53, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 56, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 59, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 62, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 65, "patternId": "control_statement"} if (condition) { diff --git a/docs/tests/cyclomatic_complexity.swift b/docs/tests/cyclomatic_complexity.swift index 15c46e8..de6519e 100644 --- a/docs/tests/cyclomatic_complexity.swift +++ b/docs/tests/cyclomatic_complexity.swift @@ -1,6 +1,6 @@ //#Patterns: cyclomatic_complexity -//#Issue: {"severity": "Info", "line": 5, "patternId": "cyclomatic_complexity"} +//#Issue: {"severity": "Warning", "line": 5, "patternId": "cyclomatic_complexity"} func f1() { if true { diff --git a/docs/tests/discarded_notification_center_observer.swift b/docs/tests/discarded_notification_center_observer.swift index 7c390b1..7a963dc 100644 --- a/docs/tests/discarded_notification_center_observer.swift +++ b/docs/tests/discarded_notification_center_observer.swift @@ -1,8 +1,8 @@ //#Patterns: discarded_notification_center_observer -//#Issue: {"severity": "Info", "line": 7, "patternId": "discarded_notification_center_observer"} -//#Issue: {"severity": "Info", "line": 10, "patternId": "discarded_notification_center_observer"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "discarded_notification_center_observer"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "discarded_notification_center_observer"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "discarded_notification_center_observer"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "discarded_notification_center_observer"} nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { } diff --git a/docs/tests/discouraged_direct_init.swift b/docs/tests/discouraged_direct_init.swift index c94a6b5..59c08b2 100644 --- a/docs/tests/discouraged_direct_init.swift +++ b/docs/tests/discouraged_direct_init.swift @@ -1,15 +1,15 @@ //#Patterns: discouraged_direct_init -//#Issue: {"severity": "Info", "line": 15, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 39, "patternId": "discouraged_direct_init"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Warning", "line": 39, "patternId": "discouraged_direct_init"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "discouraged_direct_init"} UIDevice() diff --git a/docs/tests/discouraged_object_literal.swift b/docs/tests/discouraged_object_literal.swift index 17fdc25..04d63b3 100644 --- a/docs/tests/discouraged_object_literal.swift +++ b/docs/tests/discouraged_object_literal.swift @@ -1,7 +1,7 @@ //#Patterns: discouraged_object_literal -//#Issue: {"severity": "Info", "line": 8, "patternId": "discouraged_object_literal"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "discouraged_object_literal"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "discouraged_object_literal"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "discouraged_object_literal"} diff --git a/docs/tests/dynamic_inline.swift b/docs/tests/dynamic_inline.swift index a173305..da8e096 100644 --- a/docs/tests/dynamic_inline.swift +++ b/docs/tests/dynamic_inline.swift @@ -1,10 +1,10 @@ //#Patterns: dynamic_inline -//#Issue: {"severity": "Info", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "dynamic_inline"} class C { @inline(__always) dynamic func f() {} diff --git a/docs/tests/empty_count.swift b/docs/tests/empty_count.swift index dd32943..b341b46 100644 --- a/docs/tests/empty_count.swift +++ b/docs/tests/empty_count.swift @@ -1,9 +1,9 @@ //#Patterns: empty_count -//#Issue: {"severity": "Info", "line": 8, "patternId": "empty_count"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "empty_count"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "empty_count"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "empty_count"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "empty_count"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "empty_count"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "empty_count"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "empty_count"} [Int]().count == 0 diff --git a/docs/tests/empty_parameters.swift b/docs/tests/empty_parameters.swift index b51bec5..1827bdc 100644 --- a/docs/tests/empty_parameters.swift +++ b/docs/tests/empty_parameters.swift @@ -1,9 +1,9 @@ //#Patterns: empty_parameters -//#Issue: {"severity": "Info", "line": 8, "patternId": "empty_parameters"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "empty_parameters"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "empty_parameters"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "empty_parameters"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "empty_parameters"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "empty_parameters"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "empty_parameters"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "empty_parameters"} let abc: (Void) -> Void = {} diff --git a/docs/tests/empty_parentheses_with_trailing_closure.swift b/docs/tests/empty_parentheses_with_trailing_closure.swift index 2b3c2c6..c2550f9 100644 --- a/docs/tests/empty_parentheses_with_trailing_closure.swift +++ b/docs/tests/empty_parentheses_with_trailing_closure.swift @@ -1,9 +1,9 @@ //#Patterns: empty_parentheses_with_trailing_closure -//#Issue: {"severity": "Info", "line": 8, "patternId": "empty_parentheses_with_trailing_closure"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "empty_parentheses_with_trailing_closure"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "empty_parentheses_with_trailing_closure"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "empty_parentheses_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "empty_parentheses_with_trailing_closure"} [1, 2].map() { $0 + 1 } diff --git a/docs/tests/explicit_type_interface.swift b/docs/tests/explicit_type_interface.swift index f9e4342..49f17d8 100644 --- a/docs/tests/explicit_type_interface.swift +++ b/docs/tests/explicit_type_interface.swift @@ -1,9 +1,9 @@ //#Patterns: explicit_type_interface -//#Issue: {"severity": "Info", "line": 9, "patternId": "explicit_type_interface"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "explicit_type_interface"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "explicit_type_interface"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "explicit_type_interface"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "explicit_type_interface"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "explicit_type_interface"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "explicit_type_interface"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "explicit_type_interface"} class Foo { var myVar = 0 diff --git a/docs/tests/fallthrough.swift b/docs/tests/fallthrough.swift index e19281d..a350526 100644 --- a/docs/tests/fallthrough.swift +++ b/docs/tests/fallthrough.swift @@ -1,6 +1,6 @@ //#Patterns: fallthrough -//#Issue: {"severity": "Info", "line": 10, "patternId": "fallthrough"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "fallthrough"} diff --git a/docs/tests/fatal_error_message.swift b/docs/tests/fatal_error_message.swift index 3820dec..1a678e9 100644 --- a/docs/tests/fatal_error_message.swift +++ b/docs/tests/fatal_error_message.swift @@ -1,7 +1,7 @@ //#Patterns: fatal_error_message -//#Issue: {"severity": "Info", "line": 7, "patternId": "fatal_error_message"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "fatal_error_message"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "fatal_error_message"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "fatal_error_message"} func foo() { fatalError("") diff --git a/docs/tests/file_length.swift b/docs/tests/file_length.swift index 0d5cd14..9f212b7 100644 --- a/docs/tests/file_length.swift +++ b/docs/tests/file_length.swift @@ -1,6 +1,6 @@ //#Patterns: file_length -//#Issue: {"severity": "Info", "line": 808, "patternId": "file_length"} +//#Issue: {"severity": "Warning", "line": 808, "patternId": "file_length"} print("swiftlint") print("swiftlint") diff --git a/docs/tests/for_where.swift b/docs/tests/for_where.swift index 12b76e4..f7fdfae 100644 --- a/docs/tests/for_where.swift +++ b/docs/tests/for_where.swift @@ -1,6 +1,6 @@ //#Patterns: for_where -//#Issue: {"severity": "Info", "line": 6, "patternId": "for_where"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "for_where"} for user in users { if user.id == 1 { return true } diff --git a/docs/tests/force_cast.swift b/docs/tests/force_cast.swift index c31ff9a..7301b92 100644 --- a/docs/tests/force_cast.swift +++ b/docs/tests/force_cast.swift @@ -1,5 +1,5 @@ //#Patterns: force_cast -//#Issue: {"severity": "Info", "line": 5, "patternId": "force_cast"} +//#Issue: {"severity": "Warning", "line": 5, "patternId": "force_cast"} NSNumber() as! Int diff --git a/docs/tests/force_try.swift b/docs/tests/force_try.swift index 48f1357..021ce8a 100644 --- a/docs/tests/force_try.swift +++ b/docs/tests/force_try.swift @@ -1,5 +1,5 @@ //#Patterns: force_try -//#Issue: {"severity": "Info", "line": 5, "patternId": "force_try"} +//#Issue: {"severity": "Warning", "line": 5, "patternId": "force_try"} func a() throws {}; try! a() diff --git a/docs/tests/function_parameter_count.swift b/docs/tests/function_parameter_count.swift index c7febf2..9595234 100644 --- a/docs/tests/function_parameter_count.swift +++ b/docs/tests/function_parameter_count.swift @@ -1,9 +1,9 @@ //#Patterns: function_parameter_count -//#Issue: {"severity": "Info", "line": 8, "patternId": "function_parameter_count"} -//#Issue: {"severity": "Info", "line": 10, "patternId": "function_parameter_count"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "function_parameter_count"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "function_parameter_count"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "function_parameter_count"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "function_parameter_count"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "function_parameter_count"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "function_parameter_count"} func f(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) {} diff --git a/docs/tests/implicit_getter.swift b/docs/tests/implicit_getter.swift index 00e8c0c..4a1354c 100644 --- a/docs/tests/implicit_getter.swift +++ b/docs/tests/implicit_getter.swift @@ -1,10 +1,10 @@ //#Patterns: implicit_getter -//#Issue: {"severity": "Info", "line": 11, "patternId": "implicit_getter"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "implicit_getter"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "implicit_getter"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "implicit_getter"} -//#Issue: {"severity": "Info", "line": 49, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 49, "patternId": "implicit_getter"} class Foo { var foo: Int { diff --git a/docs/tests/is_disjoint.swift b/docs/tests/is_disjoint.swift index 12befab..7c7a22b 100644 --- a/docs/tests/is_disjoint.swift +++ b/docs/tests/is_disjoint.swift @@ -1,7 +1,7 @@ //#Patterns: is_disjoint -//#Issue: {"severity": "Info", "line": 8, "patternId": "is_disjoint"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "is_disjoint"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "is_disjoint"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "is_disjoint"} diff --git a/docs/tests/legacy_constant.swift b/docs/tests/legacy_constant.swift index ce1de6e..cd0727e 100644 --- a/docs/tests/legacy_constant.swift +++ b/docs/tests/legacy_constant.swift @@ -1,15 +1,15 @@ //#Patterns: legacy_constant -//#Issue: {"severity": "Info", "line": 14, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "legacy_constant"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "legacy_constant"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "legacy_constant"} CGRectInfinite diff --git a/docs/tests/legacy_constructor.swift b/docs/tests/legacy_constructor.swift index ed5af78..3ce126c 100644 --- a/docs/tests/legacy_constructor.swift +++ b/docs/tests/legacy_constructor.swift @@ -1,25 +1,25 @@ //#Patterns: legacy_constructor -//#Issue: {"severity": "Info", "line": 24, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 48, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 52, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 58, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 60, "patternId": "legacy_constructor"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 46, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 48, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 52, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 56, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 58, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 60, "patternId": "legacy_constructor"} +//#Issue: {"severity": "Warning", "line": 62, "patternId": "legacy_constructor"} CGPointMake(10, 10) diff --git a/docs/tests/legacy_nsgeometry_functions.swift b/docs/tests/legacy_nsgeometry_functions.swift index 0e72904..83d57e1 100644 --- a/docs/tests/legacy_nsgeometry_functions.swift +++ b/docs/tests/legacy_nsgeometry_functions.swift @@ -1,26 +1,26 @@ //#Patterns: legacy_nsgeometry_functions -//#Issue: {"severity": "Info", "line": 25, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 39, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 43, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 45, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 49, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 51, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 53, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 55, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 57, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 61, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 63, "patternId": "legacy_nsgeometry_functions"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 37, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 39, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 41, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 43, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 45, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 47, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 49, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 51, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 53, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 55, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 57, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 59, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 61, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 63, "patternId": "legacy_nsgeometry_functions"} +//#Issue: {"severity": "Warning", "line": 65, "patternId": "legacy_nsgeometry_functions"} NSWidth(rect) diff --git a/docs/tests/line_length.swift b/docs/tests/line_length.swift index c660465..3aeafb7 100644 --- a/docs/tests/line_length.swift +++ b/docs/tests/line_length.swift @@ -1,8 +1,8 @@ //#Patterns: line_length -//#Issue: {"severity": "Info", "line": 7, "patternId": "line_length"} -//#Issue: {"severity": "Info", "line": 10, "patternId": "line_length"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "line_length"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "line_length"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "line_length"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "line_length"} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/docs/tests/mark.swift b/docs/tests/mark.swift index 1301746..146ba6b 100644 --- a/docs/tests/mark.swift +++ b/docs/tests/mark.swift @@ -1,25 +1,25 @@ //#Patterns: mark -//#Issue: {"severity": "Info", "line": 24, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 48, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 52, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 58, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "mark"} -//#Issue: {"severity": "Info", "line": 61, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 46, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 48, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 52, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 56, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 58, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 59, "patternId": "mark"} +//#Issue: {"severity": "Warning", "line": 61, "patternId": "mark"} //MARK: bad diff --git a/docs/tests/multiline_arguments.swift b/docs/tests/multiline_arguments.swift index 960de1c..d528bbe 100644 --- a/docs/tests/multiline_arguments.swift +++ b/docs/tests/multiline_arguments.swift @@ -1,11 +1,11 @@ //#Patterns: multiline_arguments -//#Issue: {"severity": "Info", "line": 13, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "multiline_arguments"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "multiline_arguments"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "multiline_arguments"} diff --git a/docs/tests/multiple_closures_with_trailing_closure.swift b/docs/tests/multiple_closures_with_trailing_closure.swift index 679d852..563a950 100644 --- a/docs/tests/multiple_closures_with_trailing_closure.swift +++ b/docs/tests/multiple_closures_with_trailing_closure.swift @@ -1,7 +1,7 @@ //#Patterns: multiple_closures_with_trailing_closure -//#Issue: {"severity": "Info", "line": 8, "patternId": "multiple_closures_with_trailing_closure"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "multiple_closures_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "multiple_closures_with_trailing_closure"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "multiple_closures_with_trailing_closure"} diff --git a/docs/tests/nesting.swift b/docs/tests/nesting.swift index e0442dc..e095436 100644 --- a/docs/tests/nesting.swift +++ b/docs/tests/nesting.swift @@ -1,11 +1,11 @@ //#Patterns: nesting -//#Issue: {"severity": "Info", "line": 10, "patternId": "nesting"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "nesting"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "nesting"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "nesting"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "nesting"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "nesting"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "nesting"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "nesting"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "nesting"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "nesting"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "nesting"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "nesting"} class A { class B { class C {} } } diff --git a/docs/tests/nimble_operator.swift b/docs/tests/nimble_operator.swift index 5261baf..cd51956 100644 --- a/docs/tests/nimble_operator.swift +++ b/docs/tests/nimble_operator.swift @@ -1,14 +1,14 @@ //#Patterns: nimble_operator -//#Issue: {"severity": "Info", "line": 13, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 31, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "nimble_operator"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "nimble_operator"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "nimble_operator"} expect(seagull.squawk).toNot(equal("Hi")) diff --git a/docs/tests/no_extension_access_modifier.swift b/docs/tests/no_extension_access_modifier.swift index b601dff..dbeaa3c 100644 --- a/docs/tests/no_extension_access_modifier.swift +++ b/docs/tests/no_extension_access_modifier.swift @@ -1,10 +1,10 @@ //#Patterns: no_extension_access_modifier -//#Issue: {"severity": "Info", "line": 9, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "no_extension_access_modifier"} private extension String {} diff --git a/docs/tests/no_grouping_extension.swift b/docs/tests/no_grouping_extension.swift index cb5845d..ec71e66 100644 --- a/docs/tests/no_grouping_extension.swift +++ b/docs/tests/no_grouping_extension.swift @@ -1,9 +1,9 @@ //#Patterns: no_grouping_extension -//#Issue: {"severity": "Info", "line": 11, "patternId": "no_grouping_extension"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "no_grouping_extension"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "no_grouping_extension"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "no_grouping_extension"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "no_grouping_extension"} diff --git a/docs/tests/notification_center_detachment.swift b/docs/tests/notification_center_detachment.swift index 14a4779..a0964c8 100644 --- a/docs/tests/notification_center_detachment.swift +++ b/docs/tests/notification_center_detachment.swift @@ -1,6 +1,6 @@ //#Patterns: notification_center_detachment -//#Issue: {"severity": "Info", "line": 7, "patternId": "notification_center_detachment"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "notification_center_detachment"} class Foo { func bar() { diff --git a/docs/tests/object_literal.swift b/docs/tests/object_literal.swift index 5639d4e..ce35dd2 100644 --- a/docs/tests/object_literal.swift +++ b/docs/tests/object_literal.swift @@ -1,21 +1,21 @@ //#Patterns: object_literal -//#Issue: {"severity": "Info", "line": 20, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 48, "patternId": "object_literal"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 46, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 48, "patternId": "object_literal"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "object_literal"} let image = UIImage(named: "foo") diff --git a/docs/tests/operator_whitespace.swift b/docs/tests/operator_whitespace.swift index b3aacdb..f9fefa1 100644 --- a/docs/tests/operator_whitespace.swift +++ b/docs/tests/operator_whitespace.swift @@ -1,11 +1,11 @@ //#Patterns: operator_whitespace -//#Issue: {"severity": "Info", "line": 10, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "operator_whitespace"} func <|(lhs: Int, rhs: Int) -> Int {} diff --git a/docs/tests/overridden_super_call.swift b/docs/tests/overridden_super_call.swift index 72895a3..5ae97bc 100644 --- a/docs/tests/overridden_super_call.swift +++ b/docs/tests/overridden_super_call.swift @@ -1,8 +1,8 @@ //#Patterns: overridden_super_call -//#Issue: {"severity": "Info", "line": 8, "patternId": "overridden_super_call"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "overridden_super_call"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "overridden_super_call"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "overridden_super_call"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "overridden_super_call"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "overridden_super_call"} class VC: UIViewController { override func viewWillAppear(_ animated: Bool) { diff --git a/docs/tests/override_in_extension.swift b/docs/tests/override_in_extension.swift index c28a1c3..23c84aa 100644 --- a/docs/tests/override_in_extension.swift +++ b/docs/tests/override_in_extension.swift @@ -1,7 +1,7 @@ //#Patterns: override_in_extension -//#Issue: {"severity": "Info", "line": 9, "patternId": "override_in_extension"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "override_in_extension"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "override_in_extension"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "override_in_extension"} diff --git a/docs/tests/private_action.swift b/docs/tests/private_action.swift index 4e3c771..a8caaaa 100644 --- a/docs/tests/private_action.swift +++ b/docs/tests/private_action.swift @@ -1,16 +1,16 @@ //#Patterns: private_action -//#Issue: {"severity": "Info", "line": 17, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 53, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 71, "patternId": "private_action"} -//#Issue: {"severity": "Info", "line": 77, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 41, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 47, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 53, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 59, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 65, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 71, "patternId": "private_action"} +//#Issue: {"severity": "Warning", "line": 77, "patternId": "private_action"} class Foo { diff --git a/docs/tests/private_outlet.swift b/docs/tests/private_outlet.swift index c3fdf97..fed5029 100644 --- a/docs/tests/private_outlet.swift +++ b/docs/tests/private_outlet.swift @@ -1,7 +1,7 @@ //#Patterns: private_outlet -//#Issue: {"severity": "Info", "line": 7, "patternId": "private_outlet"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "private_outlet"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "private_outlet"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "private_outlet"} class Foo { @IBOutlet var label: UILabel? diff --git a/docs/tests/private_over_fileprivate.swift b/docs/tests/private_over_fileprivate.swift index 21eabe3..7e9e48e 100644 --- a/docs/tests/private_over_fileprivate.swift +++ b/docs/tests/private_over_fileprivate.swift @@ -1,7 +1,7 @@ //#Patterns: private_over_fileprivate -//#Issue: {"severity": "Info", "line": 7, "patternId": "private_over_fileprivate"} -//#Issue: {"severity": "Info", "line": 10, "patternId": "private_over_fileprivate"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "private_over_fileprivate"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "private_over_fileprivate"} fileprivate enum MyEnum {} diff --git a/docs/tests/private_unit_test.swift b/docs/tests/private_unit_test.swift index 657213c..35f9550 100644 --- a/docs/tests/private_unit_test.swift +++ b/docs/tests/private_unit_test.swift @@ -1,9 +1,9 @@ //#Patterns: private_unit_test -//#Issue: {"severity": "Info", "line": 8, "patternId": "private_unit_test"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "private_unit_test"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "private_unit_test"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "private_unit_test"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "private_unit_test"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "private_unit_test"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "private_unit_test"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "private_unit_test"} private class FooTest: XCTestCase { func test1() {} internal func test2() {} diff --git a/docs/tests/prohibited_super_call.swift b/docs/tests/prohibited_super_call.swift index 26c08ec..d879a60 100644 --- a/docs/tests/prohibited_super_call.swift +++ b/docs/tests/prohibited_super_call.swift @@ -1,9 +1,9 @@ //#Patterns: prohibited_super_call -//#Issue: {"severity": "Info", "line": 9, "patternId": "prohibited_super_call"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "prohibited_super_call"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "prohibited_super_call"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "prohibited_super_call"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "prohibited_super_call"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "prohibited_super_call"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "prohibited_super_call"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "prohibited_super_call"} class VC: UIViewController { override func loadView() { diff --git a/docs/tests/protocol_property_accessors_order.swift b/docs/tests/protocol_property_accessors_order.swift index 6836af9..1dec6da 100644 --- a/docs/tests/protocol_property_accessors_order.swift +++ b/docs/tests/protocol_property_accessors_order.swift @@ -1,6 +1,6 @@ //#Patterns: protocol_property_accessors_order -//#Issue: {"severity": "Info", "line": 6, "patternId": "protocol_property_accessors_order"} +//#Issue: {"severity": "Warning", "line": 6, "patternId": "protocol_property_accessors_order"} protocol Foo { var bar: String { set get } diff --git a/docs/tests/redundant_optional_initialization.swift b/docs/tests/redundant_optional_initialization.swift index 8477089..69c122f 100644 --- a/docs/tests/redundant_optional_initialization.swift +++ b/docs/tests/redundant_optional_initialization.swift @@ -1,9 +1,9 @@ //#Patterns: redundant_optional_initialization -//#Issue: {"severity": "Info", "line": 8, "patternId": "redundant_optional_initialization"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "redundant_optional_initialization"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "redundant_optional_initialization"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "redundant_optional_initialization"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "redundant_optional_initialization"} var myVar: Int? = nil diff --git a/docs/tests/redundant_void_return.swift b/docs/tests/redundant_void_return.swift index ead3abd..f5e239f 100644 --- a/docs/tests/redundant_void_return.swift +++ b/docs/tests/redundant_void_return.swift @@ -1,9 +1,9 @@ //#Patterns: redundant_void_return -//#Issue: {"severity": "Info", "line": 8, "patternId": "redundant_void_return"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "redundant_void_return"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "redundant_void_return"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "redundant_void_return"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "redundant_void_return"} func foo() -> Void {} diff --git a/docs/tests/return_arrow_whitespace.swift b/docs/tests/return_arrow_whitespace.swift index c62b57f..2c4b840 100644 --- a/docs/tests/return_arrow_whitespace.swift +++ b/docs/tests/return_arrow_whitespace.swift @@ -1,13 +1,13 @@ //#Patterns: return_arrow_whitespace -//#Issue: {"severity": "Info", "line": 12, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "return_arrow_whitespace"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "return_arrow_whitespace"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "return_arrow_whitespace"} func abc()->Int {} diff --git a/docs/tests/shorthand_operator.swift b/docs/tests/shorthand_operator.swift index cd3d248..3d76f73 100644 --- a/docs/tests/shorthand_operator.swift +++ b/docs/tests/shorthand_operator.swift @@ -1,27 +1,27 @@ //#Patterns: shorthand_operator -//#Issue: {"severity": "Info", "line": 26, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 35, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 47, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 53, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 59, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 68, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 71, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 74, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 77, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 80, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 83, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 86, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Info", "line": 88, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 41, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 47, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 53, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 56, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 59, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 62, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 65, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 68, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 71, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 74, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 77, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 80, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 83, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 86, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Warning", "line": 88, "patternId": "shorthand_operator"} foo = foo - 1 diff --git a/docs/tests/sorted_first_last.swift b/docs/tests/sorted_first_last.swift index fc2178c..47dddad 100644 --- a/docs/tests/sorted_first_last.swift +++ b/docs/tests/sorted_first_last.swift @@ -1,18 +1,18 @@ //#Patterns: sorted_first_last -//#Issue: {"severity": "Info", "line": 18, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 58, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "sorted_first_last"} -//#Issue: {"severity": "Info", "line": 66, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 46, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 58, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 62, "patternId": "sorted_first_last"} +//#Issue: {"severity": "Warning", "line": 66, "patternId": "sorted_first_last"} myList.sorted().first diff --git a/docs/tests/sorted_imports.swift b/docs/tests/sorted_imports.swift index fc3e85e..b57199a 100644 --- a/docs/tests/sorted_imports.swift +++ b/docs/tests/sorted_imports.swift @@ -1,6 +1,6 @@ //#Patterns: sorted_imports -//#Issue: {"severity": "Info", "line": 7, "patternId": "sorted_imports"} +//#Issue: {"severity": "Warning", "line": 7, "patternId": "sorted_imports"} import AAA import ZZZ diff --git a/docs/tests/statement_position.swift b/docs/tests/statement_position.swift index b15e677..721cc72 100644 --- a/docs/tests/statement_position.swift +++ b/docs/tests/statement_position.swift @@ -1,9 +1,9 @@ //#Patterns: statement_position -//#Issue: {"severity": "Info", "line": 8, "patternId": "statement_position"} -//#Issue: {"severity": "Info", "line": 10, "patternId": "statement_position"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "statement_position"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "statement_position"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "statement_position"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "statement_position"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "statement_position"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "statement_position"} }else if { diff --git a/docs/tests/switch_case_alignment.swift b/docs/tests/switch_case_alignment.swift index 969a884..f71880c 100644 --- a/docs/tests/switch_case_alignment.swift +++ b/docs/tests/switch_case_alignment.swift @@ -1,10 +1,10 @@ //#Patterns: switch_case_alignment -//#Issue: {"severity": "Info", "line": 12, "patternId": "switch_case_alignment"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "switch_case_alignment"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "switch_case_alignment"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "switch_case_alignment"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "switch_case_alignment"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "switch_case_alignment"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "switch_case_alignment"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "switch_case_alignment"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "switch_case_alignment"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "switch_case_alignment"} diff --git a/docs/tests/todo.swift b/docs/tests/todo.swift index 7463db7..380b461 100644 --- a/docs/tests/todo.swift +++ b/docs/tests/todo.swift @@ -1,13 +1,13 @@ //#Patterns: todo -//#Issue: {"severity": "Info", "line": 12, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "todo"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "todo"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "todo"} // TODO: diff --git a/docs/tests/trailing_closure.swift b/docs/tests/trailing_closure.swift index 86e189c..e1a5821 100644 --- a/docs/tests/trailing_closure.swift +++ b/docs/tests/trailing_closure.swift @@ -1,9 +1,9 @@ //#Patterns: trailing_closure -//#Issue: {"severity": "Info", "line": 10, "patternId": "trailing_closure"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "trailing_closure"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "trailing_closure"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "trailing_closure"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "trailing_closure"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "trailing_closure"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "trailing_closure"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "trailing_closure"} diff --git a/docs/tests/trailing_comma.swift b/docs/tests/trailing_comma.swift index ae36203..86baf82 100644 --- a/docs/tests/trailing_comma.swift +++ b/docs/tests/trailing_comma.swift @@ -1,13 +1,13 @@ //#Patterns: trailing_comma -//#Issue: {"severity": "Info", "line": 12, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 15, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 21, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "trailing_comma"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "trailing_comma"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "trailing_comma"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "trailing_comma"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "trailing_comma"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "trailing_comma"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "trailing_comma"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "trailing_comma"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "trailing_comma"} +//#Issue: {"severity": "Warning", "line": 37, "patternId": "trailing_comma"} let foo = [1, 2, 3,] diff --git a/docs/tests/trailing_semicolon.swift b/docs/tests/trailing_semicolon.swift index d08f4b2..0d562f9 100644 --- a/docs/tests/trailing_semicolon.swift +++ b/docs/tests/trailing_semicolon.swift @@ -1,10 +1,10 @@ //#Patterns: trailing_semicolon -//#Issue: {"severity": "Info", "line": 9, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Info", "line": 12, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "trailing_semicolon"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "trailing_semicolon"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "trailing_semicolon"} let a = 0; diff --git a/docs/tests/type_name.swift b/docs/tests/type_name.swift index b7fddb5..4db3780 100644 --- a/docs/tests/type_name.swift +++ b/docs/tests/type_name.swift @@ -1,27 +1,27 @@ //#Patterns: type_name -//#Issue: {"severity": "Info", "line": 26, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 28, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 36, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 38, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 40, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 42, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 46, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 48, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 50, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 52, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 56, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 58, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 60, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 62, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 65, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 69, "patternId": "type_name"} -//#Issue: {"severity": "Info", "line": 73, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 46, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 48, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 50, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 52, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 56, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 58, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 60, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 62, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 65, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 69, "patternId": "type_name"} +//#Issue: {"severity": "Warning", "line": 73, "patternId": "type_name"} class myType {} diff --git a/docs/tests/unneeded_parentheses_in_closure_argument.swift b/docs/tests/unneeded_parentheses_in_closure_argument.swift index 7167226..6fbc13b 100644 --- a/docs/tests/unneeded_parentheses_in_closure_argument.swift +++ b/docs/tests/unneeded_parentheses_in_closure_argument.swift @@ -1,10 +1,10 @@ //#Patterns: unneeded_parentheses_in_closure_argument -//#Issue: {"severity": "Info", "line": 10, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "unneeded_parentheses_in_closure_argument"} -//#Issue: {"severity": "Info", "line": 25, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "unneeded_parentheses_in_closure_argument"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "unneeded_parentheses_in_closure_argument"} call(arg: { (bar) in }) diff --git a/docs/tests/unused_closure_parameter.swift b/docs/tests/unused_closure_parameter.swift index 46c93c0..c0e0f5f 100644 --- a/docs/tests/unused_closure_parameter.swift +++ b/docs/tests/unused_closure_parameter.swift @@ -1,13 +1,13 @@ //#Patterns: unused_closure_parameter -//#Issue: {"severity": "Info", "line": 12, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 22, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 32, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 37, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 41, "patternId": "unused_closure_parameter"} -//#Issue: {"severity": "Info", "line": 45, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 37, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 41, "patternId": "unused_closure_parameter"} +//#Issue: {"severity": "Warning", "line": 45, "patternId": "unused_closure_parameter"} [1, 2].map { number in return 3 diff --git a/docs/tests/unused_enumerated.swift b/docs/tests/unused_enumerated.swift index 53932a9..fefbb13 100644 --- a/docs/tests/unused_enumerated.swift +++ b/docs/tests/unused_enumerated.swift @@ -1,9 +1,9 @@ //#Patterns: unused_enumerated -//#Issue: {"severity": "Info", "line": 8, "patternId": "unused_enumerated"} -//#Issue: {"severity": "Info", "line": 11, "patternId": "unused_enumerated"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "unused_enumerated"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "unused_enumerated"} for (_, foo) in bar.enumerated() { } diff --git a/docs/tests/valid_ibinspectable.swift b/docs/tests/valid_ibinspectable.swift index 98448c5..e7cc66b 100644 --- a/docs/tests/valid_ibinspectable.swift +++ b/docs/tests/valid_ibinspectable.swift @@ -1,14 +1,14 @@ //#Patterns: valid_ibinspectable -//#Issue: {"severity": "Info", "line": 14, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 19, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 34, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 39, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 44, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 49, "patternId": "valid_ibinspectable"} -//#Issue: {"severity": "Info", "line": 54, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 39, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 44, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 49, "patternId": "valid_ibinspectable"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "valid_ibinspectable"} class Foo { @IBInspectable private let count: Int diff --git a/docs/tests/vertical_parameter_alignment.swift b/docs/tests/vertical_parameter_alignment.swift index cabd4f8..eca126f 100644 --- a/docs/tests/vertical_parameter_alignment.swift +++ b/docs/tests/vertical_parameter_alignment.swift @@ -1,9 +1,9 @@ //#Patterns: vertical_parameter_alignment -//#Issue: {"severity": "Info", "line": 9, "patternId": "vertical_parameter_alignment"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "vertical_parameter_alignment"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "vertical_parameter_alignment"} -//#Issue: {"severity": "Info", "line": 18, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 9, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "vertical_parameter_alignment"} func validateFunction(_ file: File, kind: SwiftDeclarationKind, dictionary: [String: SourceKitRepresentable]) { } diff --git a/docs/tests/vertical_whitespace.swift b/docs/tests/vertical_whitespace.swift index 4859960..30c2d71 100644 --- a/docs/tests/vertical_whitespace.swift +++ b/docs/tests/vertical_whitespace.swift @@ -1,7 +1,7 @@ //#Patterns: vertical_whitespace -//#Issue: {"severity": "Info", "line": 10, "patternId": "vertical_whitespace"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "vertical_whitespace"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "vertical_whitespace"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "vertical_whitespace"} let aaaa = 0 diff --git a/docs/tests/void_return.swift b/docs/tests/void_return.swift index 586b837..e0a4ac7 100644 --- a/docs/tests/void_return.swift +++ b/docs/tests/void_return.swift @@ -1,12 +1,12 @@ //#Patterns: void_return -//#Issue: {"severity": "Info", "line": 11, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 14, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 17, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 23, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 26, "patternId": "void_return"} -//#Issue: {"severity": "Info", "line": 29, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "void_return"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "void_return"} let abc: () -> () = {} diff --git a/docs/tests/xctfail_message.swift b/docs/tests/xctfail_message.swift index 61ae9a0..7ab9607 100644 --- a/docs/tests/xctfail_message.swift +++ b/docs/tests/xctfail_message.swift @@ -1,7 +1,7 @@ //#Patterns: xctfail_message -//#Issue: {"severity": "Info", "line": 8, "patternId": "xctfail_message"} -//#Issue: {"severity": "Info", "line": 13, "patternId": "xctfail_message"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "xctfail_message"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "xctfail_message"} func testFoo() { diff --git a/docs/tests/yoda_condition.swift b/docs/tests/yoda_condition.swift index 09c4bee..55c302b 100644 --- a/docs/tests/yoda_condition.swift +++ b/docs/tests/yoda_condition.swift @@ -1,12 +1,12 @@ //#Patterns: yoda_condition -//#Issue: {"severity": "Info", "line": 12, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 16, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 20, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 24, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 27, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 30, "patternId": "yoda_condition"} -//#Issue: {"severity": "Info", "line": 33, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 16, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "yoda_condition"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "yoda_condition"} if 42 == foo {} From 9dddfe614d5b6c189c06172c025766f692c41fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Pires?= Date: Sat, 9 Dec 2023 13:39:40 +0000 Subject: [PATCH 099/119] fix: tests --- docs/tests/control_statement.swift | 66 +++++--------- docs/tests/dynamic_inline.swift | 46 +++++----- docs/tests/empty_count.swift | 32 +++++-- docs/tests/explicit_init.swift | 23 ++++- docs/tests/force_cast.swift | 4 +- docs/tests/force_try.swift | 4 +- docs/tests/no_extension_access_modifier.swift | 23 +++-- docs/tests/operator_whitespace.swift | 25 +++--- docs/tests/shorthand_operator.swift | 88 +++++++++---------- docs/tests/vertical_parameter_alignment.swift | 26 ++++-- 10 files changed, 174 insertions(+), 163 deletions(-) diff --git a/docs/tests/control_statement.swift b/docs/tests/control_statement.swift index 8ce7e63..f6a03b6 100644 --- a/docs/tests/control_statement.swift +++ b/docs/tests/control_statement.swift @@ -1,65 +1,41 @@ //#Patterns: control_statement //#Issue: {"severity": "Warning", "line": 20, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 23, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "control_statement"} //#Issue: {"severity": "Warning", "line": 26, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "control_statement"} //#Issue: {"severity": "Warning", "line": 32, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 35, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 36, "patternId": "control_statement"} //#Issue: {"severity": "Warning", "line": 38, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 41, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 40, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 42, "patternId": "control_statement"} //#Issue: {"severity": "Warning", "line": 44, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 47, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 50, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 53, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 56, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 59, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 62, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 65, "patternId": "control_statement"} - if (condition) { +if (condition) {} +if(condition) {} - if(condition) { +if (condition == endIndex) {} +if ((a || b) && (c || d)) {} - if ((a || b) && (c || d)) { +if ((min...max).contains(value)) {} +guard (condition) else {} - if ((min...max).contains(value)) { +while (condition) {} +while(condition) {} +do { ; } while(condition) {} +do { ; } while (condition) {} +switch (foo) {} +do {} catch(let error as NSError) {} - - - - - - - - - guard (condition) else { - - - while (condition) { - - - while(condition) { - - - } while (condition) { - - - } while(condition) { - - - do { ; } while(condition) { - - - do { ; } while (condition) { - - - switch (foo) { +if (max(a, b) < c) {} diff --git a/docs/tests/dynamic_inline.swift b/docs/tests/dynamic_inline.swift index da8e096..81e7a2b 100644 --- a/docs/tests/dynamic_inline.swift +++ b/docs/tests/dynamic_inline.swift @@ -1,30 +1,30 @@ //#Patterns: dynamic_inline -//#Issue: {"severity": "Warning", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Error", "line": 10, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Error", "line": 14, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Error", "line": 18, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Error", "line": 23, "patternId": "dynamic_inline"} +//#Issue: {"severity": "Error", "line": 29, "patternId": "dynamic_inline"} - class C { - @inline(__always) dynamic func f() {} - } +class C { +@inline(__always) dynamic func f() {} +} - class C { - @inline(__always) public dynamic func f() {} - } +class C { +@inline(__always) public dynamic func f() {} +} - class C { - @inline(__always) dynamic internal func f() {} - } +class C { +@inline(__always) dynamic internal func f() {} +} - class C { - @inline(__always) - dynamic func f() {} - } +class C { +@inline(__always) +dynamic func f() {} +} - class C { - @inline(__always) - dynamic - func f() {} - } +class C { +@inline(__always) +dynamic +func f() {} +} diff --git a/docs/tests/empty_count.swift b/docs/tests/empty_count.swift index b341b46..79138be 100644 --- a/docs/tests/empty_count.swift +++ b/docs/tests/empty_count.swift @@ -1,18 +1,32 @@ //#Patterns: empty_count -//#Issue: {"severity": "Warning", "line": 8, "patternId": "empty_count"} -//#Issue: {"severity": "Warning", "line": 11, "patternId": "empty_count"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "empty_count"} -//#Issue: {"severity": "Warning", "line": 17, "patternId": "empty_count"} +//#Issue: {"severity": "Error", "line": 14, "patternId": "empty_count"} +//#Issue: {"severity": "Error", "line": 16, "patternId": "empty_count"} +//#Issue: {"severity": "Error", "line": 18, "patternId": "empty_count"} +//#Issue: {"severity": "Error", "line": 20, "patternId": "empty_count"} +//#Issue: {"severity": "Error", "line": 22, "patternId": "empty_count"} +//#Issue: {"severity": "Error", "line": 24, "patternId": "empty_count"} +//#Issue: {"severity": "Error", "line": 26, "patternId": "empty_count"} +//#Issue: {"severity": "Error", "line": 28, "patternId": "empty_count"} +//#Issue: {"severity": "Error", "line": 30, "patternId": "empty_count"} +//#Issue: {"severity": "Error", "line": 32, "patternId": "empty_count"} - [Int]().count == 0 +[Int]().count == 0 +0 == [Int]().count - [Int]().count > 0 +[Int]().count==0 +[Int]().count > 0 - [Int]().count != 0 +[Int]().count != 0 +[Int]().count == 0x0 - count == 0 - +[Int]().count == 0x00_00 + +[Int]().count == 0b00 + +[Int]().count == 0o00 + +count == 0 diff --git a/docs/tests/explicit_init.swift b/docs/tests/explicit_init.swift index c54c71e..0137361 100644 --- a/docs/tests/explicit_init.swift +++ b/docs/tests/explicit_init.swift @@ -1,7 +1,26 @@ //#Patterns: explicit_init -//#Issue: {"severity": "Warning", "line": 6, "patternId": "explicit_init"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "explicit_init"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "explicit_init"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "explicit_init"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "explicit_init"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "explicit_init"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "explicit_init"} + +[1].flatMap{String.init($0)} + +[String.self].map { Type in Type.init(1) } func foo() -> [String] { - return [1].flatMap { String↓.init($0) } + return [1].flatMap { String.init($0) } } + +_ = GleanMetrics.Tabs.GroupedTabExtra.init() + +_ = Set.init() + +Observable.zip( + obs1, + obs2, + resultSelector: { MyType.init($0, $1) } +).asMaybe() diff --git a/docs/tests/force_cast.swift b/docs/tests/force_cast.swift index 7301b92..475cdf1 100644 --- a/docs/tests/force_cast.swift +++ b/docs/tests/force_cast.swift @@ -1,5 +1,5 @@ //#Patterns: force_cast -//#Issue: {"severity": "Warning", "line": 5, "patternId": "force_cast"} +//#Issue: {"severity": "Error", "line": 5, "patternId": "force_cast"} - NSNumber() as! Int +NSNumber() as! Int diff --git a/docs/tests/force_try.swift b/docs/tests/force_try.swift index 021ce8a..5e3ce92 100644 --- a/docs/tests/force_try.swift +++ b/docs/tests/force_try.swift @@ -1,5 +1,5 @@ //#Patterns: force_try -//#Issue: {"severity": "Warning", "line": 5, "patternId": "force_try"} +//#Issue: {"severity": "Error", "line": 5, "patternId": "force_try"} - func a() throws {}; try! a() +func a() throws {}; try! a() diff --git a/docs/tests/no_extension_access_modifier.swift b/docs/tests/no_extension_access_modifier.swift index dbeaa3c..b584468 100644 --- a/docs/tests/no_extension_access_modifier.swift +++ b/docs/tests/no_extension_access_modifier.swift @@ -1,19 +1,18 @@ //#Patterns: no_extension_access_modifier -//#Issue: {"severity": "Warning", "line": 9, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Warning", "line": 11, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Warning", "line": 16, "patternId": "no_extension_access_modifier"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Error", "line": 9, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Error", "line": 11, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Error", "line": 14, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Error", "line": 16, "patternId": "no_extension_access_modifier"} +//#Issue: {"severity": "Error", "line": 18, "patternId": "no_extension_access_modifier"} - private extension String {} +private extension String {} - public - extension String {} +public + extension String {} - open extension String {} +open extension String {} - internal extension String {} +internal extension String {} - fileprivate extension String {} - +fileprivate extension String {} diff --git a/docs/tests/operator_whitespace.swift b/docs/tests/operator_whitespace.swift index f9fefa1..7bbc866 100644 --- a/docs/tests/operator_whitespace.swift +++ b/docs/tests/operator_whitespace.swift @@ -1,25 +1,20 @@ //#Patterns: operator_whitespace //#Issue: {"severity": "Warning", "line": 10, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Warning", "line": 13, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "operator_whitespace"} //#Issue: {"severity": "Warning", "line": 16, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Warning", "line": 19, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "operator_whitespace"} -//#Issue: {"severity": "Warning", "line": 25, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "operator_whitespace"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "operator_whitespace"} - func <|(lhs: Int, rhs: Int) -> Int {} +func <|(lhs: Int, rhs: Int) -> Int {} +func <|<
(lhs: A, rhs: A) -> A {} - func <|<(lhs: A, rhs: A) -> A {} +func <| (lhs: Int, rhs: Int) -> Int {} +func <|< (lhs: A, rhs: A) -> A {} - func <| (lhs: Int, rhs: Int) -> Int {} +func <| (lhs: Int, rhs: Int) -> Int {} - - func <|< (lhs: A, rhs: A) -> A {} - - - func <| (lhs: Int, rhs: Int) -> Int {} - - - func <|< (lhs: A, rhs: A) -> A {} +func <|< (lhs: A, rhs: A) -> A {} diff --git a/docs/tests/shorthand_operator.swift b/docs/tests/shorthand_operator.swift index 3d76f73..9a879b6 100644 --- a/docs/tests/shorthand_operator.swift +++ b/docs/tests/shorthand_operator.swift @@ -1,88 +1,88 @@ //#Patterns: shorthand_operator -//#Issue: {"severity": "Warning", "line": 26, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 32, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 35, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 38, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 41, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 44, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 47, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 50, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 53, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 56, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 59, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 62, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 65, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 68, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 71, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 74, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 77, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 80, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 83, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 86, "patternId": "shorthand_operator"} -//#Issue: {"severity": "Warning", "line": 88, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 26, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 29, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 32, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 35, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 38, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 41, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 44, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 47, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 50, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 53, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 56, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 59, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 62, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 65, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 68, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 71, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 74, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 77, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 80, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 83, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 86, "patternId": "shorthand_operator"} +//#Issue: {"severity": "Error", "line": 88, "patternId": "shorthand_operator"} - foo = foo - 1 +foo = foo - 1 - foo = foo - aVariable +foo = foo - aVariable - foo = foo - bar.method() +foo = foo - bar.method() - foo.aProperty = foo.aProperty - 1 +foo.aProperty = foo.aProperty - 1 - self.aProperty = self.aProperty - 1 +self.aProperty = self.aProperty - 1 - foo = foo / 1 +foo = foo / 1 - foo = foo / aVariable +foo = foo / aVariable - foo = foo / bar.method() +foo = foo / bar.method() - foo.aProperty = foo.aProperty / 1 +foo.aProperty = foo.aProperty / 1 - self.aProperty = self.aProperty / 1 +self.aProperty = self.aProperty / 1 - foo = foo + 1 +foo = foo + 1 - foo = foo + aVariable +foo = foo + aVariable - foo = foo + bar.method() +foo = foo + bar.method() - foo.aProperty = foo.aProperty + 1 +foo.aProperty = foo.aProperty + 1 - self.aProperty = self.aProperty + 1 +self.aProperty = self.aProperty + 1 - foo = foo * 1 +foo = foo * 1 - foo = foo * aVariable +foo = foo * aVariable - foo = foo * bar.method() +foo = foo * bar.method() - foo.aProperty = foo.aProperty * 1 +foo.aProperty = foo.aProperty * 1 - self.aProperty = self.aProperty * 1 +self.aProperty = self.aProperty * 1 - n = n + i / outputLength +n = n + i / outputLength - n = n - i / outputLength +n = n - i / outputLength diff --git a/docs/tests/vertical_parameter_alignment.swift b/docs/tests/vertical_parameter_alignment.swift index eca126f..b22fa42 100644 --- a/docs/tests/vertical_parameter_alignment.swift +++ b/docs/tests/vertical_parameter_alignment.swift @@ -1,18 +1,26 @@ //#Patterns: vertical_parameter_alignment -//#Issue: {"severity": "Warning", "line": 9, "patternId": "vertical_parameter_alignment"} -//#Issue: {"severity": "Warning", "line": 13, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 11, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "vertical_parameter_alignment"} //#Issue: {"severity": "Warning", "line": 17, "patternId": "vertical_parameter_alignment"} //#Issue: {"severity": "Warning", "line": 18, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "vertical_parameter_alignment"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "vertical_parameter_alignment"} - func validateFunction(_ file: File, kind: SwiftDeclarationKind, - dictionary: [String: SourceKitRepresentable]) { } +func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind, + dictionary: SourceKittenDictionary) { } +func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind, + dictionary: SourceKittenDictionary) { } - func validateFunction(_ file: File, kind: SwiftDeclarationKind, - dictionary: [String: SourceKitRepresentable]) { } +func validateFunction(_ file: SwiftLintFile, + kind: SwiftDeclarationKind, + dictionary: SourceKittenDictionary) { } +func foo(data: Data, + @ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {} - func validateFunction(_ file: File, - kind: SwiftDeclarationKind, - dictionary: [String: SourceKitRepresentable]) { } +class A { + init(data: Data, + @ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {} +} From 0c886cf4b8fb1d07db56dd3c39b88a71cb6f6c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Pires?= Date: Sat, 9 Dec 2023 14:04:25 +0000 Subject: [PATCH 100/119] fix: tests --- README.md | 2 +- docs/tests/control_statement.swift | 26 +++++----- docs/tests/first_where.swift | 31 ++++++----- docs/tests/implicit_getter.swift | 79 +++++++++++++++-------------- docs/tests/statement_position.swift | 19 ++++--- docs/tests/strict_fileprivate.swift | 61 ++++++++++------------ docs/tests/unused_enumerated.swift | 15 +++--- 7 files changed, 115 insertions(+), 118 deletions(-) diff --git a/README.md b/README.md index eca09ff..8fdf593 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/c19f9b18251e4dc5bce89b0a70d0bc70)](https://app.codacy.com/gh/codacy/codacy-swiftlint?utm_source=github.com&utm_medium=referral&utm_content=codacy/codacy-swiftlint&utm_campaign=Badge_Grade_Settings) -[![Build Status](https://circleci.com/gh/codacy/codacy-swiftlint.svg?style=shield&circle-token=:circle-token)](https://circleci.com/gh/codacy/codacy-swiftlint) +[![Build Status](https://circleci.com/gh/codacy/codacy-swiftlint.svg?style=svg)](https://circleci.com/gh/codacy/codacy-swiftlint) # Codacy Swiftlint diff --git a/docs/tests/control_statement.swift b/docs/tests/control_statement.swift index f6a03b6..94b6833 100644 --- a/docs/tests/control_statement.swift +++ b/docs/tests/control_statement.swift @@ -1,18 +1,18 @@ //#Patterns: control_statement -//#Issue: {"severity": "Warning", "line": 20, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 24, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 26, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 28, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 32, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 34, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 36, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 38, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 40, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 42, "patternId": "control_statement"} -//#Issue: {"severity": "Warning", "line": 44, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 33, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 37, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 39, "patternId": "control_statement"} +//#Issue: {"severity": "Warning", "line": 41, "patternId": "control_statement"} if (condition) {} diff --git a/docs/tests/first_where.swift b/docs/tests/first_where.swift index cd6b6a4..e812753 100644 --- a/docs/tests/first_where.swift +++ b/docs/tests/first_where.swift @@ -1,27 +1,30 @@ //#Patterns: first_where -//#Issue: {"severity": "Warning", "line": 10, "patternId": "first_where"} //#Issue: {"severity": "Warning", "line": 13, "patternId": "first_where"} -//#Issue: {"severity": "Warning", "line": 16, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "first_where"} //#Issue: {"severity": "Warning", "line": 19, "patternId": "first_where"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "first_where"} -//#Issue: {"severity": "Warning", "line": 25, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 28, "patternId": "first_where"} +//#Issue: {"severity": "Warning", "line": 30, "patternId": "first_where"} - myList.filter { $0 % 2 == 0 }.first +myList.filter { $0 % 2 == 0 }.first +myList.filter({ $0 % 2 == 0 }).first - myList.filter({ $0 % 2 == 0 }).first +myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).first +myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).first?.something() - myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).first +myList.filter(someFunction).first +myList.filter({ $0 % 2 == 0 }) +.first - myList.map { $0 + 1 }.filter({ $0 % 2 == 0 }).first?.something() +(myList.filter { $0 == 1 }).first +myListOfDict.filter { dict in dict["1"] }.first - myList.filter(someFunction).first - - - myList.filter({ $0 % 2 == 0 }) - .first - +myListOfDict.filter { $0["someString"] }.first diff --git a/docs/tests/implicit_getter.swift b/docs/tests/implicit_getter.swift index 4a1354c..84fdfad 100644 --- a/docs/tests/implicit_getter.swift +++ b/docs/tests/implicit_getter.swift @@ -1,55 +1,58 @@ //#Patterns: implicit_getter -//#Issue: {"severity": "Warning", "line": 11, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "implicit_getter"} //#Issue: {"severity": "Warning", "line": 21, "patternId": "implicit_getter"} -//#Issue: {"severity": "Warning", "line": 31, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 34, "patternId": "implicit_getter"} //#Issue: {"severity": "Warning", "line": 40, "patternId": "implicit_getter"} -//#Issue: {"severity": "Warning", "line": 49, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 48, "patternId": "implicit_getter"} +//#Issue: {"severity": "Warning", "line": 54, "patternId": "implicit_getter"} - class Foo { - var foo: Int { - get { - return 20 - } - } - } +class Foo { + var foo: Int { + get { + return 20 + } } +} - - class Foo { - var foo: Int { - get{ - return 20 - } - } - } +class Foo { + var foo: Int { + get{ return 20 } } +} - - class Foo { - static var foo: Int { - get { - return 20 - } - } - } +class Foo { + static var foo: Int { + get { + return 20 + } } +} +var foo: Int { + get { return 20 } +} +class Foo { + @objc func bar() {} var foo: Int { - get { - return 20 - } - } + get { + return 20 + } } +} - class Foo { - @objc func bar() { } - var foo: Int { - get { - return 20 - } - } +extension Foo { + var bar: Bool { + get { _bar } } +} + +class Foo { + subscript(i: Int) -> Int { + get { + return 20 + } } - +} diff --git a/docs/tests/statement_position.swift b/docs/tests/statement_position.swift index 721cc72..7def736 100644 --- a/docs/tests/statement_position.swift +++ b/docs/tests/statement_position.swift @@ -1,16 +1,19 @@ //#Patterns: statement_position -//#Issue: {"severity": "Warning", "line": 8, "patternId": "statement_position"} //#Issue: {"severity": "Warning", "line": 10, "patternId": "statement_position"} //#Issue: {"severity": "Warning", "line": 12, "patternId": "statement_position"} -//#Issue: {"severity": "Warning", "line": 15, "patternId": "statement_position"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "statement_position"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "statement_position"} - }else if { +if { - } else { +↓}else if { - } - catch { +↓} else { - } - catch { +↓} +catch { + +↓} + catch { +} diff --git a/docs/tests/strict_fileprivate.swift b/docs/tests/strict_fileprivate.swift index ab55faf..89ae6a6 100644 --- a/docs/tests/strict_fileprivate.swift +++ b/docs/tests/strict_fileprivate.swift @@ -1,42 +1,33 @@ //#Patterns: strict_fileprivate -//#Issue: {"severity": "Warning", "line": 12, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Warning", "line": 15, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Warning", "line": 19, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Warning", "line": 24, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Warning", "line": 34, "patternId": "strict_fileprivate"} -//#Issue: {"severity": "Warning", "line": 40, "patternId": "strict_fileprivate"} - - -fileprivate extension String {} - - -fileprivate -extension String {} - - -fileprivate extension -String {} - - -extension String { - fileprivate func Something(){} -} - - -class MyClass { - fileprivate let myInt = 4 -} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 18, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 22, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 25, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 26, "patternId": "strict_fileprivate"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "strict_fileprivate"} + + fileprivate class C { + fileprivate func f() {} + } + fileprivate extension String { + fileprivate var isSomething: Bool { self == "something" } + } -class MyClass { - fileprivate(set) var myInt = 4 -} + fileprivate actor A { + fileprivate let i = 1 + } + fileprivate struct C { + fileprivate(set) var myInt = 4 + } -struct Outter { - struct Inter { - fileprivate struct Inner {} + struct Outter { + struct Inter { + fileprivate struct Inner {} + } } -} diff --git a/docs/tests/unused_enumerated.swift b/docs/tests/unused_enumerated.swift index fefbb13..cfc281c 100644 --- a/docs/tests/unused_enumerated.swift +++ b/docs/tests/unused_enumerated.swift @@ -1,17 +1,14 @@ //#Patterns: unused_enumerated //#Issue: {"severity": "Warning", "line": 8, "patternId": "unused_enumerated"} -//#Issue: {"severity": "Warning", "line": 11, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "unused_enumerated"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "unused_enumerated"} //#Issue: {"severity": "Warning", "line": 14, "patternId": "unused_enumerated"} -//#Issue: {"severity": "Warning", "line": 17, "patternId": "unused_enumerated"} - for (_, foo) in bar.enumerated() { } +for (_, foo) in bar.enumerated() { } +for (_, foo) in abc.bar.enumerated() { } - for (_, foo) in abc.bar.enumerated() { } +for (_, foo) in abc.something().enumerated() { } - - for (_, foo) in abc.something().enumerated() { } - - - for (idx, _) in bar.enumerated() { } +for (idx, _) in bar.enumerated() { } From 977370bac1f0242aac80f74f9eaab5f3d88bf160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Pires?= Date: Sat, 9 Dec 2023 14:16:27 +0000 Subject: [PATCH 101/119] fix: tests --- ...vertical_parameter_alignment_on_call.swift | 64 +++++++++++-------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/docs/tests/vertical_parameter_alignment_on_call.swift b/docs/tests/vertical_parameter_alignment_on_call.swift index d9a51b8..979559a 100644 --- a/docs/tests/vertical_parameter_alignment_on_call.swift +++ b/docs/tests/vertical_parameter_alignment_on_call.swift @@ -1,30 +1,38 @@ //#Patterns: vertical_parameter_alignment_on_call -//#Issue: {"severity": "Warning", "line": 12, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Warning", "line": 15, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Warning", "line": 19, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Warning", "line": 22, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Warning", "line": 27, "patternId": "vertical_parameter_alignment_on_call"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "vertical_parameter_alignment_on_call"} - - foo(param1: 1, param2: bar - param3: false, param4: true) - - foo(param1: 1, param2: bar - param3: false, param4: true) - - foo(param1: 1, param2: bar - param3: false, - param4: true) - - foo(param1: 1, - param2: { _ in }) - - foo(param1: 1, - param2: { _ in - }, param3: 2, - param4: 0) - - foo(param1: 1, param2: { _ in }, - param3: false, param4: true) +//#Issue: {"severity": "Warning", "line": 14, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 20, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 21, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 24, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 29, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 32, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "vertical_parameter_alignment_on_call"} +//#Issue: {"severity": "Warning", "line": 38, "patternId": "vertical_parameter_alignment_on_call"} + +foo(param1: 1, param2: bar, + param3: false, param4: true) + +foo(param1: 1, param2: bar, + param3: false, param4: true) + +foo(param1: 1, param2: bar, + param3: false, + param4: true) + +foo(param1: 1, + param2: { _ in }) + +foo(param1: 1, + param2: { _ in +}, param3: 2, + param4: 0) + +foo(param1: 1, param2: { _ in }, + param3: false, param4: true) + +myFunc(foo: 0, + bar: baz == 0) + +myFunc(foo: 0, bar: + baz == 0, baz: true) From cf3e847c291e2523d69641089d098b78bd2f4865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Pires?= Date: Sat, 9 Dec 2023 14:55:27 +0000 Subject: [PATCH 102/119] fix: tests --- docs/tests/compiler_protocol_init.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/tests/compiler_protocol_init.swift b/docs/tests/compiler_protocol_init.swift index 532ece5..6ae9ab9 100644 --- a/docs/tests/compiler_protocol_init.swift +++ b/docs/tests/compiler_protocol_init.swift @@ -1,9 +1,14 @@ //#Patterns: compiler_protocol_init -//#Issue: {"severity": "Warning", "line": 6, "patternId": "compiler_protocol_init"} -//#Issue: {"severity": "Warning", "line": 9, "patternId": "compiler_protocol_init"} +//#Issue: {"severity": "Warning", "line": 8, "patternId": "compiler_protocol_init"} +//#Issue: {"severity": "Warning", "line": 10, "patternId": "compiler_protocol_init"} +//#Issue: {"severity": "Warning", "line": 12, "patternId": "compiler_protocol_init"} +//#Issue: {"severity": "Warning", "line": 14, "patternId": "compiler_protocol_init"} - let set = Set(arrayLiteral: 1, 2) +let set = ↓Set(arrayLiteral: 1, 2) +let set = ↓Set (arrayLiteral: 1, 2) - let set = Set.init(arrayLiteral: 1, 2) +let set = ↓Set.init(arrayLiteral: 1, 2) + +let set = ↓Set.init(arrayLiteral : 1, 2) From a9b17e14738e880e621bde5a237d2fb270d3c3ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Pires?= Date: Sat, 9 Dec 2023 15:32:01 +0000 Subject: [PATCH 103/119] fix: tests --- .circleci/config.yml | 3 +- docs/multiple-tests/filter-files/patterns.xml | 4 +- docs/multiple-tests/filter-files/results.xml | 4 +- .../filter-files/src/.swiftlint.yml | 2 + .../filter-files/src/closing_brace.swift | 10 +---- .../filter-files/src/dynamic_inline.swift | 44 ++++++++----------- .../patterns.xml | 3 +- .../multiple-files/patterns.xml | 3 +- .../multiple-tests/multiple-files/results.xml | 14 +++--- .../multiple-files/src/.swiftlint.yml | 2 + .../multiple-files/src/closing_brace.swift | 10 +---- .../multiple-files/src/dynamic_inline.swift | 44 ++++++++----------- .../use-codacy-conf/patterns.xml | 4 +- .../use-codacy-conf/results.xml | 11 +++-- .../use-codacy-conf/src/.swiftlint.yml | 2 - .../use-codacy-conf/src/closing_brace.swift | 10 +---- .../use-codacy-conf/src/dynamic_inline.swift | 44 ++++++++----------- docs/multiple-tests/with-config/patterns.xml | 3 +- docs/multiple-tests/with-config/results.xml | 5 +-- .../with-config/src/closing_brace.swift | 10 +---- .../with-config/src/dynamic_inline.swift | 44 ++++++++----------- docs/tests/closing_brace.swift | 5 +-- 22 files changed, 109 insertions(+), 172 deletions(-) delete mode 100644 docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index ca2f018..f8d9b33 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,10 +2,9 @@ version: 2.1 orbs: codacy: codacy/base@10.11.1 - codacy_plugins_test: codacy/plugins-test@1.1.1 + codacy_plugins_test: codacy/plugins-test@2.0.3 workflows: - version: 2 compile_test_deploy: jobs: - codacy/checkout_and_version: diff --git a/docs/multiple-tests/filter-files/patterns.xml b/docs/multiple-tests/filter-files/patterns.xml index 94ef14d..82d33bb 100644 --- a/docs/multiple-tests/filter-files/patterns.xml +++ b/docs/multiple-tests/filter-files/patterns.xml @@ -1,7 +1,7 @@ - - + + diff --git a/docs/multiple-tests/filter-files/results.xml b/docs/multiple-tests/filter-files/results.xml index d1f4700..27212ed 100644 --- a/docs/multiple-tests/filter-files/results.xml +++ b/docs/multiple-tests/filter-files/results.xml @@ -1,7 +1,7 @@ - - + + diff --git a/docs/multiple-tests/filter-files/src/.swiftlint.yml b/docs/multiple-tests/filter-files/src/.swiftlint.yml index 8807964..7be436b 100644 --- a/docs/multiple-tests/filter-files/src/.swiftlint.yml +++ b/docs/multiple-tests/filter-files/src/.swiftlint.yml @@ -1,3 +1,5 @@ only_rules: - closing_brace - dynamic_inline + - first_where + - unused_enumerated diff --git a/docs/multiple-tests/filter-files/src/closing_brace.swift b/docs/multiple-tests/filter-files/src/closing_brace.swift index 9196728..842492f 100644 --- a/docs/multiple-tests/filter-files/src/closing_brace.swift +++ b/docs/multiple-tests/filter-files/src/closing_brace.swift @@ -1,9 +1,3 @@ -//#Patterns: closing_brace +[].map({ } ) -//#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} - - [].map({ } ) - - [].map({ } ) - +[].map({ } ) diff --git a/docs/multiple-tests/filter-files/src/dynamic_inline.swift b/docs/multiple-tests/filter-files/src/dynamic_inline.swift index da8e096..635fee5 100644 --- a/docs/multiple-tests/filter-files/src/dynamic_inline.swift +++ b/docs/multiple-tests/filter-files/src/dynamic_inline.swift @@ -1,30 +1,22 @@ -//#Patterns: dynamic_inline +class C { +@inline(__always) dynamic func f() {} +} -//#Issue: {"severity": "Warning", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "dynamic_inline"} +class C { +@inline(__always) public dynamic func f() {} +} - class C { - @inline(__always) dynamic func f() {} - } +class C { +@inline(__always) dynamic internal func f() {} +} - class C { - @inline(__always) public dynamic func f() {} - } +class C { +@inline(__always) +dynamic func f() {} +} - class C { - @inline(__always) dynamic internal func f() {} - } - - class C { - @inline(__always) - dynamic func f() {} - } - - class C { - @inline(__always) - dynamic - func f() {} - } +class C { +@inline(__always) +dynamic +func f() {} +} diff --git a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml index b08b9a3..a36de62 100644 --- a/docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml +++ b/docs/multiple-tests/multiple-config-submodules-and-custom-rules/patterns.xml @@ -1,7 +1,6 @@ - - + diff --git a/docs/multiple-tests/multiple-files/patterns.xml b/docs/multiple-tests/multiple-files/patterns.xml index b08b9a3..a36de62 100644 --- a/docs/multiple-tests/multiple-files/patterns.xml +++ b/docs/multiple-tests/multiple-files/patterns.xml @@ -1,7 +1,6 @@ - - + diff --git a/docs/multiple-tests/multiple-files/results.xml b/docs/multiple-tests/multiple-files/results.xml index 1eeea34..5d10379 100644 --- a/docs/multiple-tests/multiple-files/results.xml +++ b/docs/multiple-tests/multiple-files/results.xml @@ -1,14 +1,14 @@ - - + + - - - - - + + + + + diff --git a/docs/multiple-tests/multiple-files/src/.swiftlint.yml b/docs/multiple-tests/multiple-files/src/.swiftlint.yml index 8807964..7be436b 100644 --- a/docs/multiple-tests/multiple-files/src/.swiftlint.yml +++ b/docs/multiple-tests/multiple-files/src/.swiftlint.yml @@ -1,3 +1,5 @@ only_rules: - closing_brace - dynamic_inline + - first_where + - unused_enumerated diff --git a/docs/multiple-tests/multiple-files/src/closing_brace.swift b/docs/multiple-tests/multiple-files/src/closing_brace.swift index 9196728..842492f 100644 --- a/docs/multiple-tests/multiple-files/src/closing_brace.swift +++ b/docs/multiple-tests/multiple-files/src/closing_brace.swift @@ -1,9 +1,3 @@ -//#Patterns: closing_brace +[].map({ } ) -//#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} - - [].map({ } ) - - [].map({ } ) - +[].map({ } ) diff --git a/docs/multiple-tests/multiple-files/src/dynamic_inline.swift b/docs/multiple-tests/multiple-files/src/dynamic_inline.swift index da8e096..635fee5 100644 --- a/docs/multiple-tests/multiple-files/src/dynamic_inline.swift +++ b/docs/multiple-tests/multiple-files/src/dynamic_inline.swift @@ -1,30 +1,22 @@ -//#Patterns: dynamic_inline +class C { +@inline(__always) dynamic func f() {} +} -//#Issue: {"severity": "Warning", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "dynamic_inline"} +class C { +@inline(__always) public dynamic func f() {} +} - class C { - @inline(__always) dynamic func f() {} - } +class C { +@inline(__always) dynamic internal func f() {} +} - class C { - @inline(__always) public dynamic func f() {} - } +class C { +@inline(__always) +dynamic func f() {} +} - class C { - @inline(__always) dynamic internal func f() {} - } - - class C { - @inline(__always) - dynamic func f() {} - } - - class C { - @inline(__always) - dynamic - func f() {} - } +class C { +@inline(__always) +dynamic +func f() {} +} diff --git a/docs/multiple-tests/use-codacy-conf/patterns.xml b/docs/multiple-tests/use-codacy-conf/patterns.xml index 250d6d1..34aafb8 100644 --- a/docs/multiple-tests/use-codacy-conf/patterns.xml +++ b/docs/multiple-tests/use-codacy-conf/patterns.xml @@ -1,9 +1,7 @@ - - + - diff --git a/docs/multiple-tests/use-codacy-conf/results.xml b/docs/multiple-tests/use-codacy-conf/results.xml index 7146716..883bce8 100644 --- a/docs/multiple-tests/use-codacy-conf/results.xml +++ b/docs/multiple-tests/use-codacy-conf/results.xml @@ -1,11 +1,10 @@ - - - - - - + + + + + diff --git a/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml b/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml deleted file mode 100644 index 22259b0..0000000 --- a/docs/multiple-tests/use-codacy-conf/src/.swiftlint.yml +++ /dev/null @@ -1,2 +0,0 @@ -only_rules: - - closing_brace diff --git a/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift b/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift index 9196728..842492f 100644 --- a/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift +++ b/docs/multiple-tests/use-codacy-conf/src/closing_brace.swift @@ -1,9 +1,3 @@ -//#Patterns: closing_brace +[].map({ } ) -//#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} - - [].map({ } ) - - [].map({ } ) - +[].map({ } ) diff --git a/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift b/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift index da8e096..635fee5 100644 --- a/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift +++ b/docs/multiple-tests/use-codacy-conf/src/dynamic_inline.swift @@ -1,30 +1,22 @@ -//#Patterns: dynamic_inline +class C { +@inline(__always) dynamic func f() {} +} -//#Issue: {"severity": "Warning", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "dynamic_inline"} +class C { +@inline(__always) public dynamic func f() {} +} - class C { - @inline(__always) dynamic func f() {} - } +class C { +@inline(__always) dynamic internal func f() {} +} - class C { - @inline(__always) public dynamic func f() {} - } +class C { +@inline(__always) +dynamic func f() {} +} - class C { - @inline(__always) dynamic internal func f() {} - } - - class C { - @inline(__always) - dynamic func f() {} - } - - class C { - @inline(__always) - dynamic - func f() {} - } +class C { +@inline(__always) +dynamic +func f() {} +} diff --git a/docs/multiple-tests/with-config/patterns.xml b/docs/multiple-tests/with-config/patterns.xml index b08b9a3..a36de62 100644 --- a/docs/multiple-tests/with-config/patterns.xml +++ b/docs/multiple-tests/with-config/patterns.xml @@ -1,7 +1,6 @@ - - + diff --git a/docs/multiple-tests/with-config/results.xml b/docs/multiple-tests/with-config/results.xml index da8dbec..27212ed 100644 --- a/docs/multiple-tests/with-config/results.xml +++ b/docs/multiple-tests/with-config/results.xml @@ -1,8 +1,7 @@ - - + + - diff --git a/docs/multiple-tests/with-config/src/closing_brace.swift b/docs/multiple-tests/with-config/src/closing_brace.swift index 9196728..842492f 100644 --- a/docs/multiple-tests/with-config/src/closing_brace.swift +++ b/docs/multiple-tests/with-config/src/closing_brace.swift @@ -1,9 +1,3 @@ -//#Patterns: closing_brace +[].map({ } ) -//#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} -//#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} - - [].map({ } ) - - [].map({ } ) - +[].map({ } ) diff --git a/docs/multiple-tests/with-config/src/dynamic_inline.swift b/docs/multiple-tests/with-config/src/dynamic_inline.swift index da8e096..635fee5 100644 --- a/docs/multiple-tests/with-config/src/dynamic_inline.swift +++ b/docs/multiple-tests/with-config/src/dynamic_inline.swift @@ -1,30 +1,22 @@ -//#Patterns: dynamic_inline +class C { +@inline(__always) dynamic func f() {} +} -//#Issue: {"severity": "Warning", "line": 10, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 14, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 18, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 23, "patternId": "dynamic_inline"} -//#Issue: {"severity": "Warning", "line": 29, "patternId": "dynamic_inline"} +class C { +@inline(__always) public dynamic func f() {} +} - class C { - @inline(__always) dynamic func f() {} - } +class C { +@inline(__always) dynamic internal func f() {} +} - class C { - @inline(__always) public dynamic func f() {} - } +class C { +@inline(__always) +dynamic func f() {} +} - class C { - @inline(__always) dynamic internal func f() {} - } - - class C { - @inline(__always) - dynamic func f() {} - } - - class C { - @inline(__always) - dynamic - func f() {} - } +class C { +@inline(__always) +dynamic +func f() {} +} diff --git a/docs/tests/closing_brace.swift b/docs/tests/closing_brace.swift index 9196728..7ccc470 100644 --- a/docs/tests/closing_brace.swift +++ b/docs/tests/closing_brace.swift @@ -3,7 +3,6 @@ //#Issue: {"severity": "Warning", "line": 6, "patternId": "closing_brace"} //#Issue: {"severity": "Warning", "line": 8, "patternId": "closing_brace"} - [].map({ } ) +[].map({ } ) - [].map({ } ) - +[].map({ } ) From 07c7a3a340a3372cb30b72696029af8985981e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Pires?= Date: Sat, 9 Dec 2023 15:50:34 +0000 Subject: [PATCH 104/119] fix: revert plugins-test --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f8d9b33..7af2bb8 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 orbs: codacy: codacy/base@10.11.1 - codacy_plugins_test: codacy/plugins-test@2.0.3 + codacy_plugins_test: codacy/plugins-test@1.1.1 workflows: compile_test_deploy: From 0357e628b674b0749dc28248aab293e1daedefd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Pires?= Date: Sat, 9 Dec 2023 16:03:20 +0000 Subject: [PATCH 105/119] fix: tests --- docs/multiple-tests/filter-files/patterns.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/multiple-tests/filter-files/patterns.xml b/docs/multiple-tests/filter-files/patterns.xml index 82d33bb..cb37919 100644 --- a/docs/multiple-tests/filter-files/patterns.xml +++ b/docs/multiple-tests/filter-files/patterns.xml @@ -1,7 +1,6 @@ - - + From 91018be26bd5a3053af0a4809ed7c599cd5da924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Pires?= Date: Sat, 9 Dec 2023 16:16:53 +0000 Subject: [PATCH 106/119] fix: tests --- docs/multiple-tests/multiple-files/results.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/multiple-tests/multiple-files/results.xml b/docs/multiple-tests/multiple-files/results.xml index 5d10379..b25e73f 100644 --- a/docs/multiple-tests/multiple-files/results.xml +++ b/docs/multiple-tests/multiple-files/results.xml @@ -1,14 +1,14 @@ - - + + - + + - - - + + From e7f05edf4bac93bc87feb90a9871e410247a9dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Pires?= Date: Sat, 9 Dec 2023 16:55:45 +0000 Subject: [PATCH 107/119] bump: plugins-test --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7af2bb8..f8d9b33 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 orbs: codacy: codacy/base@10.11.1 - codacy_plugins_test: codacy/plugins-test@1.1.1 + codacy_plugins_test: codacy/plugins-test@2.0.3 workflows: compile_test_deploy: From b3c7076591976c791092178e08e381d51500e5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Pires?= Date: Mon, 11 Dec 2023 13:51:35 +0000 Subject: [PATCH 108/119] revert: plugins-test; update rule; --- .circleci/config.yml | 2 +- docs/tests/array_init.swift | 57 +++++++++++++++---------------------- 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f8d9b33..7af2bb8 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 orbs: codacy: codacy/base@10.11.1 - codacy_plugins_test: codacy/plugins-test@2.0.3 + codacy_plugins_test: codacy/plugins-test@1.1.1 workflows: compile_test_deploy: diff --git a/docs/tests/array_init.swift b/docs/tests/array_init.swift index 31471c2..bdb33a9 100644 --- a/docs/tests/array_init.swift +++ b/docs/tests/array_init.swift @@ -1,48 +1,37 @@ //#Patterns: array_init -//#Issue: {"severity": "Warning", "line": 12, "patternId": "array_init"} -//#Issue: {"severity": "Warning", "line": 16, "patternId": "array_init"} -//#Issue: {"severity": "Warning", "line": 20, "patternId": "array_init"} -//#Issue: {"severity": "Warning", "line": 24, "patternId": "array_init"} -//#Issue: {"severity": "Warning", "line": 30, "patternId": "array_init"} -//#Issue: {"severity": "Warning", "line": 36, "patternId": "array_init"} -//#Issue: {"severity": "Warning", "line": 42, "patternId": "array_init"} -//#Issue: {"severity": "Warning", "line": 48, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 13, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 15, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 17, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 19, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 23, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 27, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 31, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 35, "patternId": "array_init"} +//#Issue: {"severity": "Warning", "line": 37, "patternId": "array_init"} foo.map({ $0 }) - - foo.map { $0 } - - foo.map { return $0 } + foo.map { elem in + elem + } + foo.map { elem in + return elem + } -foo.map { elem in - elem -} - - - -foo.map { elem in - return elem -} - - - -foo.map { (elem: String) in - elem -} - - - -foo.map { elem -> String in - elem -} - + foo.map { (elem: String) in + elem + } + foo.map { elem -> String in + elem + } foo.map { $0 /* a comment */ } + +foo.map { /* a comment */ $0 } From e4db7ddf37a86b8f0e3ad8cc7c0a37a5fae65570 Mon Sep 17 00:00:00 2001 From: stefanvacareanu7 <91726880+stefanvacareanu7@users.noreply.github.com> Date: Tue, 30 Jan 2024 12:54:02 +0200 Subject: [PATCH 109/119] Fix vulnerabilities TCE-788 (#46) * Fix vulnerabilities TCE-788 * Undo changes --- .circleci/config.yml | 2 +- docs/patterns.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7af2bb8..850cb14 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codacy: codacy/base@10.11.1 + codacy: codacy/base@10.11.2 codacy_plugins_test: codacy/plugins-test@1.1.1 workflows: diff --git a/docs/patterns.json b/docs/patterns.json index 414ce31..8a92308 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -1,6 +1,6 @@ { "name" : "swiftlint", - "version" : "0.53.0", + "version" : "0.54.0", "patterns" : [ { "patternId" : "accessibility_label_for_image", "level" : "Warning", From 7f1b7cba5aa198eb5978acdd196a47afdbe1bb33 Mon Sep 17 00:00:00 2001 From: David Marinho Date: Mon, 6 May 2024 12:27:29 +0100 Subject: [PATCH 110/119] bump some packages --- .circleci/config.yml | 4 ++-- build.sbt | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 850cb14..1cc5683 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ version: 2.1 orbs: - codacy: codacy/base@10.11.2 - codacy_plugins_test: codacy/plugins-test@1.1.1 + codacy: codacy/base@11.1.2 + codacy_plugins_test: codacy/plugins-test@2.0.10 workflows: compile_test_deploy: diff --git a/build.sbt b/build.sbt index 6e115c0..e9f22c3 100755 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ enablePlugins(NativeImagePlugin) enablePlugins(JavaAppPackaging) -libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "6.0.1") +libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "6.1.2") Compile / mainClass := Some("codacy.Engine") @@ -17,8 +17,8 @@ nativeImageOptions ++= Seq("-O1", "-H:+ReportExceptionStackTraces", "--no-fallba lazy val `doc-generator` = project .settings( libraryDependencies ++= Seq( - "com.codacy" %% "codacy-engine-scala-seed" % "6.0.1", - "com.lihaoyi" %% "os-lib" % "0.9.0" + "com.codacy" %% "codacy-engine-scala-seed" % "6.1.2", + "com.lihaoyi" %% "os-lib" % "0.10.0" ) ) .enablePlugins(JavaAppPackaging) From 45351d8b038faaf47fcdcdd81a72dad3c5a14491 Mon Sep 17 00:00:00 2001 From: David Marinho Date: Mon, 6 May 2024 14:22:43 +0100 Subject: [PATCH 111/119] [test] downgrade codacy/base --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1cc5683..39d7501 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codacy: codacy/base@11.1.2 + codacy: codacy/base@10.11.2 codacy_plugins_test: codacy/plugins-test@2.0.10 workflows: From 7ea8440d21e254f4015082b313437c477e3ee793 Mon Sep 17 00:00:00 2001 From: David Marinho Date: Mon, 6 May 2024 14:29:54 +0100 Subject: [PATCH 112/119] bump codacy/base --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 39d7501..1cc5683 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - codacy: codacy/base@10.11.2 + codacy: codacy/base@11.1.2 codacy_plugins_test: codacy/plugins-test@2.0.10 workflows: From d79a95261e8f86219d9bf48cfad35d974ab342a9 Mon Sep 17 00:00:00 2001 From: David Marinho Date: Mon, 6 May 2024 14:31:56 +0100 Subject: [PATCH 113/119] downgrade plugins_test --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1cc5683..dfed6ab 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 orbs: codacy: codacy/base@11.1.2 - codacy_plugins_test: codacy/plugins-test@2.0.10 + codacy_plugins_test: codacy/plugins-test@1.1.1 workflows: compile_test_deploy: From 0990106159e930a3f1fdb9e987690cbb2884b8c6 Mon Sep 17 00:00:00 2001 From: David Marinho Date: Mon, 6 May 2024 14:33:50 +0100 Subject: [PATCH 114/119] bump plugins-test --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dfed6ab..1cc5683 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 orbs: codacy: codacy/base@11.1.2 - codacy_plugins_test: codacy/plugins-test@1.1.1 + codacy_plugins_test: codacy/plugins-test@2.0.10 workflows: compile_test_deploy: From 54ee50115ebcda917f93b62c655a07ec254a016a Mon Sep 17 00:00:00 2001 From: David Marinho Date: Mon, 6 May 2024 14:36:44 +0100 Subject: [PATCH 115/119] bump plugins-test --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index e9f22c3..6e115c0 100755 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ enablePlugins(NativeImagePlugin) enablePlugins(JavaAppPackaging) -libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "6.1.2") +libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "6.0.1") Compile / mainClass := Some("codacy.Engine") @@ -17,8 +17,8 @@ nativeImageOptions ++= Seq("-O1", "-H:+ReportExceptionStackTraces", "--no-fallba lazy val `doc-generator` = project .settings( libraryDependencies ++= Seq( - "com.codacy" %% "codacy-engine-scala-seed" % "6.1.2", - "com.lihaoyi" %% "os-lib" % "0.10.0" + "com.codacy" %% "codacy-engine-scala-seed" % "6.0.1", + "com.lihaoyi" %% "os-lib" % "0.9.0" ) ) .enablePlugins(JavaAppPackaging) From 7c15f7faa7d9d33dd1063beab381d10bbeb37997 Mon Sep 17 00:00:00 2001 From: David Marinho Date: Mon, 6 May 2024 17:13:36 +0100 Subject: [PATCH 116/119] bump version --- .circleci/config.yml | 4 ++-- build.sbt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1cc5683..f24b5e5 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ version: 2.1 orbs: - codacy: codacy/base@11.1.2 - codacy_plugins_test: codacy/plugins-test@2.0.10 + codacy: codacy/base@12.0.0 + codacy_plugins_test: codacy/plugins-test@2.0.11 workflows: compile_test_deploy: diff --git a/build.sbt b/build.sbt index 6e115c0..0768914 100755 --- a/build.sbt +++ b/build.sbt @@ -2,13 +2,13 @@ organization := "com.codacy" name := "codacy-swiftlint" -ThisBuild / scalaVersion := "2.13.10" +ThisBuild / scalaVersion := "3.4.1" enablePlugins(NativeImagePlugin) enablePlugins(JavaAppPackaging) -libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "6.0.1") +libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "6.1.2") Compile / mainClass := Some("codacy.Engine") @@ -17,8 +17,8 @@ nativeImageOptions ++= Seq("-O1", "-H:+ReportExceptionStackTraces", "--no-fallba lazy val `doc-generator` = project .settings( libraryDependencies ++= Seq( - "com.codacy" %% "codacy-engine-scala-seed" % "6.0.1", - "com.lihaoyi" %% "os-lib" % "0.9.0" + "com.codacy" %% "codacy-engine-scala-seed" % "6.1.2", + "com.lihaoyi" %% "os-lib" % "0.10.0" ) ) .enablePlugins(JavaAppPackaging) From 9efc49c59b0adba7056a4c2868b59132b594c33e Mon Sep 17 00:00:00 2001 From: David Marinho Date: Mon, 6 May 2024 17:17:18 +0100 Subject: [PATCH 117/119] fix scala version --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 0768914..c5a18dc 100755 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ organization := "com.codacy" name := "codacy-swiftlint" -ThisBuild / scalaVersion := "3.4.1" +ThisBuild / scalaVersion := "2.13.14" enablePlugins(NativeImagePlugin) From de73631c30eeee4685fe6ee4379278b3108710a8 Mon Sep 17 00:00:00 2001 From: David Marinho Date: Mon, 6 May 2024 17:37:53 +0100 Subject: [PATCH 118/119] add library better-files --- build.sbt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index c5a18dc..ed755ad 100755 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,10 @@ enablePlugins(NativeImagePlugin) enablePlugins(JavaAppPackaging) -libraryDependencies ++= Seq("com.codacy" %% "codacy-engine-scala-seed" % "6.1.2") +libraryDependencies ++= Seq( + "com.codacy" %% "codacy-engine-scala-seed" % "6.1.2", + "com.github.pathikrit" %% "better-files" % "3.9.2" + ) Compile / mainClass := Some("codacy.Engine") From 875c3ff7e21bbce9365f9088a63dbece59c553d3 Mon Sep 17 00:00:00 2001 From: David Marinho Date: Mon, 6 May 2024 18:31:26 +0100 Subject: [PATCH 119/119] add library better-files --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index ed755ad..602b802 100755 --- a/build.sbt +++ b/build.sbt @@ -9,9 +9,9 @@ enablePlugins(NativeImagePlugin) enablePlugins(JavaAppPackaging) libraryDependencies ++= Seq( - "com.codacy" %% "codacy-engine-scala-seed" % "6.1.2", - "com.github.pathikrit" %% "better-files" % "3.9.2" - ) + "com.codacy" %% "codacy-engine-scala-seed" % "6.1.2", + "com.github.pathikrit" %% "better-files" % "3.9.2" +) Compile / mainClass := Some("codacy.Engine")