Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate SwiftLint / Fix errors #1

Merged
merged 1 commit into from
Feb 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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