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

Fix empty_count false-positives - cannot use variables named "count" #2220

Closed
2 tasks done
johnvuko opened this issue May 24, 2018 · 1 comment
Closed
2 tasks done
Labels
duplicate Issues that already exist in other terms.

Comments

@johnvuko
Copy link

New Issue Checklist

Bug Report

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint

Loading configuration from '.swiftlint.yml'
Linting Swift files in current working directory
Linting 'WPReportView.swift' (1/10)
Linting 'UIFont.swift' (2/10)
Linting 'WPContext.swift' (3/10)
Linting 'JTView.swift' (4/10)
Linting 'UIColor+JT.swift' (5/10)
Linting 'NSObject+JT.swift' (6/10)
Linting 'WPTheme.swift' (7/10)
Linting 'UIView+JT.swift' (8/10)
Linting 'WPHeaderView.swift' (9/10)
Linting 'WPHeaderItemView.swift' (10/10)
/XXX/SDK/Views/WPHeaderItemView.swift:77:12: error: Empty Count Violation: Prefer checking `isEmpty` over comparing `count` to zero. (empty_count)
Done linting! Found 1 violation, 1 serious in 10 files.

Environment

  • SwiftLint version (run swiftlint version to be sure)? => 0.25.1
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Cocoapod
  • Paste your configuration file:
# https://github.com/realm/SwiftLint/blob/master/Rules.md

disabled_rules:
  - cyclomatic_complexity
  - function_body_length
  - file_length
  - identifier_name
  - line_length
  - todo
  - trailing_comma
  - type_body_length
  - unused_optional_binding
opt_in_rules:
  - attributes
  - closure_end_indentation
  - closure_spacing
  - conditional_returns_on_newline
  - contains_over_first_not_nil
  - discouraged_object_literal
  - empty_count
  - fatal_error_message
  - first_where
  - joined_default_parameter
  - literal_expression_end_indentation
  - multiline_arguments
  - multiline_parameters
  - operator_usage_whitespace
  - overridden_super_call
  - redundant_nil_coalescing
  - sorted_first_last
  - sorted_imports
  - switch_case_on_newline
  - unneeded_parentheses_in_closure_argument
  - vertical_parameter_alignment_on_call
  - yoda_condition
excluded:
  - Pods
  • Are you using nested configurations? No
  • Which Xcode version are you using (check xcode-select -p)? 9.3.1 (9E501)
  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
echo "func updateErrors(count: Int) {\n
	if count > 0 {\n
		print(\"1\")\n
	} else {\n
		print(\"2\")\n
    }\n
}" | swiftlint lint --no-cache --use-stdin --enable-all-rules
// This triggers a violation:
    func updateErrors(count: Int) {
        if count > 0 {
            print("1")
        } else {
            print("2")
        }
    }

I just use a variable named count I think it should not be catch by the empty_count rule.

@marcelofabri
Copy link
Collaborator

It's the same issue as #827. Check this comment: #827 (comment)

@marcelofabri marcelofabri added the duplicate Issues that already exist in other terms. label May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues that already exist in other terms.
Projects
None yet
Development

No branches or pull requests

2 participants