Skip to content

Commit

Permalink
- Integrate swiftlint into Makefile.
Browse files Browse the repository at this point in the history
- Fix linter warnings
- Treat warnings as errors in xcodeproj
  • Loading branch information
rahul-malik committed Feb 15, 2017
1 parent 8b6a88c commit 3f15d21
Show file tree
Hide file tree
Showing 19 changed files with 727 additions and 674 deletions.
26 changes: 11 additions & 15 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
disabled_rules: # rule identifiers to exclude from running
- force_cast
- function_body_length
- line_length
- todo
- line_length
- type_body_length
- variable_name
- cyclomatic_complexity
included: # paths to include during linting. `--path` is ignored if present.
- PINModel
excluded: # paths to ignore during linting.
- PINModel/Carthage
- PINModel/CommandKit
- Sources
- Tests
- Utility

# parameterized rules can be customized from this configuration file
line_length: 110
line_length: 120

# parameterized rules are first parameterized as a warning level, then error level.
type_body_length:
- 300 # warning
- 400 # error
# parameterized rules are first parameterized as a warning level, then error level.
variable_name_max_length:
- 40 # warning
- 60 # error
# parameterized rules are first parameterized as a warning level, then error level.
variable_name_min_length:
- 3 # warning
- 2 # error

reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji)

9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# This makefile exposes targets that unify building, testing and archiving of
# PINModel

SWIFT_LINT_EXEC=`which swiftlint`

.PHONY: all clean build test archive

all: clean build test archive

clean:
swift build --clean

build:
lint:
$(SWIFT_LINT_EXEC) lint --reporter emoji

build: lint
swift build

build_test_index_linux:
Expand All @@ -17,7 +22,7 @@ build_test_index_linux:
test: build_test_index_linux build
swift test

archive:
archive: lint
swift build -c release -Xswiftc -static-stdlib

archive_linux: clean
Expand Down
6 changes: 3 additions & 3 deletions Sources/Core/FileGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum GenerationParameterType {
}

protocol FileGeneratorManager {
static func filesToGenerate(descriptor: SchemaObjectRoot, generatorParameters: GenerationParameters) -> Array<FileGenerator>
static func filesToGenerate(descriptor: SchemaObjectRoot, generatorParameters: GenerationParameters) -> [FileGenerator]
}

protocol FileGenerator {
Expand All @@ -45,7 +45,7 @@ extension FileGenerator {
let header = [
"//",
"// \(copy.fileName)",
"// Pinterest", // TODO (allow other copyrights?)
"// Autogenerated by plank",
"//",
"// DO NOT EDIT - EDITS WILL BE OVERWRITTEN",
"// Copyright (c) \(year) Pinterest, Inc. All rights reserved.",
Expand All @@ -60,7 +60,7 @@ extension FileGenerator {

func generateFile(_ schema: SchemaObjectRoot, outputDirectory: URL, generationParameters: GenerationParameters) {
for var file in ObjectiveCFileGenerator.filesToGenerate(descriptor: schema, generatorParameters: generationParameters) {
let fileContents = file.renderFile() + "\n" // Ensure there is exactly one new line a the end of the file. // TODO - Have `FilePrinter` take care of things like this.
let fileContents = file.renderFile() + "\n" // Ensure there is exactly one new line a the end of the file
do {
try fileContents.write(
to: URL(string: file.fileName, relativeTo: outputDirectory)!,
Expand Down
Loading

0 comments on commit 3f15d21

Please sign in to comment.