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

empty_count false positive with PHFetchResult #2805

Closed
2 tasks done
Noobish1 opened this issue Jul 9, 2019 · 1 comment
Closed
2 tasks done

empty_count false positive with PHFetchResult #2805

Noobish1 opened this issue Jul 9, 2019 · 1 comment

Comments

@Noobish1
Copy link

Noobish1 commented Jul 9, 2019

New Issue Checklist

Describe the bug

The guard below triggers the empty_count rule however PHFetchResult doesn't actually have an isEmpty computed property so it's impossible to use it.

private var fetchResult = PHFetchResult<PHAsset>()

guard fetchResult.count > 0 else {
    return
}
``

##### Complete output when running SwiftLint, including the stack trace and command used

I'm running this in a Run Script Phase

```bash
set -e
set -o pipefail

"${SRCROOT}/SwiftLint/swiftlint" --quiet --strict | sed 's/warning:/error:/g'

Output

Empty Count Violation: Prefer checking `isEmpty` over comparing `count` to zero. (empty_count)

Environment

  • SwiftLint version 0.33.1, portable version
  • I'm not using nested config files

I'll include this anyway but I don't think it matters for this, I've replaced the names of my app/frameworks in the included bit.

disabled_rules:
    - identifier_name
    - private_over_fileprivate
    - redundant_string_enum_value
    - todo
opt_in_rules:
    - force_unwrapping
    - attributes
    - file_header
    - prohibited_super_call
    - closure_spacing
    - explicit_init
    - first_where
    - nimble_operator
    - overridden_super_call
    - private_outlet
    - redundant_nil_coalescing
    - fatal_error_message
    - explicit_top_level_acl
    - implicit_return
    - empty_count
    - array_init
    - closure_end_indentation
    - contains_over_first_not_nil
    - let_var_whitespace
    - literal_expression_end_indentation
    - operator_usage_whitespace
    - override_in_extension
    - quick_discouraged_call
    - quick_discouraged_focused_test
    - quick_discouraged_pending_test
    - single_test_class
    - sorted_first_last
    - unneeded_parentheses_in_closure_argument
    - explicit_acl
    - private_action
    - sorted_imports
    - yoda_condition
    - convenience_type
    - discouraged_optional_boolean
    - discouraged_optional_collection
    - empty_string
    - empty_xctest_method
    - fallthrough
    - file_name
    - lower_acl_than_parent
    - modifier_order
    - switch_case_alignment
    - unavailable_function
    - explicit_enum_raw_value
    - anyobject_protocol
    - implicitly_unwrapped_optional
    - closure_body_length
    - discouraged_object_literal
    - identical_operands
    - last_where
    - legacy_random
    - multiline_arguments
    - prohibited_interface_builder
    - toggle_bool
    - unused_import
    - unused_private_declaration
    - static_operator
    - redundant_type_annotation
    - nslocalizedstring_key
    - multiline_function_chains
    - multiline_literal_brackets
    - multiline_parameters
    - multiline_parameters_brackets
    - vertical_parameter_alignment_on_call
    - vertical_whitespace_closing_braces
    - vertical_whitespace_opening_braces
    - reduce_into
    - file_contents_order
    - type_contents_order
    - no_extension_access_modifier
included:
    - MyApp
    - MyAppFrameworks
type_contents_order:
    order:
        - type_alias
        - associated_type
        - subtype
        - case
        - [type_property, instance_property]
        - ib_outlet
        - ib_inspectable
        - initializer
        - type_method
        - [other_method, view_life_cycle_method]
        - [other_method, ib_action, subscript]
cyclomatic_complexity:
    ignores_case_statements: true
trailing_whitespace:
    ignores_empty_lines: true
colon:
    apply_to_dictionaries: false
line_length: 200 # I think I want 104 though
file_length:
    - 750 # warning
closure_body_length:
    - 30 # warning
function_body_length:
    - 200 # warning
type_body_length:
    - 600 # warning
type_name:
    excluded:
        - R # R.swift
        - image # R.swift
        - intern # R.swift
        - _R # R.swift
    min_length: 2 # only warning
    max_length: # warning and error
        warning: 60
file_name:
    excluded:
        - R.generated.swift
modifier_order:
    preferred_modifier_order:
        - acl
        - override
nesting:
    type_level:
        warning: 4
switch_case_alignment:
    indented_cases: true
function_parameter_count:
    warning: 7
@marcelofabri
Copy link
Collaborator

Duplicate of #827.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants