periphery icon indicating copy to clipboard operation
periphery copied to clipboard

Show warning if `// periphery:ignore` unneeded

Open subdan opened this issue 4 years ago • 7 comments

I want to see a warning if // periphery:ignore command is unneeded.

// periphery:ignore
func sayHello() {
    print("sayHello")
}
sayHello()

I want to see the following warning: Superfluous Ignore Command Violation: function sayHello is used and shouldn't marked as ignored. Please remove the ignore command.


SwiftLint shows a warning if a disable command doesn't needed.

// swiftlint:disable:next function_body_length
func sayHello() {
    print("Hello")
}

Warning: Superfluous Disable Command Violation: SwiftLint rule 'function_body_length' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)

subdan avatar Nov 18 '21 11:11 subdan

@subdan Are you working on this? I would be interested in adding this capability

maxwellE avatar Jun 02 '23 14:06 maxwellE

@maxwellE @geraldWilliam took a stab at this recently: https://github.com/peripheryapp/periphery/pull/551. It wasn't quite the right solution though. I've been wanting to take another look but haven't had time yet. I'll be focusing more on integrating Periphery into Reddit's build system soon, so hopefully I can allocate some time for this too.

ileitch avatar Jun 02 '23 14:06 ileitch

@subdan Are you working on this? I would be interested in adding this capability

No

subdan avatar Jun 03 '23 06:06 subdan

@ileitch was there any progress on this yet?

maxwellE avatar Aug 24 '23 14:08 maxwellE

@ileitch Id like to take this up if you have any pointers on how to best tackle this

tinder-maxwellelliott avatar Aug 31 '23 16:08 tinder-maxwellelliott

Hey @maxwellE, sorry for the slow reply. I haven't had time to think about the right solution for this. I think a naive approach is possibly quite simple, but finding one that doesn't significantly impact performance might be a bit harder. Please have a go!

ileitch avatar Sep 08 '23 14:09 ileitch

Would it make sense to have even a less performant version of this implemented behind a flag? I could dive into how SwiftLint accomplishes this same logic

maxwellE avatar Sep 12 '23 14:09 maxwellE