Add SwiftLint

This commit is contained in:
Sindre Sorhus 2019-01-26 04:44:11 +07:00
parent c4766cb481
commit 7c5f842b26
4 changed files with 109 additions and 4 deletions

82
.swiftlint.yml Normal file
View File

@ -0,0 +1,82 @@
disabled_rules:
- file_length
- line_length
- identifier_name
- todo
- vertical_whitespace
- force_cast
- force_try
- large_tuple
- function_body_length
- nesting
- type_body_length
opt_in_rules:
- empty_count
- prohibited_super_call
- conditional_returns_on_newline
- implicit_return
- overridden_super_call
- private_outlet
- redundant_nil_coalescing
- first_where
- explicit_init
- switch_case_on_newline
- number_separator
- closure_end_indentation
- closure_spacing
- operator_usage_whitespace
- nimble_operator
- attributes
- fatal_error_message
- unneeded_parentheses_in_closure_argument
- trailing_closure
- block_based_kvo
- discouraged_direct_init
- joined_default_parameter
- pattern_matching_keywords
- contains_over_first_not_nil
- fallthrough
- array_init
- literal_expression_end_indentation
- sorted_first_last
- private_action
- yoda_condition
- required_enum_case
- discouraged_optional_boolean
- empty_string
- untyped_error_in_catch
- discouraged_optional_collection
- modifier_order
- unavailable_function
- multiline_function_chains
- redundant_set_access_control
- empty_xctest_method
- multiline_arguments
- anyobject_protocol
- redundant_type_annotation
- no_extension_access_modifier
- legacy_random
- toggle_bool
- identical_operands
- collection_alignment
- static_operator
- multiline_literal_brackets
- multiline_parameters_brackets
- vertical_whitespace_opening_braces
- vertical_whitespace_closing_braces
- legacy_hashing
- object_literal
- last_where
- unused_control_flow_label
- strong_iboutlet
analyzer_rules:
- unused_import
- unused_private_declaration
force_cast: warning
force_unwrapping: warning
number_separator:
minimum_length: 5
object_literal:
image_literal: false
discouraged_object_literal:
color_literal: false

View File

@ -128,6 +128,7 @@
isa = PBXNativeTarget;
buildConfigurationList = OBJ_15 /* Build configuration list for PBXNativeTarget "DockProgress" */;
buildPhases = (
E3BFC67621FBB9B400C16B1A /* SwiftLint */,
OBJ_18 /* Sources */,
OBJ_21 /* Frameworks */,
);
@ -222,6 +223,28 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
E3BFC67621FBB9B400C16B1A /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = SwiftLint;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed\"\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
E3FB30BD20EA5DBC009BA1BD /* Sources */ = {
isa = PBXSourcesBuildPhase;

View File

@ -19,14 +19,14 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
]
var stylesIterator = styles.makeIterator()
let _ = stylesIterator.next()
_ = stylesIterator.next()
Timer.scheduledTimer(withTimeInterval: 0.02, repeats: true) { _ in
DockProgress.progressValue += 0.01
if DockProgress.progressValue > 1 {
if let style = stylesIterator.next() {
DockProgress.progressValue = 0
DockProgress.resetProgress()
DockProgress.style = style
} else {
// Reset iterator when all is looped

View File

@ -166,7 +166,7 @@ public final class DockProgress {
if absNumber < 1000 {
return "\(number)"
} else if absNumber < 10000 {
} else if absNumber < 10_000 {
return "\(sign * Int(absNumber / 1000))k"
} else {
return "\(sign * 9)k+"