Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some settings causing compilation errors and reduce other annoying warnings #652

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,29 @@ disabled_rules:
- for_where #使用 `for where` 代替 简单的 `for { if }`
- class_delegate_protocol #delegate protocol 应该被设定为 class-only,才能被弱引用
- todo #避免 TODOs and FIXMEs 标识
- line_length
- function_body_length
- no_space_in_method_call
- multiple_closures_with_trailing_closure
- switch_case_alignment
- syntactic_sugar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think disable those rules are good practices

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think disable those rules are good practices

The first 5 cause compilation to fail in the current code, so keeping them means refactoring.

  • no_space_in_method_call causes warnings reported on cases where a function takes a closure and it's called without parenthesis, for example: DispatchQueue.main.async {
  • line_length I personally tend to ignore it, as in some cases I prefer a longer line to splits
  • switch_case_alignment seems to randomly throw warnings even if cases are aligned correctly
  • syntactic_sugar: I find this annoying, as sometimes I prefer to make the code more explicit by avoiding syntactic sugar — typically in some usages of optionals, or when defining extensions.

Anyway it seems nobody but me has the linter enabled, as it causes compilation to fail.

cyclomatic_complexity: 20 #代码复杂度,默认为10
force_try: warning # try语句判断
force_cast: warning # 强制转换(代码中存在一些前面通过if判断过类型,后面做的强制转换的代码)
line_length: #每行长度限制
warning: 160
error: 300
ignores_function_declarations: true
ignores_comments: true
#line_length: #每行长度限制
# warning: 160
# error: 300
# ignores_function_declarations: true
# ignores_comments: true
file_length: #文件长度
warning: 1000
error: 1500
function_body_length: #函数体长度
warning: 100
error: 150
error: 2000
#function_body_length: #函数体长度
# warning: 100
# error: 150
type_body_length: #类的长度
warning: 800
error: 1200
error: 1200
generic_type_name:
validates_start_with_lowercase: false