Skip to content

Instantly share code, notes, and snippets.

@nzatsepilov
Created February 3, 2019 13:00
Show Gist options
  • Save nzatsepilov/6c37af04dda785fba7d2e1e4ebf5d5a0 to your computer and use it in GitHub Desktop.
Save nzatsepilov/6c37af04dda785fba7d2e1e4ebf5d5a0 to your computer and use it in GitHub Desktop.
custom_rules:
equals_to_self:
name: "Equals to self"
regex: "(^|[\\h])([$.\\w]+)([\\h]*[=]{2,}[\\h]*)\\2([\\s]+)"
message: "Expression always returns true, please fix typo"
match_kinds:
- argument
- identifier
- keyword
- number
- objectliteral
- parameter
- placeholder
- typeidentifier
extension_mark:
name: "Extension mark"
regex: "^([\\h]*[\\/]{2}[\\h]*MARK[:\\h-]+)([\\w]+)[\\s]+(extension[\\h]+[\\w]+[\\h]*:[\\h]*)(?!\\2[\\h]*[\\{])([\\w]+[\\s]*[\\{])"
message: "Extension mark should contain same protocol name"
double_whitespace:
name: "Double whitespace"
regex: "(?<!^)(\\b[\\h]{2,})"
message: "Expression contains double whitespace, please fix typo"
match_kinds:
- argument
- identifier
- keyword
- number
- objectliteral
- parameter
- placeholder
- typeidentifier
c_style_comment:
name: "C-style comment"
regex: '\/\*([^"*]+)\*\/'
message: "Avoid C-style comments, use `//` instead"
explicit_return_in_closure:
name: "Explicit return in closure"
regex: "(^)?(\\bin\\b)([\\s]+)(\\breturn\\b.+)[\\s]+[\\}]"
message: "Unnecessary return in single-expression closure"
unwrapping_self:
name: "Unwrapping self"
regex: "\\b(var|let)([\\h]+)(`self`|strongSelf)([\\h]*=[\\h]*)(self|weakSelf)"
message: "Please unwrap self as `self = self
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment