diff --git a/sonar-swift-plugin/src/main/resources/com/sonar/sqale/swiftlint-model.xml b/sonar-swift-plugin/src/main/resources/com/sonar/sqale/swiftlint-model.xml index d7bfd998..820bbd2a 100644 --- a/sonar-swift-plugin/src/main/resources/com/sonar/sqale/swiftlint-model.xml +++ b/sonar-swift-plugin/src/main/resources/com/sonar/sqale/swiftlint-model.xml @@ -825,6 +825,58 @@ min + + SwiftLint + file_name + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + + + SwiftLint + function_default_parameter_at_end + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + + + SwiftLint + redundant_set_access_control + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + + + SwiftLint + untyped_error_in_catch + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + UNDERSTANDABILITY @@ -1336,6 +1388,97 @@ min + + SwiftLint + convenience_type + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + + + SwiftLint + discouraged_optional_collection + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + + + SwiftLint + empty_string + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + + + SwiftLint + empty_xctest_method + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + + + SwiftLint + modifier_order + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + + + SwiftLint + multiline_function_chains + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + + + SwiftLint + no_fallthrough_only + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + @@ -1344,6 +1487,19 @@ API_ABUSE API abuse + + SwiftLint + unavailable_function + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + ERRORS @@ -1421,6 +1577,19 @@ min + + SwiftLint + lower_acl_than_parent + + remediationFunction + CONSTANT_ISSUE + + + offset + 5 + min + + diff --git a/sonar-swift-plugin/src/main/resources/org/sonar/plugins/swiftlint/profile-swiftlint.xml b/sonar-swift-plugin/src/main/resources/org/sonar/plugins/swiftlint/profile-swiftlint.xml index ee5257f1..93636000 100644 --- a/sonar-swift-plugin/src/main/resources/org/sonar/plugins/swiftlint/profile-swiftlint.xml +++ b/sonar-swift-plugin/src/main/resources/org/sonar/plugins/swiftlint/profile-swiftlint.xml @@ -59,6 +59,10 @@ SwiftLint control_statement + + SwiftLint + convenience_type + SwiftLint custom_rules @@ -83,6 +87,10 @@ SwiftLint discouraged_optional_boolean + + SwiftLint + discouraged_optional_collection + SwiftLint dynamic_inline @@ -103,6 +111,14 @@ SwiftLint empty_parentheses_with_trailing_closure + + SwiftLint + empty_string + + + SwiftLint + empty_xctest_method + SwiftLint explicit_acl @@ -143,6 +159,10 @@ SwiftLint file_length + + SwiftLint + file_name + SwiftLint first_where @@ -167,6 +187,10 @@ SwiftLint function_body_length + + SwiftLint + function_default_parameter_at_end + SwiftLint function_parameter_count @@ -235,14 +259,26 @@ SwiftLint literal_expression_end_indentation + + SwiftLint + lower_acl_than_parent + SwiftLint mark + + SwiftLint + modifier_order + SwiftLint multiline_arguments + + SwiftLint + multiline_function_chains + SwiftLint multiline_parameters @@ -263,6 +299,10 @@ SwiftLint no_extension_access_modifier + + SwiftLint + no_fallthrough_only + SwiftLint no_grouping_extension @@ -355,6 +395,10 @@ SwiftLint redundant_optional_initialization + + SwiftLint + redundant_set_access_control + SwiftLint redundant_string_enum_value @@ -443,6 +487,10 @@ SwiftLint type_name + + SwiftLint + unavailable_function + SwiftLint unneeded_break_in_switch @@ -451,6 +499,10 @@ SwiftLint unneeded_parentheses_in_closure_argument + + SwiftLint + untyped_error_in_catch + SwiftLint unused_closure_parameter diff --git a/sonar-swift-plugin/src/main/resources/org/sonar/plugins/swiftlint/rules.json b/sonar-swift-plugin/src/main/resources/org/sonar/plugins/swiftlint/rules.json index 909eed7f..3c315281 100644 --- a/sonar-swift-plugin/src/main/resources/org/sonar/plugins/swiftlint/rules.json +++ b/sonar-swift-plugin/src/main/resources/org/sonar/plugins/swiftlint/rules.json @@ -3,7 +3,7 @@ "key": "array_init", "category": "SwiftLint", "name": "Array Init", - "description": "Prefer using Array(seq) than 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.", "severity": "MINOR" }, { @@ -97,6 +97,13 @@ "description": "if,for,while,do,catch statements shouldn't wrap their conditionals or arguments in parentheses.", "severity": "MINOR" }, + { + "key": "convenience_type", + "category": "SwiftLint", + "name": "Convenience Type", + "description": "Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation.", + "severity": "MINOR" + }, { "key": "custom_rules", "category": "SwiftLint", @@ -139,6 +146,13 @@ "description": "Prefer non-optional booleans over optional booleans.", "severity": "MINOR" }, + { + "key": "discouraged_optional_collection", + "category": "SwiftLint", + "name": "Discouraged Optional Collection", + "description": "Prefer empty collection over optional collection.", + "severity": "MINOR" + }, { "key": "dynamic_inline", "category": "SwiftLint", @@ -174,6 +188,20 @@ "description": "When using trailing closures, empty parentheses should be avoided after the method call.", "severity": "MINOR" }, + { + "key": "empty_string", + "category": "SwiftLint", + "name": "Empty String", + "description": "Prefer checking `isEmpty` over comparing `string` to an empty string literal.", + "severity": "MINOR" + }, + { + "key": "empty_xctest_method", + "category": "SwiftLint", + "name": "Empty XCTest Method", + "description": "Empty XCTest method should be avoided.", + "severity": "MINOR" + }, { "key": "explicit_acl", "category": "SwiftLint", @@ -234,7 +262,7 @@ "key": "file_header", "category": "SwiftLint", "name": "File Header", - "description": "Header comments should be consistent with project patterns.", + "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.", "severity": "MINOR" }, { @@ -244,6 +272,13 @@ "description": "Files should not span too many lines.", "severity": "MAJOR" }, + { + "key": "file_name", + "category": "SwiftLint", + "name": "File Name", + "description": "File name should match a type or extension declared in the file (if any).", + "severity": "MINOR" + }, { "key": "first_where", "category": "SwiftLint", @@ -286,6 +321,13 @@ "description": "Functions bodies should not span too many lines.", "severity": "MAJOR" }, + { + "key": "function_default_parameter_at_end", + "category": "SwiftLint", + "name": "Function Default Parameter at End", + "description": "Prefer to locate parameters with defaults toward the end of the parameter list.", + "severity": "MINOR" + }, { "key": "function_parameter_count", "category": "SwiftLint", @@ -311,7 +353,7 @@ "key": "implicit_getter", "category": "SwiftLint", "name": "Implicit Getter", - "description": "Computed read-only properties should avoid using the get keyword.", + "description": "Computed read-only properties and subscripts should avoid using the get keyword.", "severity": "MINOR" }, { @@ -405,6 +447,13 @@ "description": "Array and dictionary literal end should have the same indentation as the line that started it.", "severity": "MINOR" }, + { + "key": "lower_acl_than_parent", + "category": "SwiftLint", + "name": "Lower ACL than parent", + "description": "Ensure definitions have a lower access control level than their enclosing parent", + "severity": "MINOR" + }, { "key": "mark", "category": "SwiftLint", @@ -412,6 +461,13 @@ "description": "MARK comment should be in valid format. e.g. '// MARK: ...' or '// MARK: - ...'", "severity": "MINOR" }, + { + "key": "modifier_order", + "category": "SwiftLint", + "name": "Modifier Order", + "description": "Modifier order should be consistent.", + "severity": "MINOR" + }, { "key": "multiline_arguments", "category": "SwiftLint", @@ -419,6 +475,13 @@ "description": "Arguments should be either on the same line, or one per line.", "severity": "MINOR" }, + { + "key": "multiline_function_chains", + "category": "SwiftLint", + "name": "Multiline Function Chains", + "description": "Chained function calls should be either on the same line, or one per line.", + "severity": "MINOR" + }, { "key": "multiline_parameters", "category": "SwiftLint", @@ -454,6 +517,13 @@ "description": "Prefer not to use extension access modifiers", "severity": "MINOR" }, + { + "key": "no_fallthrough_only", + "category": "SwiftLint", + "name": "No Fallthrough Only", + "description": "Fallthroughs can only be used if the `case` contains at least one other statement.", + "severity": "MINOR" + }, { "key": "no_grouping_extension", "category": "SwiftLint", @@ -615,6 +685,13 @@ "description": "Initializing an optional variable with nil is redundant.", "severity": "MINOR" }, + { + "key": "redundant_set_access_control", + "category": "SwiftLint", + "name": "Redundant Set Access Control", + "description": "Property setter access level shouldn't be explicit if it's the same as the variable access level.", + "severity": "MINOR" + }, { "key": "redundant_string_enum_value", "category": "SwiftLint", @@ -696,7 +773,7 @@ "key": "switch_case_alignment", "category": "SwiftLint", "name": "Switch and Case Statement Alignment", - "description": "Case statements should vertically align with the enclosing switch statement.", + "description": "Case statements should vertically align with their enclosing switch statement, or indented if configured otherwise.", "severity": "MINOR" }, { @@ -717,7 +794,7 @@ "key": "todo", "category": "SwiftLint", "name": "Todo", - "description": "TODOs and FIXMEs should be avoided.", + "description": "TODOs and FIXMEs should be resolved.", "severity": "MINOR" }, { @@ -769,6 +846,13 @@ "description": "Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 40 characters in length.", "severity": "MINOR" }, + { + "key": "unavailable_function", + "category": "SwiftLint", + "name": "Unavailable Function", + "description": "Unimplemented functions should be marked as unavailable.", + "severity": "MINOR" + }, { "key": "unneeded_break_in_switch", "category": "SwiftLint", @@ -783,6 +867,13 @@ "description": "Parentheses are not needed when declaring closure arguments.", "severity": "MINOR" }, + { + "key": "untyped_error_in_catch", + "category": "SwiftLint", + "name": "Untyped Error in Catch", + "description": "Catch statements should not declare error variables without type casting.", + "severity": "MINOR" + }, { "key": "unused_closure_parameter", "category": "SwiftLint",