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

“swiftlint quit unexpectedly.” as Build Tool Plugin w/ custom rules #5284

Open
2 tasks done
capnslipp opened this issue Oct 17, 2023 · 2 comments
Open
2 tasks done
Labels
enhancement Ideas for improvements of existing features and rules.

Comments

@capnslipp
Copy link

New Issue Checklist

Describe the bug

SwiftLint crashes (EXC_CRASH (SIGABRT)) when used as a Build Tool Plugin, with certain custom rules (see Environment).

macOS Problem Report dialog:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               swiftlint [21508]
Path:                  /Users/USER/Library/Developer/Xcode/DerivedData/MapsGL_Prototype-cvtvxgsihvkahdfubyhlchwstanh/SourcePackages/artifacts/swiftlint/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-0.53.0-macos/bin/swiftlint
Identifier:            swiftlint
Version:               ???
Code Type:             ARM-64 (Native)
Parent Process:        Xcode [2757]
Responsible:           Xcode [2757]
User ID:               501

Date/Time:             2023-10-17 13:30:23.5834 -0500
OS Version:            macOS 13.6 (22G120)
Report Version:        12
Anonymous UUID:        48F91BEB-D548-5481-807A-49062AD093F7

Sleep/Wake UUID:       70F5F817-9D02-460F-BEDC-3844C0547FF0

Time Awake Since Boot: 80000 seconds
Time Since Wake:       271 seconds

System Integrity Protection: enabled

Crashed Thread:        1

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 6 Abort trap: 6
Terminating Process:   swiftlint [21508]

Application Specific Information:
abort() called


Thread 0::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x18b8fff34 mach_msg2_trap + 8
1   libsystem_kernel.dylib        	       0x18b912260 mach_msg2_internal + 80
2   libsystem_kernel.dylib        	       0x18b908b98 mach_msg_overwrite + 604
3   libsystem_kernel.dylib        	       0x18b9002b0 mach_msg + 24
4   CoreFoundation                	       0x18ba1e774 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                	       0x18ba1d054 __CFRunLoopRun + 1208
6   CoreFoundation                	       0x18ba1c448 CFRunLoopRunSpecific + 612
7   CoreFoundation                	       0x18baa152c CFRunLoopRun + 64
8   libswift_Concurrency.dylib    	       0x21911685c swift_task_asyncMainDrainQueueImpl() + 40
9   libswift_Concurrency.dylib    	       0x219116834 swift_task_asyncMainDrainQueue + 100
10  swiftlint                     	       0x10080f088 main + 84
11  dyld                          	       0x18b5e7f28 start + 2236

Thread 1 Crashed:
0   libsystem_kernel.dylib        	       0x18b908744 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x18b93fc28 pthread_kill + 288
2   libsystem_c.dylib             	       0x18b84dae8 abort + 180
3   swiftlint                     	       0x100b20968 0x100804000 + 3262824
4   swiftlint                     	       0x100b1d690 0x100804000 + 3249808
5   swiftlint                     	       0x1008431d8 0x100804000 + 258520
6   swiftlint                     	       0x10083b760 0x100804000 + 227168
7   swiftlint                     	       0x1008420f8 0x100804000 + 254200
8   swiftlint                     	       0x10081a4ed 0x100804000 + 91373
9   swiftlint                     	       0x10081a8fd 0x100804000 + 92413
10  swiftlint                     	       0x10107050d 0x100804000 + 8832269
11  swiftlint                     	       0x10080f105 0x100804000 + 45317
12  libswift_Concurrency.dylib    	       0x21911727d completeTaskAndRelease(swift::AsyncContext*, swift::SwiftError*) + 1

Thread 2:
0   libsystem_pthread.dylib       	       0x18b93ad8c start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib       	       0x18b93ad8c start_wqthread + 0


Thread 1 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000016   x5: 0x0000000000000001   x6: 0x0000000000000000   x7: 0x0000000000000403
    x8: 0x44f4eb77995de61d   x9: 0x44f4eb76f635d61d  x10: 0x0000000000000e20  x11: 0x00000000000007fb
   x12: 0x00000000af0c8862  x13: 0x00000000000007fd  x14: 0x00000000af2c9072  x15: 0x00000000af0c8862
   x16: 0x0000000000000148  x17: 0x00000001eb4ef3f8  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x000000016f683000  x21: 0x0000000000000c0b  x22: 0x000000016f6830e0  x23: 0x000060000220ce20
   x24: 0x0000000000000000  x25: 0x0000000000000000  x26: 0x0000600001d0c0f0  x27: 0x0000000000000000
   x28: 0x0000000000000000   fp: 0x000000016f6825a0   lr: 0x000000018b93fc28
    sp: 0x000000016f682580   pc: 0x000000018b908744 cpsr: 0x40001000
   far: 0x00000001e6f7bff8  esr: 0x56000080  Address size fault

Binary Images:
       0x100804000 -        0x10126ffff swiftlint (*) <b2f1aad7-e586-3b5c-89b3-cdaab4729df4> /Users/USER/Library/Developer/Xcode/DerivedData/MapsGL_Prototype-cvtvxgsihvkahdfubyhlchwstanh/SourcePackages/artifacts/swiftlint/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-0.53.0-macos/bin/swiftlint
       0x18b8ff000 -        0x18b938fe7 libsystem_kernel.dylib (*) <1adb8ddc-762b-3b9f-a290-ca1e5ee7b419> /usr/lib/system/libsystem_kernel.dylib
       0x18b99f000 -        0x18be78fff com.apple.CoreFoundation (6.9) <77747d94-2513-3133-a53b-e032d73058d7> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
       0x2190cf000 -        0x219129ffb libswift_Concurrency.dylib (*) <6b78ae7c-22cc-3dae-b8a6-bf669887afc8> /usr/lib/swift/libswift_Concurrency.dylib
       0x18b5e2000 -        0x18b670587 dyld (*) <49204446-242b-3d1e-9704-32f8ac99723e> /usr/lib/dyld
       0x18b939000 -        0x18b945fff libsystem_pthread.dylib (*) <1f30fb9a-bdf9-32db-a709-8417666a7e45> /usr/lib/system/libsystem_pthread.dylib
       0x18b7d7000 -        0x18b855ff7 libsystem_c.dylib (*) <949943e2-52cb-3c95-ab08-7ed984333d03> /usr/lib/system/libsystem_c.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 8
    thread_create: 0
    thread_set_state: 44

VM Region Summary:
ReadOnly portion of Libraries: Total=925.9M resident=0K(0%) swapped_out_or_unallocated=925.9M(100%)
Writable regions: Total=686.0M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=686.0M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
Kernel Alloc Once                   32K        1 
MALLOC                           171.2M       17 
MALLOC guard page                   96K        5 
MALLOC_MEDIUM (reserved)         120.0M        1         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                       56.1M        4 
Stack                             9808K        4 
__AUTH                             315K       60 
__AUTH_CONST                      3741K      145 
__DATA                            4002K      141 
__DATA_CONST                      4523K      147 
__DATA_DIRTY                       361K       58 
__LINKEDIT                       804.3M        2 
__OBJC_RO                         66.4M        1 
__OBJC_RW                         2012K        1 
__TEXT                           121.6M      155 
dyld private memory                272K        2 
mapped file                       29.2M        3 
shared memory                       64K        4 
===========                     =======  ======= 
TOTAL                              1.7G      753 
TOTAL, minus reserved VM space     1.2G      753 



-----------
Full Report
-----------

{"app_name":"swiftlint","timestamp":"2023-10-17 13:30:23.00 -0500","app_version":"","slice_uuid":"b2f1aad7-e586-3b5c-89b3-cdaab4729df4","build_version":"","platform":1,"share_with_app_devs":1,"is_first_party":1,"bug_type":"309","os_version":"macOS 13.6 (22G120)","roots_installed":0,"incident_id":"2D4DB121-BB83-41CA-BB4E-085E16B5E9DB","name":"swiftlint"}
{
  "uptime" : 80000,
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "Mac14,9",
  "coalitionID" : 3992,
  "osVersion" : {
    "train" : "macOS 13.6",
    "build" : "22G120",
    "releaseType" : "User"
  },
  "captureTime" : "2023-10-17 13:30:23.5834 -0500",
  "incident" : "2D4DB121-BB83-41CA-BB4E-085E16B5E9DB",
  "pid" : 21508,
  "translated" : false,
  "cpuType" : "ARM-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2023-10-17 13:30:23.5584 -0500",
  "procStartAbsTime" : 1941086976547,
  "procExitAbsTime" : 1941087571076,
  "procName" : "swiftlint",
  "procPath" : "\/Users\/USER\/Library\/Developer\/Xcode\/DerivedData\/MapsGL_Prototype-cvtvxgsihvkahdfubyhlchwstanh\/SourcePackages\/artifacts\/swiftlint\/SwiftLintBinary\/SwiftLintBinary.artifactbundle\/swiftlint-0.53.0-macos\/bin\/swiftlint",
  "parentProc" : "Xcode",
  "parentPid" : 2757,
  "coalitionName" : "com.apple.dt.Xcode",
  "crashReporterKey" : "48F91BEB-D548-5481-807A-49062AD093F7",
  "responsiblePid" : 2757,
  "responsibleProc" : "Xcode",
  "codeSigningID" : "swiftlint",
  "codeSigningTeamID" : "",
  "codeSigningFlags" : 570556929,
  "codeSigningValidationCategory" : 10,
  "codeSigningTrustLevel" : 0,
  "wakeTime" : 271,
  "sleepWakeUUID" : "70F5F817-9D02-460F-BEDC-3844C0547FF0",
  "sip" : "enabled",
  "exception" : {"codes":"0x0000000000000000, 0x0000000000000000","rawCodes":[0,0],"type":"EXC_CRASH","signal":"SIGABRT"},
  "termination" : {"flags":0,"code":6,"namespace":"SIGNAL","indicator":"Abort trap: 6","byProc":"swiftlint","byPid":21508},
  "asi" : {"libsystem_c.dylib":["abort() called"]},
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":44,"task_for_pid":8},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 1,
  "threads" : [{"id":2349673,"queue":"com.apple.main-thread","frames":[{"imageOffset":3892,"symbol":"mach_msg2_trap","symbolLocation":8,"imageIndex":1},{"imageOffset":78432,"symbol":"mach_msg2_internal","symbolLocation":80,"imageIndex":1},{"imageOffset":39832,"symbol":"mach_msg_overwrite","symbolLocation":604,"imageIndex":1},{"imageOffset":4784,"symbol":"mach_msg","symbolLocation":24,"imageIndex":1},{"imageOffset":522100,"symbol":"__CFRunLoopServiceMachPort","symbolLocation":160,"imageIndex":2},{"imageOffset":516180,"symbol":"__CFRunLoopRun","symbolLocation":1208,"imageIndex":2},{"imageOffset":513096,"symbol":"CFRunLoopRunSpecific","symbolLocation":612,"imageIndex":2},{"imageOffset":1058092,"symbol":"CFRunLoopRun","symbolLocation":64,"imageIndex":2},{"imageOffset":292956,"symbol":"swift_task_asyncMainDrainQueueImpl()","symbolLocation":40,"imageIndex":3},{"imageOffset":292916,"symbol":"swift_task_asyncMainDrainQueue","symbolLocation":100,"imageIndex":3},{"imageOffset":45192,"symbol":"main","symbolLocation":84,"imageIndex":0},{"imageOffset":24360,"symbol":"start","symbolLocation":2236,"imageIndex":4}]},{"triggered":true,"id":2349674,"threadState":{"x":[{"value":0},{"value":0},{"value":0},{"value":0},{"value":22},{"value":1},{"value":0},{"value":1027},{"value":4968855187803203101},{"value":4968855185065891357},{"value":3616},{"value":2043},{"value":2936834146},{"value":2045},{"value":2938933362},{"value":2936834146},{"value":328},{"value":8242787320},{"value":0},{"value":6},{"value":6164066304},{"value":3083},{"value":6164066528},{"value":105553151970848},{"value":0},{"value":0},{"value":105553146724592},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6636698664},"cpsr":{"value":1073745920},"fp":{"value":6164063648},"sp":{"value":6164063616},"esr":{"value":1442840704,"description":" Address size fault"},"pc":{"value":6636472132,"matchesCrashFrame":1},"far":{"value":8169963512}},"frames":[{"imageOffset":38724,"symbol":"__pthread_kill","symbolLocation":8,"imageIndex":1},{"imageOffset":27688,"symbol":"pthread_kill","symbolLocation":288,"imageIndex":5},{"imageOffset":486120,"symbol":"abort","symbolLocation":180,"imageIndex":6},{"imageOffset":3262824,"imageIndex":0},{"imageOffset":3249808,"imageIndex":0},{"imageOffset":258520,"imageIndex":0},{"imageOffset":227168,"imageIndex":0},{"imageOffset":254200,"imageIndex":0},{"imageOffset":91373,"imageIndex":0},{"imageOffset":92413,"imageIndex":0},{"imageOffset":8832269,"imageIndex":0},{"imageOffset":45317,"imageIndex":0},{"imageOffset":295549,"symbol":"completeTaskAndRelease(swift::AsyncContext*, swift::SwiftError*)","symbolLocation":1,"imageIndex":3}]},{"id":2349675,"frames":[{"imageOffset":7564,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]},{"id":2349676,"frames":[{"imageOffset":7564,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":5}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4303372288,
    "size" : 10928128,
    "uuid" : "b2f1aad7-e586-3b5c-89b3-cdaab4729df4",
    "path" : "\/Users\/USER\/Library\/Developer\/Xcode\/DerivedData\/MapsGL_Prototype-cvtvxgsihvkahdfubyhlchwstanh\/SourcePackages\/artifacts\/swiftlint\/SwiftLintBinary\/SwiftLintBinary.artifactbundle\/swiftlint-0.53.0-macos\/bin\/swiftlint",
    "name" : "swiftlint"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6636433408,
    "size" : 237544,
    "uuid" : "1adb8ddc-762b-3b9f-a290-ca1e5ee7b419",
    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
    "name" : "libsystem_kernel.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6637088768,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.CoreFoundation",
    "size" : 5087232,
    "uuid" : "77747d94-2513-3133-a53b-e032d73058d7",
    "path" : "\/System\/Library\/Frameworks\/CoreFoundation.framework\/Versions\/A\/CoreFoundation",
    "name" : "CoreFoundation",
    "CFBundleVersion" : "1979.101"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 9010212864,
    "size" : 372732,
    "uuid" : "6b78ae7c-22cc-3dae-b8a6-bf669887afc8",
    "path" : "\/usr\/lib\/swift\/libswift_Concurrency.dylib",
    "name" : "libswift_Concurrency.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6633168896,
    "size" : 583048,
    "uuid" : "49204446-242b-3d1e-9704-32f8ac99723e",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6636670976,
    "size" : 53248,
    "uuid" : "1f30fb9a-bdf9-32db-a709-8417666a7e45",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6635220992,
    "size" : 520184,
    "uuid" : "949943e2-52cb-3c95-ab08-7ed984333d03",
    "path" : "\/usr\/lib\/system\/libsystem_c.dylib",
    "name" : "libsystem_c.dylib"
  }
],
  "sharedCache" : {
  "base" : 6632505344,
  "size" : 3553476608,
  "uuid" : "c26be8cd-619e-3513-8673-3ff826317005"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=925.9M resident=0K(0%) swapped_out_or_unallocated=925.9M(100%)\nWritable regions: Total=686.0M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=686.0M(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nActivity Tracing                   256K        1 \nKernel Alloc Once                   32K        1 \nMALLOC                           171.2M       17 \nMALLOC guard page                   96K        5 \nMALLOC_MEDIUM (reserved)         120.0M        1         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nSTACK GUARD                       56.1M        4 \nStack                             9808K        4 \n__AUTH                             315K       60 \n__AUTH_CONST                      3741K      145 \n__DATA                            4002K      141 \n__DATA_CONST                      4523K      147 \n__DATA_DIRTY                       361K       58 \n__LINKEDIT                       804.3M        2 \n__OBJC_RO                         66.4M        1 \n__OBJC_RW                         2012K        1 \n__TEXT                           121.6M      155 \ndyld private memory                272K        2 \nmapped file                       29.2M        3 \nshared memory                       64K        4 \n===========                     =======  ======= \nTOTAL                              1.7G      753 \nTOTAL, minus reserved VM space     1.2G      753 \n",
  "legacyInfo" : {
  "threadTriggered" : {

  }
},
  "logWritingSignature" : "93f1b38d00bb2679f55214be976d3304089a5ba7",
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "62c74108bcb0435c2153f963",
      "factorPackIds" : {
        "SIRI_TEXT_TO_SPEECH" : "651df1e7be905e686a05edc8"
      },
      "deploymentId" : 240000367
    },
    {
      "rolloutId" : "645c2d2f9e69a025b0a37e29",
      "factorPackIds" : {

      },
      "deploymentId" : 240000003
    }
  ],
  "experiments" : [

  ]
}
}

Model: Mac14,9, BootROM 10151.0.255.0.4, proc 10:6:4 processors, 32 GB, SMC 
Graphics: Apple M2 Pro, Apple M2 Pro, Built-In
Display: MacBook Pro 14", 3024 x 1964 Retina, Main, MirrorOff, Online
Memory Module: LPDDR5, Hynix
AirPort: spairport_wireless_card_type_wifi (0x14E4, 0x4388), wl0: Jun 11 2023 05:20:59 version 23.20.95.0.40.50.92 FWID 01-ec505a98
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB31Bus
USB Device: USB31Bus
USB Device: USB31Bus
Thunderbolt Bus: MacBook Pro, Apple Inc.
Thunderbolt Bus: MacBook Pro, Apple Inc.
Thunderbolt Bus: MacBook Pro, Apple Inc.

Running swiftlint lint on the CLI works displays the following warning:

warning: Cannot parse YAML file: 95:21: error: scanner: while parsing a quoted scalar in line 95, column 12
found unknown escape character:
    regex: "(?-s)(\n\s*){3,}\n(\t|    )"
                    ^ – Falling back to default configuration

but then continues on with:

Linting Swift files in current working directory
Linting 'AerisCustomLayerHost.swift' (1/98)
Linting 'MapsGL_PrototypeApp.swift' (2/98)
…
Done linting! Found 2384 violations, 53 serious in 98 files.

and does not crash.

(This is issue is not about the bad config itself; I'm aware and I'll fix it; this issue about about the plugin EXC_CRASH-ing.)

Environment

  • SwiftLint version: 0.53.0 package version (also 0.53.0 for the also-installed CLI standalone version)
  • Installation method used: SPM via Xcode project's Package Dependencies, and also via Package.swift (but also installed on the CLI with brew)
  • Paste your configuration file:
# By default, SwiftLint uses a set of sensible default rules you can adjust:
disabled_rules: # rule identifiers turned on by default to exclude from running
  - colon
  - comment_spacing
  - empty_enum_arguments
  - identifier_name
  - opening_brace
  - private_over_fileprivate
  - redundant_optional_initialization
  - statement_position
  - trailing_whitespace
opt_in_rules: # some rules are turned off by default, so you need to opt-in
  - indentation_width
  - vertical_whitespace_closing_braces
  - vertical_whitespace_opening_braces
  - yoda_condition
  #- empty_count # find all the available rules by running: `swiftlint rules`

# Alternatively, specify all rules explicitly by uncommenting this option:
# only_rules: # delete `disabled_rules` & `opt_in_rules` if using this
#   - empty_parameters
#   - vertical_whitespace



analyzer_rules: # rules run by `swiftlint analyze`
  - explicit_self

included: # case-sensitive paths to include during linting. `--path` is ignored if present
  #- Sources
excluded: # case-sensitive paths to ignore during linting. Takes precedence over `included`
  - Carthage
  - Pods
  - Sources/ExcludedFolder
  - Sources/ExcludedFile.swift
  - Sources/*/ExcludedFile.swift # exclude files with a wildcard

# If true, SwiftLint will not fail if no lintable files are found.
allow_zero_lintable_files: false

# If true, SwiftLint will treat all warnings as errors.
strict: false


# configurable rules can be customized from this configuration file
# binary rules can set their severity level
cyclomatic_complexity:
  ignores_case_statements: true
force_cast: warning
force_try: warning
identifier_name:
  min_length:
    warning: 2
    error: 1
large_tuple:
  warning: 3
  error: 999
line_length:
  warning: 200
  error: 999
  ignores_urls: true
  ignores_comments: true
  ignores_interpolated_strings: true
switch_case_alignment:
  indented_cases: true
trailing_comma:
  mandatory_comma: true
type_name:
  min_lenth:
    warning: 2
    error: 1
  allowed_symbols: ["_"]
vertical_whitespace:
  max_empty_lines: 3

reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, codeclimate, junit, html, emoji, sonarqube, markdown, github-actions-logging, summary)


custom_rules:
  stub:
    included:
      - ".*\\.swift"
    name: "Stub Violation"
    regex: "STUB"
    match_kinds:
        - comment
    message: "STUB code should be resolved"
    severity: warning
  
  # This custom rule seems to be causing the crashes— comment it out and there's no issues.
  max_double_blank_lines_in_indented_code:
    included:
      - ".*\\.swift"
    name: "Maximum of Double Blank Lines In Indented Code"
    regex: "(?-s)(\n\s*){3,}\n(\t|    )"
    message: "Maximum of Double Blank Lines In Indented Code"
    severity: warning
  
  triple_blank_lines_before_sectional_mark:
    included:
      - ".*\\.swift"
    name: "Triple Blank Lines Before Sectional Mark"
    regex: "(?<!\n\n\n)\n// MARK: -"
    match_kinds:
        - comment
    message: "`MARK -` comments should be preceded by 3 blank lines"
    severity: warning
  
  triple_blank_lines_after_imports:
    included:
      - ".*\\.swift"
    name: "Triple Blank Lines After Imports"
    regex: "(?-s)import .+\n(?!\n\n\n|\n?(@testable )?import|\n?\/\/.+\nimport)"
    message: "The last import should be followed by 3 blank lines. (Up to 1 blank line and comments are allowed between imports.)"
    severity: warning
  • Are you using nested configurations? Nope
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcodebuild -version)? Xcode 15.0 Build version 15A240d
  • Do you have a sample that shows the issue? Crash dialog pops up as soon as you run Product > Build (⌘B) in Xcode. Shouldn't require any specific source code.
@mildm8nnered
Copy link
Collaborator

So this has been bothering me for a while. SwiftLint is a bit over-enthusiastic about calling its equivalent of fatalError in a few cases - maybe even just this one, and that function calls abort().

Your config will do the same on the command line - this is not Build Tool Plugin related.

% swiftlint --config /tmp/t.yml
The operation couldn’t be completed. (SwiftLintCore.Issue error 6.)
Could not read configuration: file Configuration.swift, line 236
zsh: abort      swiftlint --config /tmp/t.yml

queuedFatalError("Could not read configuration")

We should probably just exit(2) or something in this particular case.

@SimplyDanny SimplyDanny added the enhancement Ideas for improvements of existing features and rules. label Oct 18, 2023
@capnslipp
Copy link
Author

My expectation as a user is that Xcode's build process should abort, with a single error in the Issues Navigator explaining the .swiftlint.yml formatting error (or whatever other reason SwiftLint couldn't continue).

I'm not sure if that's as simple as reporting a single error line through the normal mechanisms (a stdout line with error: …, right?) before exit()ing, or it's more involved than that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Ideas for improvements of existing features and rules.
Projects
None yet
Development

No branches or pull requests

3 participants