periphery icon indicating copy to clipboard operation
periphery copied to clipboard

Create a Baseline

Open aiKrice opened this issue 2 years ago • 1 comments

It would be nice to create a baseline feature when legacy warnings are too numbered.

aiKrice avatar Jan 28 '24 19:01 aiKrice

I was just about to request something like this also, we are integrating periphery into a codebase with thousands of LOC and it's not feasible to fix the warnings without having a baseline ignore. You might be able to make use of a short ruby script to perform an automated insert of baseline ignores.

Does not handle parameters, and doesn't do indentation correctly

# takes as input lines of warnings from periphery formatted for Xcode
# exclude parameter based warnings (cannot be handled)
File.open('warnings.txt').grep_v(/Parameter/).sort.reverse.each do |line|
  # extract location
  file=line[/(.*?):(.*?):(.*?)/, 1]
  line_num=line[/(.*?):(.*?):(.*?)/, 2]
  # insert a baseline ignore on the line above
  `sed -i '' '#{line_num}s/^/    \\/\\/ periphery:ignore - baseline ignores\\n/' "#{file}"`
end

amleszk avatar Feb 14 '24 14:02 amleszk

I have been working on a very similar feature for SwiftLint, which is not in a shipping version yet, but has been merged to main - you can see more details here: https://github.com/realm/SwiftLint/pull/5475

I have an implementation of this feature for Periphery as well, that I'm just working out a few kinks on.

mildm8nnered avatar May 11 '24 16:05 mildm8nnered

Implemented in https://github.com/peripheryapp/periphery/commit/e676e1abbfadbfea4b2206a5f8e3a3f7007543e3

ileitch avatar Jun 09 '24 09:06 ileitch