danger / swift

⚠️ Stop saying "you forgot to …" in code review
https://danger.systems/swift/
MIT License
1.05k stars 141 forks source link

"Error deserializing SwiftLint JSON response" when using Xcode 13.4 on GitHub Actions #522

Closed ghost closed 2 years ago

ghost commented 2 years ago

I have updated my swift package to swift-tools-version:5.6, and my GA workflow to use Xcode 13.4:

jobs:
  Lint:
    runs-on: macos-12
    env:
      DEVELOPER_DIR: "/Applications/Xcode_13.4.app/Contents/Developer"
    ...

Now I get this error from Danger:

. Fails
🚫 Error deserializing SwiftLint JSON response (): dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Unable to parse empty data." UserInfo={NSDebugDescription=Unable to parse empty data.})))

My Dangerfile.swift is simple:

import Danger
let danger = Danger()
SwiftLint.lint(inline: true)

Any ideas how to fix?

f-meloni commented 2 years ago

It seems that the issue is from Swiftlint's JSON, which is empty, can I see your Swiftlint config please?

ghost commented 2 years ago

My .swiftlint.yml (worked fine before the update):

excluded:
  - Pods
  - Package.swift
  - .build

disabled_rules:
  - comment_spacing
  - file_length
  - function_body_length
  - function_parameter_count
  - identifier_name
  - large_tuple
  - line_length
  - multiple_closures_with_trailing_closure
  - nesting
  - statement_position
  - todo
  - trailing_comma
  - trailing_newline
  - type_body_length
  - type_name
  - unused_closure_parameter
  - unused_optional_binding
  - xctfail_message

opt_in_rules:
  - array_init
  - closure_end_indentation
  - closure_spacing
  - collection_alignment
  - contains_over_filter_count
  - contains_over_filter_is_empty
  - contains_over_first_not_nil
  - contains_over_range_nil_comparison
  - convenience_type
  - empty_collection_literal
  - empty_count
  - empty_string
  - first_where
  - identical_operands
  - last_where
  - legacy_random
  - literal_expression_end_indentation
  - operator_usage_whitespace
  - overridden_super_call
  - prefer_self_type_over_type_of_self
  - prefer_zero_over_explicit_init
  - prohibited_super_call
  - redundant_nil_coalescing
  - redundant_type_annotation
  - sorted_first_last
  - toggle_bool
  - unowned_variable_capture
  - untyped_error_in_catch
  - unused_declaration
  - unused_import

empty_count:
  severity: warning
force_cast: warning
force_try: warning
shorthand_operator: warning
cyclomatic_complexity: 50
trailing_whitespace:
  ignores_empty_lines: true

custom_rules:
  non_localized_string:
    regex: '(?<!NSLocalizedString\(|fatalError\(|assertionFailure\(|preconditionFailure\(|assert\(false, |format: |separator: |deprecated, message: |level: \.debug, |level: \.info, |level: \.warning, |level: \.error, |\.debug\(|\.info\(|\.warn\(|\.error\(|logError\(|\(category: |\w|\")(?:"[^" \n]+ [^"\n]*"|"[[:upper:]][[:lower:]]+"|""".*?""")'
    message: "Use LocalizedStrings or add `// TODO: Localize` above"
    match_kinds: string
    excluded: '.*Tests/|.*/Resources/|.*/Scripts/|LocalizedStrings.swift'
  localization_mark:
    regex: '(?:MARK|TODO): *-? *(?:Needs?[- ])?(?:Translate|Translation|Locali[sz]e|Locali[sz]ation)(?:[- ]Needed)?'
    message: 'Missing localized string. Build locally to add it.'
    match_kinds: comment
    excluded: '.*Tests/|.*/Resources/|.*/Scripts/'
    severity: error
  missing_doc_comment:
    regex: '^([^\n]{0,5}|([^\/\n]|[^\n]{1,2}[^\/])[^\n]*)\n[^\n]*class\s+\w+FlowCoordinator'
    message: "Explain what the coordinator below does using a doc comment `/// Description`"
    excluded: '.*Tests/|.*/Resources/|.*/Scripts/'
417-72KI commented 2 years ago

Don't you have any updates other than Package.swift the PR?

Adding allow_zero_lintable_files: true to .swiftlint.yml may help you.

ghost commented 2 years ago

Perfect, thanks!