realm / realm/SwiftLint

SwiftLint > 0.59.1 throws ViolationSeverity error

Open
#6,433 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help repro-needed stale
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

New Issue Checklist
Bug Description

A clear and concise description of what the bug is. Ideally, provide a small (but compilable) example code snippet that can be used to reproduce the issue.

When I run swiftlint 0.63.0 (or any version above 0.59.1) via Bazel, e.g.

bazel test //plugins/beacon/swiftui:PlayerUIBeaconPluginSwiftLint

I see this error:

external/swiftlint+/Source/SwiftLintCore/Models/SeverityConfiguration.swift:19:14: error: cannot assign to property: 'severity' is a get-only property
17 |     /// - parameter severity: The severity that should be used when emitting violations.
18 |     public init(_ severity: ViolationSeverity) {
19 |         self.severity = severity
   |              `- error: cannot assign to property: 'severity' is a get-only property
20 |     }
21 | 

external/swiftlint+/Source/SwiftLintCore/Models/SeverityConfiguration.swift:27:22: error: cannot assign to property: 'severity' is a get-only property
25 |         if let severityString: String = configString ?? configDict?[$severity.key] as? String {
26 |             if let severity = ViolationSeverity(rawValue: severityString.lowercased()) {
27 |                 self.severity = severity
   |                      `- error: cannot assign to property: 'severity' is a get-only property
28 |             } else {
29 |                 throw .invalidConfiguration(ruleID: Parent.identifier)

external/swiftlint+/Source/SwiftLintCore/Models/ViolationSeverity.swift:3:13: error: type 'ViolationSeverity' does not conform to protocol 'AcceptableByConfigurationElement'
 1 | /// The magnitude of a `StyleViolation`.
 2 | @AcceptableByConfigurationElement
 3 | public enum ViolationSeverity: String, Comparable, CaseIterable, Codable, Sendable, InlinableOptionType {
   |             `- error: type 'ViolationSeverity' does not conform to protocol 'AcceptableByConfigurationElement'
 4 |     /// Non-fatal. If using SwiftLint as an Xcode build phase, Xcode will mark the build as having succeeded.
 5 |     case warning

I am specifically seeing this with the player-ui repo, in this PR migrating to Xcode 26+. The SwiftLint call is defined in a helper here:

    native.sh_test(
        name = name + "SwiftLint",
        srcs = [":" + name + "_Lint"],
        visibility = ["//visibility:public"],
    )

    # Runs the SwiftLint as part of the build, if lint fails with serious violations defer the results for the test
    native.genrule(
        name = name + "_Lint",
        tools = [
            "@SwiftLint//:swiftlint",
        ],
        srcs = [":" + name + "_Sources"] + ["//:.swiftlint.yml"],
        outs = ["output.sh"],
        executable = True,
        testonly = True,
        visibility = ["//visibility:public"],
        cmd = """
      echo `$(location @SwiftLint//:swiftlint) --config $(location //:.swiftlint.yml) $(SRCS) || true` > lint_results.txt
      LINT=$$(cat lint_results.txt)

      echo '#!/bin/bash' > $(location output.sh)
      echo "echo '$$LINT'" > $(location output.sh)

      LINESWITHERROR=$$(echo grep error lint_results.txt || true)
      echo "exit $$(($$LINESWITHERROR) | wc -l)" >> $(location output.sh)
  """,
    )
Environment
  • SwiftLint version (run swiftlint version to be sure): 0.63.0
  • Xcode version (run xcodebuild -version to be sure): 26.1 on MacOS 15.7.2
  • Installation method used (Homebrew, CocoaPods, building from source, etc): Bazel
  • Configuration file:
disabled_rules:
    - unused_optional_binding
    - unused_setter_value
type_name:
    excluded:
        - T
line_length:
    warning: 160
    ignores_comments: true
function_body_length: 50
identifier_name:
    excluded:
        - id
        - file_input
        - text_input
        - check_box
        - drop_down
        - radio_button
        - search_input
included:
    - ios
    - plugins

Are you using nested configurations? If so, paste their
relative paths and respective contents.
Not using.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with bazel test //plugins/beacon/swiftui:PlayerUIBeaconPluginSwiftLint and SwiftLint 0.63.0. Start with Source/SwiftLintCore/Models/SeverityConfiguration.swift and ViolationSeverity.swift, then inspect the Bazel invocation in common_utils.bzl. Done means SwiftLint builds and the reported Bazel test runs without the ViolationSeverity conformance and get-only-property errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.