Issue #807
Don’t add SwiftLint via SPM, but just add a Run Script Build phrase
if which swiftlint >/dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
Install swiftlint locally
brew install swiftlint
Add .swiftlint.yml
with some initial disabled rules. Gradually opt-in rules to have more checks
included:
- MyApp
- MyAppTests
excluded:
- Tests/SwiftLintFrameworkTests/Resources
analyzer_rules:
- unused_declaration
- unused_import
disabled_rules:
- line_length
- trailing_whitespace
- vertical_whitespace_opening_braces
- vertical_whitespace_closing_braces
- void_return
- identifier_name
- file_name
- number_separator
- sorted_imports
- unneeded_parentheses_in_closure_argument
- redundant_optional_initialization
- todo
- first_where
- closure_spacing
- vertical_parameter_alignment_on_call
- unused_optional_binding
- operator_usage_whitespace
- large_tuple
- vertical_whitespace
- multiple_closures_with_trailing_closure
- control_statement
- statement_position
- closure_end_indentation
- opening_brace
- empty_count
- type_body_length
- force_try
- force_cast
opt_in_rules:
- anyobject_protocol
- array_init
- attributes
- collection_alignment
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- discouraged_none_name
- discouraged_object_literal
- empty_collection_literal
- empty_string
- empty_xctest_method
- enum_case_associated_values_count
- explicit_init
- extension_access_modifier
- fallthrough
- fatal_error_message
- file_header
- flatmap_over_map_reduce
- identical_operands
- joined_default_parameter
- last_where
- legacy_multiple
- legacy_random
- literal_expression_end_indentation
- lower_acl_than_parent
- modifier_order
- nimble_operator
- nslocalizedstring_key
- number_separator
- object_literal
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- prefer_self_type_over_type_of_self
- private_action
- private_outlet
- prohibited_interface_builder
- prohibited_super_call
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- reduce_into
- redundant_nil_coalescing
- redundant_type_annotation
- single_test_class
- sorted_first_last
- static_operator
- strong_iboutlet
- test_case_accessibility
- toggle_bool
- unavailable_function
- unowned_variable_capture
- untyped_error_in_catch
- xct_specific_matcher
- yoda_condition
file_name:
excluded:
- Constants.swift