Created
October 24, 2022 12:22
-
-
Save byaruhaf/f8d5c4f9f8ba6b90c14c35ad3ed0c876 to your computer and use it in GitHub Desktop.
Ruby script to find DeadCode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby | |
| puts "start dead code analysis" | |
| result = `periphery scan` | |
| result_stripped_of_absolute_path_prefix = result.gsub(Dir.pwd, '') | |
| filtered_out_result = result_stripped_of_absolute_path_prefix.split("\n").filter { |line| /:\d+:\d+:/.match?(line) } | |
| sorted_result = filtered_out_result.sort | |
| result_with_removed_code_line_number = sorted_result.map {|l| l.sub(/:\d+:\d+:/, '') } | |
| output = result_with_removed_code_line_number.join("\n") + "\n" | |
| File.write('periphery_output', output) | |
| puts "done with dead code analysis" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment