Skip to content

Commit

Permalink
Added SwiftLint and SwiftFormat rules for a better codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
kuyazee committed Nov 16, 2019
1 parent 62d4928 commit b3424da
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--allman false
--binarygrouping none
--closingparen balanced
--commas inline
--conflictmarkers reject
--decimalgrouping none
--elseposition same-line
--empty void
--exponentcase lowercase
--exponentgrouping disabled
--fractiongrouping disabled
--fragment false
--header ignore
--hexgrouping none
--hexliteralcase uppercase
--ifdef outdent
--importgrouping alphabetized
--indent 4
--indentcase false
--linebreaks lf
--octalgrouping none
--operatorfunc spaced
--patternlet inline
--ranges no-space
--self insert
--selfrequired
--semicolons inline
--stripunusedargs closure-only
--trailingclosures
--trimwhitespace always
--wraparguments before-first
--wrapcollections before-first
--xcodeindentation disabled
53 changes: 53 additions & 0 deletions .swiftlint.auto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# rule identifiers to exclude from running
disabled_rules:
- block_based_kvo
- class_delegate_protocol
- closing_brace
- closure_parameter_position
- compiler_protocol_init
- custom_rules
- cyclomatic_complexity
- discarded_notification_center_observer
- discouraged_direct_init
- dynamic_inline
- empty_parentheses_with_trailing_closure
- file_length
- for_where
- force_cast
- force_try
- function_body_length
- function_parameter_count
- generic_type_name
- identifier_name
- implicit_getter
- is_disjoint
- large_tuple
- legacy_cggeometry_functions
- legacy_constant
- legacy_nsgeometry_functions
- line_length
- mark
- multiple_closures_with_trailing_closure
- nesting
- no_fallthrough_only
- notification_center_detachment
- private_over_fileprivate
- private_unit_test
- protocol_property_accessors_order
- redundant_set_access_control
- return_arrow_whitespace
- shorthand_operator
- statement_position
- superfluous_disable_command
- todo
- type_body_length
- type_name
- valid_ibinspectable
- vertical_parameter_alignment
- xctfail_message


# paths to ignore during linting. Takes precedence over `included`.
excluded:
- Carthage
- Pods
50 changes: 50 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# rule identifiers to exclude from running
disabled_rules:
- trailing_whitespace
- line_length # This should be removed from disabled_rules, code needs a lot of refactoring
- cyclomatic_complexity # This should be removed from disabled_rules, code needs a lot of refactoring
- file_length # This should be removed from disabled_rules, code needs a lot of refactoring
- type_body_length # This should be removed from disabled_rules, code needs a lot of refactoring
- todo # This should be removed from disabled_rules, code needs a lot of refactoring
- function_parameter_count # This should be removed from disabled_rules, code needs a lot of refactoring
- force_try # I need this because of realm but this should be removed from disabled_rules
- unused_closure_parameter # Added this for readability purposes of the code.
- function_body_length
- discarded_notification_center_observer # I don't understand this at the moment so I'll disable this.
- statement_position
- nesting
- large_tuple
- private_over_fileprivate

opt_in_rules:
- empty_count

# paths to ignore during linting. Takes precedence over `included`.
excluded:
- Carthage
- Pods

empty_count: warning # implicitly
force_cast: warning # implicitly

type_name:
max_length:
warning: 99
error: 100
min_length:
warning: 2
error: 3

identifier_name:
max_length:
warning: 99
error: 100
min_length:
warning: 1
error: 2
excluded: # excluded via string array
- id
- i # for loop iteration
- e # for error e
- x # x axis
- y # y axis

0 comments on commit b3424da

Please sign in to comment.