SwiftGen / SwiftGenKit

The framework behind SwiftGen, responsible for parsing various resources and turn them into Stencil contexts
MIT License
9 stars 8 forks source link

Swiftlint reporting issues but build passes #31

Closed Liquidsoul closed 7 years ago

Liquidsoul commented 7 years ago

Steps to reproduce

From Xcode:

  1. clone the repository
  2. open the workspace
  3. run the tests

Results: build and tests passes but 10 buildtime errors are reported (identifier_name swiftlint errors)

From command line:

  1. clone the repository
  2. run rake lint:code

Results: command fails with the following output.

Output ``` == Linting the code == swiftlint lint --no-cache --strict --path Sources Linting Swift files at path Sources Linting 'AssetsCatalogParser.swift' (1/11) Linting 'ColorsFileParser.swift' (2/11) Linting 'FontsFileParser.swift' (3/11) Linting 'StoryboardParser.swift' (4/11) Linting 'StringsFileParser.swift' (5/11) Linting 'AssetsCatalogContext.swift' (6/11) Linting 'ColorsContext.swift' (7/11) Linting 'FontsContext.swift' (8/11) Linting 'StoryboardsContext.swift' (9/11) Linting 'StringsContext.swift' (10/11) Linting 'Command.swift' (11/11) S/Users/sebastienduperron/Perso/wiftGen/SwiftGenKit/Sources/Parsers/FontsFileParser.swift:72:21: warning: Unused Optional Binding Violation: Prefer `!= nil` over `let _ =` (unused_optional_binding) SwiftGen/SwiftGenKit/Sources/Parsers/StringsFileParser.swift:11:8: error: Identifier Name Violation: Enum element name should start with a lowercase character: 'FailureOnLoading' (identifier_name) SwiftGen/SwiftGenKit/Sources/Parsers/StringsFileParser.swift:12:8: error: Identifier Name Violation: Enum element name should start with a lowercase character: 'InvalidFormat' (identifier_name) SwiftGen/SwiftGenKit/Sources/Parsers/StringsFileParser.swift:54:10: error: Identifier Name Violation: Enum element name should start with a lowercase character: 'Object' (identifier_name) SwiftGen/SwiftGenKit/Sources/Parsers/StringsFileParser.swift:55:10: error: Identifier Name Violation: Enum element name should start with a lowercase character: 'Float' (identifier_name) SwiftGen/SwiftGenKit/Sources/Parsers/StringsFileParser.swift:56:10: error: Identifier Name Violation: Enum element name should start with a lowercase character: 'Int' (identifier_name) SwiftGen/SwiftGenKit/Sources/Parsers/StringsFileParser.swift:57:10: error: Identifier Name Violation: Enum element name should start with a lowercase character: 'Char' (identifier_name) SwiftGen/SwiftGenKit/Sources/Parsers/StringsFileParser.swift:59:10: error: Identifier Name Violation: Enum element name should start with a lowercase character: 'Pointer' (identifier_name) SwiftGen/SwiftGenKit/Sources/Parsers/StringsFileParser.swift:60:10: error: Identifier Name Violation: Enum element name should start with a lowercase character: 'Unknown' (identifier_name) SwiftGen/SwiftGenKit/Sources/Parsers/ColorsFileParser.swift:22:35: error: Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'k' (identifier_name) Done linting! Found 10 violations, 9 serious in 11 files. rake aborted! Command failed with status (2): [swiftlint lint --no-cache --strict --path ...] SwiftGen/SwiftGenKit/rakelib/utils.rake:64:in `plain' SwiftGen/SwiftGenKit/rakelib/utils.rake:18:in `run' SwiftGen/SwiftGenKit/rakelib/lint.rake:22:in `block (2 levels) in ' Tasks: TOP => lint:code (See full trace by running task with --trace) ```

Solutions

I see two possible solutions for this:

  1. fix the issues. This seems to work but maybe I am missing the big picture here and the impact on the main SwiftGen project.
  2. ignore the identifier_name rule with a .swiftlint.yml file or with comments where appropriate.

Solution 1 is already implemented here https://github.com/Liquidsoul/SwiftGenKit/commit/4b98f496a12c38733729564cf0486f13135c664f

djbe commented 7 years ago

Hi @Liquidsoul,

You're welcome to create a PR to fix this, we somehow missed it during the swift 3 migration, and haven't noticed them until now. 🤷‍♂️

Funnily enough, I partially addressed this in https://github.com/SwiftGen/SwiftGenKit/pull/14.