Skip to content

Repository files navigation

Code Review

Code Review Tools, Configurations, and Recommendations

Linters

Swift Linters

swiftlint --config .swiftlint.yml

Objective-C Linters

xcodebuild -project MyProject.xcodeproj -scheme MyScheme -sdk macosx -configuration Debug build | xcpretty -r json-compilation-database -o compile_commands.json
oclint-json-compilation-database
oclint -rc CYCLOMATIC_COMPLEXITY=10 -rc LONG_CLASS=1000

OCLint requires a "JSON compilation database" files to perform it's linting. This file contains a list of the Xcode build plan with the compiler flags that Xcode will pass to the compiler for each file. This complicates using oclint since we have to first run a build pass on the project, post-process the output using xcpretty, then post-process the xcpretty output using the oclint-json-compilation-database tool.

gem install xcpretty

Formatters

Swift Formatters

  • swift-format
    • https://github.com/apple/swift-format
    • Methodology
      • Parses code into AST then outputs AST through pretty printing
      • Strips all custom formatting
      • Can modify output formatting via configuration
    • Configuration: .swift-format.json
      • Setup options:
        • ln -s swift-format.json .swift-format.json
        • mv swift-format.json .swift-format.json
swiftformat **/*.swift
  • SwiftFormat
    • https://github.com/nicklockwood/SwiftFormat
    • Methodology
      • Text parser
      • Operates on line groups
      • Can ignore some text via configuration
    • Configuration: .swiftformat
      • Rules
      • Setup options:
        • ln -s swiftformat.cfg .swiftformat
        • mv swiftformat.cfg .swiftformat
swiftformat **/*.swift

Objective-C Formatters

xcrun clang-format -i **/*.[hm]

Style Guides

About

Code Review Tools, Configurations, and Recommendations

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages