periphery icon indicating copy to clipboard operation
periphery copied to clipboard

Exclude the existential protocol warning

Open nrajput05 opened this issue 3 years ago • 4 comments

My app uses a lot of protocols to create empty function declarations so that they can be used across the app to enforce same rules. For example I have a protocol for localisation having one of the methods as func handleLocalisation().

Now every view controller of my app which supports localisation adopts this and is forced to implement this so all the localisation code is consistently being used with same method throughout the app.

For this sole reason, I would like to exclude this warning from the periphery scan as I would like to add this to my CI/CD process where any periphery warning would lead to a failure report.

I did find a way (periphery scan --index-exclude myApp/Protocols/*) through docs where I can exclude the whole protocol folder in my app, so none of the protocols are scanned but I would like to ignore this rule altogether in the periphery.yml file.

nrajput05 avatar Jul 04 '22 13:07 nrajput05

Hi, any answers for the above please?

If I try to put // periphery:ignore on every protocol then my code documentation suffers alot. You can imagine that if I have put documentation on every protocol which is not used as existential type, then the quick description that I have added on every protocol then the quick description is not visible.

///My protocol which is not used as an existential type. // periphery:ignore protocol foo { }

nrajput05 avatar Jul 18 '22 13:07 nrajput05

@nrajput05 I'm not a maintainer here or anything, but I did notice that if you put // periphery:ignore above your SwiftDoc, then you can still see your doc in the quick description and Periphery still picks up the "ignore" message.

blindmonkey avatar Jul 29 '22 14:07 blindmonkey

@nrajput05 I'm not a maintainer here or anything, but I did notice that if you put // periphery:ignore above your SwiftDoc, then you can still see your doc in the quick description and Periphery still picks up the "ignore" message.

@blindmonkey yes but in that case the whole file is ignored and there could be some unused code present which I don't want to ignore while scanning. I just wanted to ignore this rule itself as a whole.

nrajput05 avatar Aug 01 '22 11:08 nrajput05

I don't believe this is the case. AFAIK, // periphery:ignore will just ignore the thing you attach it to. The documentation appears to back this up. I think you might be confusing it with // periphery:ignore:all.

All I'm suggesting is that you take the code you posted before and put the periphery comment above your docs:

// periphery:ignore
///My protocol which is not used as an existential type.
protocol foo {
}

blindmonkey avatar Aug 02 '22 17:08 blindmonkey

@nrajput05 You could add a new option to disable this, or alternatively parse the results to automatically exclude the results you don't want. Please open a PR if you've willing to add the new option.

ileitch avatar Sep 29 '22 04:09 ileitch