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

Binary operator '+=' cannot be applied to two 'CMTime' operands vs shorthand_operator #3643

Closed
2 tasks done
Bersaelor opened this issue May 25, 2021 · 2 comments
Closed
2 tasks done
Labels
acceptable-false-positive False positives caused by rules that are unavoidable due to missing type information.

Comments

@Bersaelor
Copy link

Bersaelor commented May 25, 2021

New Issue Checklist

Describe the bug

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
error: Shorthand Operator Violation: Prefer shorthand operators (+=, -=, *=, /=) over doing the operation and assigning. (shorthand_operator)

Environment

  • SwiftLint version (run swiftlint version to be sure)?
    0.43.1
  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
    package from GitHub
  • Paste your configuration file:
// This triggers a violation:
        var cumulativeTime = CMTime.zero
        while cumulativeTime + currentSegment.playbackDuration < compositionTime {
            cumulativeTime = cumulativeTime + currentSegment.playbackDuration
        }

Binary operator '+=' cannot be applied to two 'CMTime' operands.

Is there a way of disabling this rule for CMTime structs and similar cases of overloaded + ?

@Bersaelor Bersaelor changed the title Binary operator '+=' cannot be applied to two 'CMTime' operands Binary operator '+=' cannot be applied to two 'CMTime' operands vs shorthand_operator May 25, 2021
@SimplyDanny SimplyDanny added the bug Unexpected and reproducible misbehavior. label Mar 27, 2022
@SimplyDanny
Copy link
Collaborator

There is no way for the rule to know the types of the operands. Only the special Analyzer rules know. Thus, this is a false-positive we have to accept or disable in the code.

@SimplyDanny SimplyDanny added acceptable-false-positive False positives caused by rules that are unavoidable due to missing type information. and removed bug Unexpected and reproducible misbehavior. labels May 1, 2023
@SimplyDanny SimplyDanny closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2023
@SimplyDanny
Copy link
Collaborator

See #4953.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acceptable-false-positive False positives caused by rules that are unavoidable due to missing type information.
Projects
None yet
Development

No branches or pull requests

2 participants