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

unused-parameter rule should not trigger on override functions #5743

Closed
2 tasks done
sindresorhus opened this issue Aug 8, 2024 · 2 comments
Closed
2 tasks done

unused-parameter rule should not trigger on override functions #5743

sindresorhus opened this issue Aug 8, 2024 · 2 comments
Labels
discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions.

Comments

@sindresorhus
Copy link

sindresorhus commented Aug 8, 2024

New Issue Checklist

Bug Description

override function have to perfectly match the superclass, so you cannot change or remove the parameter then.

Example:

final class Foo: NSView {
	override func acceptsFirstMouse(for event: NSEvent?) -> Bool { true }
}

Same applies to protocol conformances, but I don't think it's possible to catch such cases unless the rule becomes an analyzer rule.

Environment

  • SwiftLint version: 0.56.0
  • Xcode version: Xcode 15.4, Build version 15F31d
  • Installation method used: Installer
  • Configuration file:
only_rules:
  - unused_parameter
@SimplyDanny
Copy link
Collaborator

What the rule suggests in this case is

final class Foo: NSView {
	override func acceptsFirstMouse(for _: NSEvent?) -> Bool { true }
}

which is even valid for override functions.

@SimplyDanny SimplyDanny added the discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions. label Aug 10, 2024
@sindresorhus
Copy link
Author

That's not optimal, but I guess this can be closed in favor of:

final class Foo: NSView {
	override func acceptsFirstMouse(for _event: NSEvent?) -> Bool { true }
}

#5741 (comment)

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions.
Projects
None yet
Development

No branches or pull requests

2 participants