Skip to content

Commit

Permalink
Only print report:exclude debug statement for files with unused decla…
Browse files Browse the repository at this point in the history
…rations. (#382)
  • Loading branch information
ileitch authored Jul 23, 2021
1 parent bb67c0f commit 699ffa4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
18 changes: 14 additions & 4 deletions Sources/Frontend/Formatters/OutputDeclarationFilter.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import SystemPackage
import Shared
import PeripheryKit

Expand All @@ -18,12 +19,21 @@ final class OutputDeclarationFilter: Injectable {
func filter(_ declarations: [ScanResult]) -> [ScanResult] {
let excludedSourceFiles = configuration.reportExcludeSourceFiles

excludedSourceFiles.forEach {
logger.debug("[report:exclude] \($0.string)")
}
var reportedExclusions: Set<FilePath> = []

return declarations.filter {
!excludedSourceFiles.contains($0.declaration.location.file.path)
let path = $0.declaration.location.file.path

if excludedSourceFiles.contains(path) {
if !reportedExclusions.contains(path) {
self.logger.debug("[report:exclude] \(path)")
reportedExclusions.insert(path)
}

return false
}

return true
}
}
}
8 changes: 4 additions & 4 deletions Sources/Shared/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ public final class Configuration: Singleton {
}
}

public var indexExcludeSourceFiles: Set<FilePath> {
public lazy var indexExcludeSourceFiles: Set<FilePath> = {
Set(indexExclude.flatMap { FilePath.glob($0) })
}
}()

public var reportExcludeSourceFiles: Set<FilePath> {
public lazy var reportExcludeSourceFiles: Set<FilePath> = {
Set(reportExclude.flatMap { FilePath.glob($0) })
}
}()

// MARK: - Private

Expand Down

0 comments on commit 699ffa4

Please sign in to comment.