peripheryapp / periphery

A tool to identify unused code in Swift projects.
MIT License
5.2k stars 186 forks source link

Scan raises an error in line 55 but file has only 38 lines #812

Open sergiocaserowl opened 3 weeks ago

sergiocaserowl commented 3 weeks ago

Hello!

I'm facing this issue with periphery, basically, in the analysis I see:

{
  "modifiers": [],
  "attributes": [],
  "accessibility": "internal",
  "ids": [
    "s:1118NavigationColorBarV"
  ],
  "name": "NavigationColorBar",
  "hints": [
    "unused"
  ],
  "location": "*****/utils/ViewModifiers.swift:55:8",
  "modules": [
    "******"
  ],
  "kind": "struct"
}

But... this is the file:

//
//  ViewModifiers.swift
// 
//
//  Created by **** on 27/10/22.
//

import SwiftUI

#if canImport(UIKit)
extension View {
    func hideKeyboard() {
        UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
    }
}
#endif

extension View {
    func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View {
        clipShape( RoundedCorner(radius: radius, corners: corners) )
    }
}

struct RoundedCorner: Shape {

    var radius: CGFloat = .infinity
    var corners: UIRectCorner = .allCorners

    func path(in rect: CGRect) -> Path {
        let path = UIBezierPath(
            roundedRect: rect,
            byRoundingCorners: corners,
            cornerRadii: CGSize(width: radius, height: radius)
        )
        return Path(path.cgPath)
    }
}
ileitch commented 2 weeks ago

Is this issue consistently reproduced? Does --clean-build fix it? Which file declares NavigationColorBar?