opt_in_rules: # performance - first_where - last_where - empty_string - empty_count - contains_over_filter_count - contains_over_filter_is_empty - empty_collection_literal - contains_over_range_nil_comparison - contains_over_first_not_nil - flatmap_over_map_reduce # idiomatic - legacy_random - legacy_multiple - pattern_matching_keywords - redundant_nil_coalescing - redundant_type_annotation - static_operator - toggle_bool - joined_default_parameter - implicitly_unwrapped_optional - convenience_type - object_literal - force_unwrapping - force_cast - force_try - fatal_error_message - extension_access_modifier - explicit_init # style - literal_expression_end_indentation - multiline_function_chains - multiline_literal_brackets - multiline_parameters - operator_usage_whitespace - switch_case_on_newline - unneeded_parentheses_in_closure_argument - vertical_parameter_alignment_on_call - vertical_whitespace_between_cases - vertical_whitespace_closing_braces - yoda_condition - number_separator - let_var_whitespace - implicit_return - conditional_returns_on_newline - closure_spacing - closure_end_indentation - prefer_self_type_over_type_of_self # lint - private_action - private_outlet - prohibited_super_call - unused_import - unused_declaration - identical_operands - overridden_super_call - unowned_variable_capture # metrics - enum_case_associated_values_count excluded: - Carthage - Pods - Generated - Localization line_length: warning: 128 ignores_urls: true cyclomatic_complexity: ignores_case_statements: true type_body_length: - 500 # warning - 700 # error file_length: warning: 500 error: 1200 function_parameter_count: error: 5 colon: flexible_right_spacing: true enum_case_associated_values_count: warning: 4 error: 5 identifier_name: excluded: - id - ok - URL - x - y - z warning_threshold: 1 custom_rules: # General uiwebview_disabled: included: ".*.swift" name: "UIWebView Usage Disabled" regex: 'UIWebView' message: "Do not use UIWebView. Use WKWebView Instead. https://developer.apple.com/reference/uikit/uiwebview" severity: error native_print: name: "print -> DDLog" regex: '(print|NSLog)\(' message: "Please use CocoaLumberjack instead `print` and `NSlog`" severity: error uiedge_insets_zero: name: "UIEdgeInsets .zero" regex: '\(top: 0, left: 0, bottom: 0, right: 0\)' message: "Please use short init `.zero`." severity: error let_variable: name: "Let Variable" regex: 'var\s\w*(:|(\s=))\sVariable' message: "Please make variable using `let`." severity: error marks_style: name: "Marks" regex: '// MARK: -?[a-zA-Z0-9]' message: "Marks should follow the following structure: // MARK: - Comment." severity: warning no_header_comments: name: "Header Comments" regex: '//\s*Created by.*\s*//\s*Copyright' match_kinds: - comment message: "Template header comments should be removed." unnecessary_type: name: "Unnecessary Type" regex: '[ @a-zA-Z]*(?:let|var)\s\w*: ([a-zA-Z0-9]*)\?? = \1' message: "Type definition not needed" severity: error unowned: name: "Unowned" regex: 'unowned' message: "Please use `weak` instead. " severity: error continue_keyword: name: "Continue" regex: 'continue' message: "Don't use continue instruction" severity: error match_kinds: keyword cyrillic_strings: name: "Cyrillic strings" regex: '[а-яА-Я]+' message: "Localize or translate" severity: error match_kinds: - identifier - string too_many_empty_spaces: name: "Too many empty spaces" regex: '(?!\n)[^ \n]+ {2,}.+' message: "Remove excess empty spaces" severity: warning match_kinds: - argument - attribute.builtin - attribute.id - buildconfig.id - buildconfig.keyword - identifier - keyword - number - objectliteral - parameter - placeholder # - string # all except string literals # - comment # and comments # - comment.mark # - comment.url # - doccomment # - doccomment.field - string_interpolation_anchor - typeidentifier getter_setter_style: name: "Wrong getter/setter code style" regex: "(get|set|willSet|didSet) \\{ [.]*" match_kinds: - keyword message: "Make a new line break when use getter or setter" severity: error redundant_boolean_condition: name: "Redundant Boolean Condition" regex: "(== true)|(== false)|(!= true)|(!= false)" message: "Comparing a boolean to true is redundant (use `?? false` for optionals), and `!`-syntax is preferred over comparing to false." severity: error redundant_ternary_operator: name: "Redundant Ternary Operator" regex: "(\\? true \\: false)|(\\? false \\: true)" message: "Returning a boolean as true is redundant, and `!`-syntax is preferred over returning as false." severity: error single_line_closure: name: "Single line closure" regex: '\{([^\n\/]*\[[^\]]+\][^\n\/]*)?([^\n\/]*[a-zA-Z]\w*(, \w+)*)? in [^\n\/]+' message: "Too complex expression for single line closure. Improve readability by making it multiline." severity: error addSubview_in_cell: name: "Usage addSubview in cell" regex: '(extension|class)\s*\w+Cell(:| )(?s).*(self\.|\s{2,})add(Subv|V)iews?\(\w' message: "Use сontentView instead of self for addSubview or addSubviews methods in cell." severity: error redundant_type_annotation_bool: name: "Redundant type annotation for Bool" regex: '\s((var|let))\s{1,}\w+ *((: *Bool *=)|((\w| |<|>|:)*= *BehaviorRelay\( *value *:)) *((true)|(false))' message: "Using a type annotation for Bool is redundant." severity: error parameter_repetition: name: "Parameter repetition" regex: 'func ((\w+([A-Z]\w+))|(\w+)) *(<[^>]+>)? *\( *(?i)(\3|\4):' message: "The parameter name is actually used in the function name. Use _ instead." severity: error parameter_closure: name: "Parameter closure" regex: '\w*Closure<[^\r\n\t\f\v]*, Void[^\r\n\t\f\v]*>' message: "Use `ParameterClosure` instead of declaring an explicit return value of `Void`." severity: error # Rx unused_map_parameter: name: "Unused map parameter" regex: '.map\s*\{\s*_\s*in' message: "Replace Rx.map operator with replace(with:) or asVoid(). For Sequence.map consider using forEach." severity: warning disposable_nil: name: "Disposable nil" regex: ' *\S*(d|D)isposable\?? *= *nil' message: "nil assigning doesn't dispose subscription. Call `dispose()` instead." severity: error # LeadKit multiple_add_subview: name: "Multiple addSubview calls" regex: '(^\s*\w*\.?)(addSubview)\([\w]+\)\n\1\2' message: "Replace multiple addSubview calls with single addSubviews." severity: warning