Comment Commands
For whatever reason, you may want to keep some unused code. Source code comment commands can be used to ignore specific declarations and exclude them from the results.
Ignoring Declarations
Section titled “Ignoring Declarations”An ignore comment command can be placed directly on the line above any declaration to ignore it and all descendent declarations:
// periphery:ignoreclass MyClass {}You can also ignore specific unused function parameters:
// periphery:ignore:parameters unusedOne,unusedTwofunc someFunc(used: String, unusedOne: String, unusedTwo: String) { print(used)}The // periphery:ignore:all command can be placed at the top of the source file to ignore the entire contents of the file. Note that the comment must be placed above any code, including import statements.
Comment commands also support trailing comments following a hyphen so that you can include an explanation on the same line:
// periphery:ignore - explanation of why this is necessaryclass MyClass {}Superfluous Ignore Comments
Section titled “Superfluous Ignore Comments”Ignore comments outlive the code they were added for. Once the declaration beneath an ignore comment is used again, or the unused parameter it named is removed, the comment no longer suppresses anything and is just misleading.
Periphery reports these as superfluous ignore comments by default, so you can remove them. Disable this with --no-superfluous-ignore-comments.
Overriding Result Details
Section titled “Overriding Result Details”In generated code scenarios where the generated code is too low-level or obtuse to be directly reported as unused, you can override the name, kind, and/or location of a result to provide a more meaningful report:
// periphery:override name="MyCustomName" kind="MyCustomThing" location="path/to/file.swift:42:1"func generatedFunction() {}The name and kind overrides allow you to specify custom values that will be shown in the result. The location override uses the format file:line:column (line and column default to 1 if omitted). This is particularly useful when you want to report results at a higher-level definition rather than at the low-level generated code. The location file path is assumed to be relative to the project root if a relative path is given.