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

Incorrect report of force_unwrap violation in string (from Sourcery code base) #1614

Closed
Liquidsoul opened this issue Jun 9, 2017 · 2 comments
Labels
bug Unexpected and reproducible misbehavior.

Comments

@Liquidsoul
Copy link
Contributor

Hi,

While fixing the swiftlint warnings in Sourcery, I noticed that there were some warnings about force unwrapping that should not be there:

AutoEquatable.swift:133:27: warning: Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)
AutoHashable.swift:70:27: warning: Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)
AutoHashable.swift:121:27: warning: Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)

They all involve the same code:

func greeting(for name: String) -> String {
    return "Hi \(name)!"
}

I tried to isolate a triggering example and it seems that you need to include the whole method:

"func someFunction(for name: String) -> String {\n    return \"Hi \\(name)!\n\"}"

I traced the condition of the violation and it seems that it is because of its kind while checking the structure.
Unfortunately, I do not understand what this means so I cannot offer a fix through a PR 😓

Hope this helps!

@marcelofabri
Copy link
Collaborator

#1584 should fix this

@marcelofabri marcelofabri added the bug Unexpected and reproducible misbehavior. label Jun 9, 2017
@marcelofabri
Copy link
Collaborator

Fixed in #1620.

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

No branches or pull requests

2 participants