peripheryapp / periphery

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

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

Open sergiocaserowl opened 2 months ago

sergiocaserowl commented 2 months 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 months ago

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

sergiocaserowl commented 1 month ago

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

Hello! Sorry Github didn't notified me. If I run with --clean-build, I get the same output. I have to say I'm using periphery from sonar-apple plugin, which executes exactly this command: periphery scan --skip-build --format json --quiet