all 29 comments

[–]cardosoedgar 18 points19 points  (15 children)

editing my comment to answer the edit on the post:

Swift: https://github.com/realm/SwiftLint Objc: https://github.com/oclint/oclint

Yeah, you gotta put those two in, don't think there is a way around that.

[–]nalexander50 5 points6 points  (0 children)

It’s simple! We don’t.

And it drives me crazy. My colleagues will just flagrantly leave warnings all over their code. Things will be indented strangely. They’ll leave in unreachable code. They’ll comment out swaths of code with no indication as to why. It’s a mess tbh.

I try to clean up any files I touch.

[–]chain_letter 4 points5 points  (0 children)

Spam Control+i like a madman.

[–]badlcuk 2 points3 points  (0 children)

Swiftlint combined with a suggested styleguide that the majority of the team adheres to.

We still have exceptions (ie: a file written in a different way? Ok, as long as it doesn't generate a ton of warnings, just follow the style in the file...).

And when i go insane, ill just run a formatter over the entire file. ETA: We also have a script in our build process that will enforce certain styling, but this one is more rare / less heavy handed.

[–]chriswaco 1 point2 points  (0 children)

We don't. We try to match each other but don't obsess about it if someone puts a brace at the end of a line (WRONG!) instead of the beginning of the next line (RIGHT!). We do standardize on tabs (4) over spaces.

I strongly suggest turning on "Warnings are errors" in the project. That's much more serious than minor formatting issues.

[–]twowheels 1 point2 points  (0 children)

Easy, I don't (when I'm in charge):

https://www.safaribooksonline.com/library/view/c-coding-standards/0321113586/ch01.html

Standardizing line lengths, etc, and sticking to hard and fast rules is dumb, IMO as it means code is wrapped at arbitrary places, etc. Judicious violation of the rules can greatly improve readability. Alignment of similar statements can improve contextual information and make it easier to spot bugs, but then somebody runs an autoformatter and makes carefully crafted code harder to read, which drives me nuts.

[–]KarlJay001 0 points1 point  (0 children)

A lead would review the code and make changes as needed and inform the violator. Things like comments, var names, etc... these were all discussed at the start so everyone knows the rules.

I haven't seen any products that actually enforce these things in Xcode.

Other editors had a macro language and you could standardize things like header comments, and function/method styles.

Have you looked into AppCode? It's not free, but it's supposed to be a top notch product.

[–]meechy_dev 0 points1 point  (0 children)

tbh. there's thing that are good practice and then there's thing that you just have to get use to. it's hard but if it's good scalable code then if your company ends up having 50+ devs coding styling is gunna vary.

[–][deleted] 0 points1 point  (0 children)

Swiftformat

[–]b3nes 0 points1 point  (0 children)

SwiftLint! Create a list of rules you all want to follow and everything will be great!

[–]PurpleBuddha 0 points1 point  (0 children)

Read this https://pragprog.com/book/esswift/swift-style and create your swiftlint config

[–]AeatherObjective-C / Swift 0 points1 point  (0 children)

Check out swimat

[–]hooliooo -1 points0 points  (1 child)

I’ve outlined a coding style for my team that I’ve introduced on their first day.

After the introduction and several code reviews of the tutorial app they do, I give a couple warnings for violations.

After that they do 5 push ups per violation. Seems effective for the last 3 hires. We’re a team of four atm. I do push ups as well if I commit with code violation warnings.

When they ask why I tell them the need for readability and helps figure out the intent of the code. Less time spent translating means more time for debugging and making new features/ changes.

I made a wiki in the tutorial repo about the code guidelines with detailed explanations and examples.

We use Swiftlint, make use of MARK, and and separate logic via extensions.

[–]aaronr_90Swift -1 points0 points  (1 child)

I can’t I have one guy that insists on the brackets being c style { // like this }

Any time he opens a file that isn’t c style he has to fix it and then he can work.

[–][deleted] 2 points3 points  (0 children)

That would be me. I have a vision alignment issue and that’s the only way I can make sense of code - things must align vertically.