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

[unused_private_declaration] False positives on CodingKeys #2573

Closed
kimdv opened this Issue Jan 21, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@kimdv
Copy link
Contributor

kimdv commented Jan 21, 2019

New Issue Checklist

Describe the bug

A clear and concise description of what the bug is.

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

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.30.0
  • Installation method used: Homebrew
  • Paste your configuration file:
disabled_rules: # rule identifiers to exclude from running
  - trailing_whitespace
  - comma
  - line_length
  - todo
  - identifier_name

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.
  - AppName

excluded: # paths to ignore during linting. Takes precedence over `included`.
  - Carthage

analyzer_rules:
  - unused_private_declaration
  - unused_import

type_body_length:
  - 300 # warning
  - 500 # error

file_length:
  warning: 500
  error: 1200

type_name:
  max_length: # warning and error
    warning: 50
    error: 60

identifier_name:
  max_length: # warning and error
    warning: 60
    error: 70
  excluded: # excluded via string array
    - id
    - db
// This triggers a violation:
struct ResponseModel: Codable {
    let items: [Item]

    private enum CodingKeys: String, CodingKey { // <-- False 'unused_private_declaration' 
        case items = "ResponseItems"
    }
}
@jpsim

This comment has been minimized.

Copy link
Collaborator

jpsim commented Jan 21, 2019

Yes, I’ve seen this too, and we should stop reporting violations here. Although I wouldn’t technically call this a false positive but more of an intentional violation, but that’s a matter of perspective.

@kimdv

This comment has been minimized.

Copy link
Contributor Author

kimdv commented Jan 21, 2019

I see your point!
Where should report stuff? 😄

Sent with GitHawk

@jpsim

This comment has been minimized.

Copy link
Collaborator

jpsim commented Jan 21, 2019

we should stop reporting violations here

Oh I meant the rule should stop reporting violations on CodingKeys enum that conform to a CodingKeys protocol inside a Codable container.

You definitely filed this issue at the right place! 😅

@kimdv

This comment has been minimized.

Copy link
Contributor Author

kimdv commented Jan 21, 2019

Oh sorry for misunderstanding. haha! 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment