如何创建.swiftlint.yml文件&;我需要把它放在哪里?
我想在我的Swift项目中使用Swiftlint。 我按照Realm指令,通过如何创建.swiftlint.yml文件&;我需要把它放在哪里?,swiftlint,Swiftlint,我想在我的Swift项目中使用Swiftlint。 我按照Realm指令,通过brew安装Swiftlint安装了Swiftlint。此外,我还面临创建.swiftlint.yml文件的问题 因此,请建议我如何进行?我建议您阅读: 通过从运行SwiftLint的目录中添加.SwiftLint.yml文件来配置SwiftLint 我建议您的项目或源根 下面是一个广泛的示例文件;从那里开始 至于可用的规则和默认值,除了运行 swiftlint规则>swiftlint_rules.txt 而且屏幕很宽
brew安装Swiftlint
安装了Swiftlint。此外,我还面临创建.swiftlint.yml
文件的问题
因此,请建议我如何进行?我建议您阅读:
通过从运行SwiftLint的目录中添加.SwiftLint.yml文件来配置SwiftLint
我建议您的项目或源根
下面是一个广泛的示例文件;从那里开始
至于可用的规则和默认值,除了运行
swiftlint规则>swiftlint_rules.txt
而且屏幕很宽。我发现这段视频很有帮助:
您可以在XCode中创建.swiftlint.yml并将其保存在项目目录中。如果您正在使用终端,只需选择文件->新建->文件->清空即可:
cd your_project_directory
touch .swiftlint.yml
我通过cocoapods安装swift lint,然后在根项目目录中添加名为
.swiftlint.yml
的新文件。有关更多详细信息,请访问youtube链接。我觉得这个视频很有帮助:或者
在项目主目录中创建此文件,文件名应
。swiftlint.yml
文件示例
disabled_rules: # rule identifiers to exclude from running
- colon
- comma
- control_statement
- identifier_name #rule for checking variable conditions (Upper case , lower case , underscore )
- force_cast
- shorthand_operator
cyclomatic_complexity:
warning: 25 # two nested ifs are acceptable
error: 50 # six nested ifs shows warning, 6 causes compile error
opt_in_rules: # some rules are only opt-in
# - empty_count
# Find all the available rules by running:
# swiftlint rules
#included: # paths to include during linting. `--path` is ignored if present.
# - Source
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- AppFolder\ App/Class/*
# - AppFolder\ App/ViewController/* //Enabled for this
analyzer_rules: # Rules run by `swiftlint analyze` (experimental)
- explicit_self
# configurable rules can be customised from this configuration file
# binary rules can set their severity level
# force_cast: warning # implicitly
force_try:
severity: warning # explicitly
# rules that have both warning and error levels, can set just the warning level
# implicitly
line_length: 200
# they can set both implicitly with an array
type_body_length:
- 300 # warning
- 600 # error
# or they can set both explicitly
file_length:
warning: 500
error: 2500
function_body_length:
- 200 #warning
- 300 #error
# naming rules can set warnings/errors for min_length and max_length
# additionally they can set excluded names
type_name:
min_length: 4 # only warning
max_length: # warning and error
warning: 40
error: 50
excluded: iPhone # excluded via string
allowed_symbols: ["_"] # these are allowed in type names
identifier_name:
min_length: # only min_length
error: 4 # only error
excluded: # excluded via string array
- id
- URL
- GlobalAPIKey
identifier_name:
# allowed_symbols: "_"
max_length:
warning: 45
error: 60
min_length:
warning: 1
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube, markdown)
它是您的\u项目\u目录中的隐藏文件,要查看它,您应该启用目录以显示隐藏文件。要在Mac OS Sierra中显示或隐藏隐藏隐藏文件,您可以使用cmd+shift+…视频不可用。