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

redundant_type_annotation autocorrect is really buggy #2314

Closed
Jeehut opened this issue Jul 23, 2018 · 3 comments
Closed

redundant_type_annotation autocorrect is really buggy #2314

Jeehut opened this issue Jul 23, 2018 · 3 comments
Labels
bug Unexpected and reproducible misbehavior.

Comments

@Jeehut
Copy link
Collaborator

Jeehut commented Jul 23, 2018

I recently turned on redundant_type_annotation which seems to work fine when it comes to showing warnigns. But when running swiftlint autocorrect I get many changes that break my code. Here are a few examples of the changes made by this rule:

BEFORE

 enum EventType {
     case amazingMonitor(isPresenting: Bool)
     case amazingHistory(isPresenting: Bool)
     case startNFCScan
     case scanAmazingQRCode
 }

AFTER (the fist two cases mixed up)

 enum EventType {
     case amazingMonitor(isPresentingcase amazingHistory(isPresenting: Bool)
     case startNFCScan
     case scanAmazingQRCode
 }

BEFORE

 import Foundation
 import MapKit
 
 // swiftlint:disable:next type_body_length
 final class AmazingTracking: NSObject {
     // MARK: - Stored Type Properties
     static let shared = AmazingTracking()

AFTER (the swiftlint disabling broken)

 import Foundation
 import MapKit
 
 // swiftlintlength
 final class AmazingTracking: NSObject {
     // MARK: - Stored Type Properties
     static let shared = AmazingTracking()

BEFORE

 protocol AmazingManagerDelegate: class {
     func manager(_ manager: AmazingManager, didChange region: MKCoordinateRegion)

AFTER (the : class is gone)

 protocol AmazingManagerDelegate {
     func manager(_ manager: AmazingManager, didChange region: MKCoordinateRegion)

There's a lot more if you need more examples, but I thinks this is a start.

@realm-probot realm-probot bot added the O:User label Jul 23, 2018
@marcelofabri marcelofabri added the bug Unexpected and reproducible misbehavior. label Jul 23, 2018
@marcelofabri
Copy link
Collaborator

@Dschee I wasn't able to reproduce the problem with the examples you've provided. Can you double check that those reduced snippets trigger the issue?

@Jeehut Jeehut closed this as completed Jul 26, 2018
@Jeehut Jeehut reopened this Jul 26, 2018
@Jeehut
Copy link
Collaborator Author

Jeehut commented Jul 26, 2018

You were right, the above examples didn't have this bug. But I could reduce the issue to the following example, where this happens:

class ViewController: UIViewController {
    func someMethod() {
        let myVar: Int = Int(5)
    }
}

When autocorrecting this example, instead of removing the redundant : Int it removes the : UIViewController.

@Jeehut
Copy link
Collaborator Author

Jeehut commented Jul 27, 2018

@marcelofabri Thank you for fixing this so quickly!

Jeehut pushed a commit to Jeehut/SwiftLint that referenced this issue Jul 27, 2018
dirtydanee pushed a commit to dirtydanee/SwiftLint that referenced this issue Aug 14, 2018
sjavora pushed a commit to sjavora/SwiftLint that referenced this issue Mar 9, 2019
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