SwiftLint fails on circleCI and passes locally because of force casting

Created on 7 Mar 2018  ·  8Comments  ·  Source: realm/SwiftLint

New Issue Checklist

Bug Report

When I enable force casting as a rule in my linter it makes my build to fail on circleci. I installed the swiftlinter via cocoa pods. It keeps complaining about force casting as you can see below. I think it has something to do with the run script that for swxftlint.

Complete output when running SwiftLint, including the stack trace and command used
Testing failed:
    Force Cast Violation: Force casts should be avoided. (force_cast)
    Force Cast Violation: Force casts should be avoided. (force_cast)
    Force Cast Violation: Force casts should be avoided. (force_cast)
** TEST FAILED **


The following build commands failed:
    PhaseScriptExecution Run\ Script /Users/distiller/Library/Developer/Xcode/DerivedData/Freshly-aqfftomwdlyzfadmktypldmeqhgq/Build/Intermediates.noindex/Freshly.build/Debug-iphonesimulator/Freshly\ Dev.build/Script-DDBA23CD2021057C00E0D5AE.sh
(1 failure)
$ swiftlint lint

Environment

  • SwiftLint version (run swiftlint version to be sure)?
  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
  • Paste your configuration file:
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Packages
- Pods
- FreshlyTests
- FreshlyUITests
- Freshly/Controllers/
- Freshly/AppDelegate.swift
- Freshly/lib/
- Freshly/models/
- Freshly/style/
- Freshly/test-helpers/


opt_in_rules: # some rules are only opt-in


disabled_rules: # rule identifiers to exclude from running
- valid_docs   # /// is valid and used by Xcode
- cyclomatic_complexity
- identifier_name
- syntactic_sugar
- type_body_length
- function_body_length
- file_length
- vertical_parameter_alignment
- function_parameter_count
- implicit_getter
- force_try
- shorthand_operator
- type_name
- large_tuple
- trailing_whitespace
- opening_brace
- colon
- comma
- todo
- empty_parentheses_with_trailing_closure
- unneeded_break_in_switch
- unused_closure_parameter
- closure_parameter_position
- switch_case_alignment

line_length: 270

type_name:
min_length: 2


  • Are you using nested configurations?
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcode-select -p)?
  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
    to quickly test if your example is really demonstrating the issue. If your example is more
    complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.
// This triggers a violation:
let foo = try! bar()
help

Most helpful comment

We're also still experiencing this issue on 2.0, fixed by explicitly adding included as mentioned above.

All 8 comments

Did you add a script to run SwiftLint in your build phases? How's that script?

@marcelofabri I did add that. Here's the script that I added:
"${PODS_ROOT}/SwiftLint/swiftlint"

@marcelofabri are you sure that it's not a bug ?

This looks like a configuration issue. I suggest you to add the full log from Circle CI so we can understand what's happening.

I also would try to run exactly what Circle runs but locally.

@marcelofabri Running the script that Circle locally, works just fine. Here's the log that I keep (running with cache and without cache) getting:

▸ Compiling ChooseMeals.storyboard
▸ Compiling Main.storyboard
▸ Compiling Web.storyboard
▸ Compiling CalendarModule.storyboard
▸ Compiling Upcoming.storyboard
▸ Compiling MealPlanner.storyboard
▸ Compiling AppStatus.storyboard
▸ Compiling Forms.storyboard
▸ Processing Freshly Dev-Info.plist
▸ Generating 'Freshly\ Dev.app.dSYM'
▸ Running script 'Run Script'
▸ Running script '[CP] Embed Pods Frameworks'
▸ Running script '[CP] Copy Pods Resources'
▸ Running script 'Run Script'
▸ Running script 'Run Script'

⚠️ /Users/distiller/freshly_ios/Freshly/Controllers/choose-meals/ChooseMealsConfigCell.swift:41:13: Statement Position Violation: Else and catch should be on the same line, one space after the previous declaration. (statement_position)

Linting 'HomeController.swift' (12/264)
^

* BUILD FAILED *

The following build commands failed:
PhaseScriptExecution Run\ Script /Users/distiller/Library/Developer/Xcode/DerivedData/Freshly-aqfftomwdlyzfadmktypldmeqhgq/Build/Intermediates.noindex/Freshly.build/Debug-iphonesimulator/Freshly\ Dev.build/Script-DD8F23DD204E04A700609DF3.sh
(1 failure)
2018-03-20 06:36:01.810 xcodebuild[1153:7411] [MT] IDETestOperationsObserverDebug: (C7475127-42C8-4321-AB5C-12500CAA18BF) Beginning test session FreshlyUITests-C7475127-42C8-4321-AB5C-12500CAA18BF at 2018-03-20 06:36:01.810 with Xcode 9C40b on target {
SimDevice: iPhone 6s (D2CE8B34-2AE7-45E4-8BCF-54F4D60212D6, iOS 10.3, Booted)
} (10.3.1 (14E8301))
2018-03-20 06:36:01.817 xcodebuild[1153:7411] [MT] IDETestOperationsObserverDebug: (612A415F-458E-4ADB-9394-0C584ED3F6F4) Beginning test session FreshlyTests-612A415F-458E-4ADB-9394-0C584ED3F6F4 at 2018-03-20 06:36:01.817 with Xcode 9C40b on target {
SimDevice: iPhone 6s (D2CE8B34-2AE7-45E4-8BCF-54F4D60212D6, iOS 10.3, Booted)

Yes. It was a Circle issue. As soon as I updated to Circle 2.0 it resolved
this issue.

I started having the same problem, it happened on Circle 2.0 and 2.1.
How I solved it was by explicitly adding included the list of folders I want to scan.

In my project they are only 2 (main app and tests) so no big deal, but still I think this is a bug.

If need any more info feel free to ask :)

We're also still experiencing this issue on 2.0, fixed by explicitly adding included as mentioned above.

Was this page helpful?
0 / 5 - 0 ratings