Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)

I am currently using SwiftLint for the perfect coding standards in my projects. After installing it I am getting so many warnings and the common ones are:

"Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)".

enter image description here

var indexPath:IndexPath!
static let collapsedHeigth : CGFloat = 80
static let expandedHeigth : CGFloat = 210

What does it means and how to improve it?

like image 677
Michelle Root Avatar asked Jun 24 '17 15:06

Michelle Root


1 Answers

The warning is telling you that your code should be:

static let collapsedHeigth: CGFloat = 80
static let expandedHeigth: CGFloat = 210

The colon should not have whitespace before it when declaring variables or when creating key-value pairs in a dictionary.

let someDictionary = [ "Hello": 4, "Bye": 42 ]

BTW - you can solve the "trailing whitespace" errors with a simple setting in Xcode preferences. Go to the Text Editing tab of the preferences and enable the "Automatically trim trailing whitespace" option.

like image 159
rmaddy Avatar answered Nov 18 '22 07:11

rmaddy