Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight unused code in Pull Requests as a warning #372

Closed
wants to merge 16 commits into from
26 changes: 26 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,32 @@ jobs:
./Derived/*
key: ${{ github.run_id }}-dependencies

unused:
name: Periphery
runs-on: macos-latest
needs: [tuist-generation, changes]
steps:
- uses: actions/checkout@v3
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Retrieve Build Cache
uses: actions/cache@v3
with:
path: |
./ApolloDev.xcodeproj
./ApolloDev.xcworkspace
./Derived/*
key: ${{ github.run_id }}-dependencies
fail-on-cache-miss: true
- name: Install Periphery
run: |
brew install peripheryapp/periphery/periphery

- name: Run Periphery
run: |
ruby scripts/periphery.rb

run-swift-builds:
runs-on: macos-latest
timeout-minutes: 15
Expand Down
21 changes: 21 additions & 0 deletions .periphery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
retain_public: true
schemes:
- ApolloAPI
- ApolloCodegenLib
- ApolloPagination
- ApolloSQLite
- ApolloWebSocket
- ApolloWrapper
- CodegenCLI
- apollo-ios-cli
targets:
- Apollo.Apollo
- Apollo.ApolloAPI
- Apollo.ApolloSQLite
- Apollo.ApolloWebSocket
- ApolloCodegen.ApolloCodegenLib
- ApolloCodegen.CodegenCLI
- ApolloCodegenLibWrapper
- ApolloPagination.ApolloPagination
- ApolloWrapper
workspace: ApolloDev.xcworkspace
12 changes: 12 additions & 0 deletions scripts/periphery.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

output = `periphery scan --relative-results`
# This can be simplified in the future to `periphery scan --relative-results --format github-actions`
# https://github.com/peripheryapp/periphery/pull/746
title = 'Unused Code'
output
.split("\n").select { |line| line.include?('.swift') }
.map { |line| line.split(':', 5) }
.map { |parts| "::warning file=#{parts[0]},line=#{parts[1]},col=#{parts[2]},title=#{title}::#{parts[4].strip}" }
.each { |warning| puts warning }
Loading