realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.62k stars 2.22k forks source link

When -todo and -expiring_todo is enabled // TODO: with expiring dates should not cause a warning #3627

Open sanguish opened 3 years ago

sanguish commented 3 years ago

New Issue Checklist

Describe the bug

We want // TODO: comments without an expiry date to appear as a warning, however expect that enabling expiring_todo would not cause //TODO: with dates outside the threshold to cause a warning under the standard -todo flag. And they seem to cause warnings regardless.

So it seems that -todo overrides -expiring_todo, and they probably should be complementary.

Additionally, approaching_expiry_threshold: doesn't seem to be in the documentation.

Environment

opt_in_rules:
- empty_count
- weak_delegate
- expiring_todo
- todo

force_try: error
closing_brace: error
comma: error
control_statement: error
leading_whitespace: error
operator_whitespace: error
return_arrow_whitespace: error
trailing_newline: error
trailing_semicolon: error
void_return: error
weak_delegate: error

expiring_todo:
  approaching_expiry_threshold: 3

colon:
  severity: error

identifier_name:
  severity: error
  min_length: 2
  max_length: 100

line_length:
  warning: 300
  error: 150
  ignores_comments: true

trailing_whitespace:
  severity: error
  ignores_empty_lines: false
  ignores_comments: true

type_name:
  severity: error
  min_length: 2
  max_length: 100

vertical_whitespace:
  severity: error

custom_rules:
    private_set_outlet:
        regex: '@IBOutlet(?!.*private \(set\).*)'
        severity: error
        message: "IBOutlets should be private to avoid leaking UIKit to higher layers."
#  guard_style:
#    name: "Guard Style"
#    regex: "(guard([^\n]*\,\n)+[^\n]*\n[\h]*else\n)|(guard[^\n]*\n[\h]*else)"
#    severity: error
#    message: "Else should be on the same line as the guard"
#  else_style:
#   name: "Else/Catch Style"
#   regex: "\}[^\n]*else|else[^\n]*\{|\}[^\n]*catch|catch[^\n]*\{"
#   severity: error
#   message: "Else/Catch and opening brace should go on new lines."

disabled_rules: # rule identifiers to exclude from running
  - function_parameter_count
  - large_tuple # tuples larger than 3 properties
  - statement_position # placement of else/catch near '{'
  - file_length
  - switch_case_alignment
  - multiple_closures_with_trailing_closure
  - fallthrough
  - vertical_parameter_alignment
  - function_body_length
  - type_body_length
  - nesting
  - block_based_kvo
  - trailing_comma

example (I'm including leading 0 to accommodate the bug yet to be released)

// TODO: [05/15/2021] Fix me by now
mywristbands commented 3 years ago

Yes I agree, it would be great if this could be fixed! I would like it if I could write // TODO: [04/22/2022] with both todo and expiring_todo enabled, then expiring_todo rule would override the regular todo rule (and so, if the date is more than 15 days away, no warning would show).

smadsenjc commented 1 week ago

Alternatively or in addition to the above, making expiring_todo always flag an error if a TODO doesn't have an expiration date. Perhaps with a bit more configuration flexibility, the two rules could be merged?