{"action":"closed","issue":{"url":"https://api.github.com/repos/realm/SwiftLint/issues/2050","repository_url":"https://api.github.com/repos/realm/SwiftLint","labels_url":"https://api.github.com/repos/realm/SwiftLint/issues/2050/labels{/name}","comments_url":"https://api.github.com/repos/realm/SwiftLint/issues/2050/comments","events_url":"https://api.github.com/repos/realm/SwiftLint/issues/2050/events","html_url":"https://github.com/realm/SwiftLint/issues/2050","id":297052432,"number":2050,"title":"\"colon\" violation no longer autocorrected in dictionary literals (since 0.23.1)","user":{"login":"AliSoftware","id":216089,"avatar_url":"https://avatars2.githubusercontent.com/u/216089?v=4","gravatar_id":"","url":"https://api.github.com/users/AliSoftware","html_url":"https://github.com/AliSoftware","followers_url":"https://api.github.com/users/AliSoftware/followers","following_url":"https://api.github.com/users/AliSoftware/following{/other_user}","gists_url":"https://api.github.com/users/AliSoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/AliSoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AliSoftware/subscriptions","organizations_url":"https://api.github.com/users/AliSoftware/orgs","repos_url":"https://api.github.com/users/AliSoftware/repos","events_url":"https://api.github.com/users/AliSoftware/events{/privacy}","received_events_url":"https://api.github.com/users/AliSoftware/received_events","type":"User","site_admin":false},"labels":[{"id":212343554,"url":"https://api.github.com/repos/realm/SwiftLint/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-14T10:55:17Z","updated_at":"2018-02-15T08:18:49Z","closed_at":"2018-02-15T08:18:49Z","author_association":"CONTRIBUTOR","body":"### New Issue Checklist\r\n\r\n- [X] Updated SwiftLint to the latest version\r\n- [X] I searched for [existing GitHub issues](https://github.com/realm/SwiftLint/issues)\r\n\r\n### Bug Report\r\n\r\n`swiftlint autocorrect` does not correct the `colon` rule on some cases (especially in dictionary literals?).\r\n\r\nI've tested with versions 0.24.0 thru 0.25.0 but the bug is still present, while it was working in 0.23.1\r\n\r\n### Environment\r\n\r\n* SwiftLint versions: 0.23.1 OK, but bug present with 0.24.0, 0.24.1, 0.24.2 and 0.25.0\r\n* Installation method used: portable zip (also tested 0.23.1 with homebrew, and 0.25.0 with CocoaPods)\r\n* Which Xcode version are you using (check `xcode-select -p`)? 9.2\r\n\r\n\r\n### Sample code to reproduce\r\n\r\n#### Sample swift file\r\n\r\n```swift\r\nimport UIKit\r\n\r\nclass SwiftLintBugSample: UIViewController {\r\n\r\n    fileprivate func updateTableView() {\r\n\r\n        let dict = [KeysConstants.CELL_KEYS.CELL_TYPE : FooCellType.editTextCell.rawValue,\r\n                    KeysConstants.CELL_KEYS.CELL_IDENTIFIER_KEY : FooEditTextTableViewCell.cellIdentifier,\r\n                    KeysConstants.CELL_KEYS.CELL_GRAY : false,\r\n                    KeysConstants.CELL_KEYS.VALUE_ERROR : self.isInError,\r\n                    KeysConstants.CELL_KEYS.ESTIMATED_CELL_HEIGHT : FooEditTextTableViewCell.cellHeight] as [String: Any]\r\n\r\n        self.dataSource = dict as NSDictionary\r\n\r\n    }\r\n}\r\n```\r\n\r\n#### Configuration File\r\n\r\n```yml\r\nwhitelist_rules:\r\n  - colon\r\n```\r\n\r\n#### Test script\r\n\r\nThis script aims to test a given swiftlint version by linting first to show the colon violations, then trying to autocorrect them, then linting again to check if they have indeed been corrected.\r\n\r\n```sh\r\n#!/bin/sh\r\n\r\nbin=$1/swiftlint\r\necho \">>> Testing with version `$bin version`\"\r\n\r\ngit checkout sample.swift\r\n\r\necho \"------ Initial linting ------\"\r\n$bin lint --path sample.swift\r\n\r\necho \"------ Autocorrecting  ------\"\r\n$bin autocorrect --path sample.swift\r\n\r\necho \"------  Linting again  ------\"\r\n$bin lint --path sample.swift\r\n```\r\n\r\n> Note: I made this test script in order to test the bug across multiple versions of SwiftLint. In order for this script to work, I've downloaded various versions of SwiftLint (portable zip) and placed each version in its own folder (each folder named after the corresponding version)\r\n\r\n#### Output for various Swiftlint versions\r\n\r\n<details>\r\n  <summary>swiftlint 0.23.1</summary>\r\n\r\n> This version works as expected: 5 violations before autocorrect, all corrected, no more violation after autocorrect.\r\n\r\n  ```sh\r\n$ ./test.sh 0.23.1\r\n>>> Testing with version 0.23.1\r\n------ Initial linting ------\r\nLoading configuration from '.swiftlint.yml'\r\nLinting Swift files at path sample.swift\r\nLinting 'sample.swift' (1/1)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:7:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:8:64: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:9:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:10:56: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:11:66: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\nDone linting! Found 5 violations, 0 serious in 1 file.\r\n------ Autocorrecting  ------\r\nLoading configuration from '.swiftlint.yml'\r\nCorrecting Swift files at path sample.swift\r\nCorrecting 'sample.swift' (1/1)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:11:66 Corrected Colon\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:10:56 Corrected Colon\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:9:54 Corrected Colon\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:8:64 Corrected Colon\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:7:54 Corrected Colon\r\nDone correcting 1 files!\r\n------  Linting again  ------\r\nLoading configuration from '.swiftlint.yml'\r\nLinting Swift files at path sample.swift\r\nLinting 'sample.swift' (1/1)\r\nDone linting! Found 0 violations, 0 serious in 1 file.\r\n  ```\r\n</details>\r\n\r\n<details>\r\n  <summary>swiftlint 0.24.0</summary>\r\n\r\n> This version does not work as expected: 5 violations before autocorrect, none auto-corrected, still 5 violation present after autocorrect.\r\n\r\n  ```sh\r\n$ ./test.sh 0.24.0\r\n>>> Testing with version 0.24.0\r\n------ Initial linting ------\r\nLoading configuration from '.swiftlint.yml'\r\nLinting Swift files at path sample.swift\r\nLinting 'sample.swift' (1/1)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:7:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:8:64: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:9:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:10:56: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:11:66: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\nDone linting! Found 5 violations, 0 serious in 1 file.\r\n------ Autocorrecting  ------\r\nLoading configuration from '.swiftlint.yml'\r\nCorrecting Swift files at path sample.swift\r\nCorrecting 'sample.swift' (1/1)\r\nDone correcting 1 files!\r\n------  Linting again  ------\r\nLoading configuration from '.swiftlint.yml'\r\nLinting Swift files at path sample.swift\r\nLinting 'sample.swift' (1/1)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:7:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:8:64: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:9:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:10:56: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:11:66: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\nDone linting! Found 5 violations, 0 serious in 1 file.\r\n  ```\r\n</details>\r\n\r\n<details>\r\n  <summary>swiftlint 0.24.1</summary>\r\n\r\n> This version does not work as expected: 5 violations before autocorrect, none auto-corrected, still 5 violation present after autocorrect.\r\n\r\n  ```sh\r\n$ ./test.sh 0.24.1\r\n>>> Testing with version 0.24.1\r\n------ Initial linting ------\r\nLoading configuration from '.swiftlint.yml'\r\nInvalid configuration for 'indentation'. Falling back to default.\r\nLinting Swift files at path sample.swift\r\nLinting 'sample.swift' (1/1)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:7:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:8:64: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:9:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:10:56: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:11:66: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\nDone linting! Found 5 violations, 0 serious in 1 file.\r\n------ Autocorrecting  ------\r\nLoading configuration from '.swiftlint.yml'\r\nInvalid configuration for 'indentation'. Falling back to default.\r\nCorrecting Swift files at path sample.swift\r\nCorrecting 'sample.swift' (1/1)\r\nDone correcting 1 files!\r\n------  Linting again  ------\r\nLoading configuration from '.swiftlint.yml'\r\nInvalid configuration for 'indentation'. Falling back to default.\r\nLinting Swift files at path sample.swift\r\nLinting 'sample.swift' (1/1)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:7:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:8:64: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:9:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:10:56: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:11:66: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\nDone linting! Found 5 violations, 0 serious in 1 file.\r\n  ```\r\n</details>\r\n\r\n<details>\r\n  <summary>swiftlint 0.24.2</summary>\r\n\r\n> This version does not work as expected: 5 violations before autocorrect, none auto-corrected, still 5 violation present after autocorrect.\r\n\r\n  ```sh\r\n$ ./test.sh 0.24.2\r\n>>> Testing with version 0.24.2\r\n------ Initial linting ------\r\nLoading configuration from '.swiftlint.yml'\r\nLinting Swift files at path sample.swift\r\nLinting 'sample.swift' (1/1)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:7:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:8:64: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:9:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:10:56: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:11:66: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\nDone linting! Found 5 violations, 0 serious in 1 file.\r\n------ Autocorrecting  ------\r\nLoading configuration from '.swiftlint.yml'\r\nCorrecting Swift files at path sample.swift\r\nCorrecting 'sample.swift' (1/1)\r\nDone correcting 1 files!\r\n------  Linting again  ------\r\nLoading configuration from '.swiftlint.yml'\r\nLinting Swift files at path sample.swift\r\nLinting 'sample.swift' (1/1)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:7:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:8:64: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:9:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:10:56: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:11:66: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\nDone linting! Found 5 violations, 0 serious in 1 file.\r\n  ```\r\n</details>\r\n\r\n<details>\r\n  <summary>swiftlint 0.25.0</summary>\r\n\r\n> This version does not work as expected: 5 violations before autocorrect, none auto-corrected, still 5 violation present after autocorrect.\r\n\r\n  ```sh\r\n$ ./test.sh 0.25.0\r\n>>> Testing with version 0.25.0\r\n------ Initial linting ------\r\nLoading configuration from '.swiftlint.yml'\r\nLinting Swift files at path sample.swift\r\nLinting 'sample.swift' (1/1)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:7:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:8:64: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:9:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:10:56: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:11:66: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\nDone linting! Found 5 violations, 0 serious in 1 file.\r\n------ Autocorrecting  ------\r\nLoading configuration from '.swiftlint.yml'\r\nCorrecting Swift files at path sample.swift\r\nCorrecting 'sample.swift' (1/1)\r\nDone correcting 1 files!\r\n------  Linting again  ------\r\nLoading configuration from '.swiftlint.yml'\r\nLinting Swift files at path sample.swift\r\nLinting 'sample.swift' (1/1)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:7:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:8:64: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:9:54: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:10:56: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\n/Users/ohalligon/Desktop/swiftlint-bug-test/swiftlint/sample.swift:11:66: warning: Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)\r\nDone linting! Found 5 violations, 0 serious in 1 file.\r\n  ```\r\n</details>\r\n\r\n---\r\n\r\n\\cc @marcelofabri as discussed on Slack."}}
{"actor":{"display_login":"marcelofabri"}}