twostraws / sitrep Goto Github PK
View Code? Open in Web Editor NEWA source code analyzer for Swift projects.
Home Page: https://www.hackingwithswift.com/
License: Apache License 2.0
A source code analyzer for Swift projects.
Home Page: https://www.hackingwithswift.com/
License: Apache License 2.0
I'm getting the following error when attempting to add Sitrep to my Package.swift:
product 'Sitrep' not found. It is required by target 'App'.
This is my Package.swift
:
// swift-tools-version:5.2
import PackageDescription
let package = Package(
name: "PSVaporV4",
platforms: [
.macOS(.v10_15)
],
dependencies: [
// ๐ง A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0-rc"),
...
.package(url: "https://github.com/twostraws/Sitrep", .branch("master"))
],
targets: [
.target(name: "App", dependencies: [
...
.product(name: "Sitrep", package: "Sitrep")
]),
],
swiftLanguageVersions: [.v5]
)
I've had some other issues migrating to packages using swift-tools-version:5.2. Is there something I'm doing wrong here or do I need to make a change to accommodate this swift-tools-version?
Edit: I know the package says it supports Swift 5.1, so if this just isn't supported in 5.2 that's totally fine.
Thanks!
Hey @twostraws ๐
An awesome little tool that you've created here! I wonder if you'd be interesting in enabling SitrepCore as a product?
It would allow other people's tools to build on top of the great stuff you've built as part of their own projects. Of course, you have the JSON output which could be used with ShellOut and some Codable stuff but this a lot more to manage (and introduces more routes for problems) versus using the library directly.
In theory it would just be a case of adding the product to the Package.swift and making a couple extra things public!
Hey Paul,
Similar to #39, I'm curious on your take of how easy it would be to modify SitRep to allow the caller to specify a flag to output a report per target, per extension, etc.
For example, 'I have an app with an app, app clip, widget extension, live activity widget extension' and so on. The idea here would be to see at a glance where the majority of the code is from a target level. Potentially some interesting analysis to 'refactor shared code into swift package'.
MacBook Pro M1, 32GB RAM, 16-inch, 2021
OS: 13.2.1 (22D68)
xCode: 14.2 (14C18)
Installed via Homebrew
I am getting following error in terminal.
dyld[66107]: Library not loaded: @rpath/lib_InternalSwiftSyntaxParser.dylib
Referenced from: <5060E796-F2F6-3624-8F9E-12E768636538> /opt/homebrew/Cellar/sitrep/2.1.0/bin/sitrep
Reason: tried: '/usr/lib/swift/lib_InternalSwiftSyntaxParser.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/opt/homebrew/Cellar/sitrep/2.1.0/bin/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/usr/lib/swift/lib_InternalSwiftSyntaxParser.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/opt/homebrew/Cellar/sitrep/2.1.0/bin/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS@rpath/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/usr/lib/swift/lib_InternalSwiftSyntaxParser.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/opt/homebrew/Cellar/sitrep/2.1.0/bin/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/usr/lib/swift/lib_InternalSwiftSyntaxParser.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/opt/homebrew/Cellar/sitrep/2.1.0/bin/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/usr/local/lib/lib_InternalSwiftSyntaxParser.dylib' (no such file), '/usr/lib/lib_InternalSwiftSyntaxParser.dylib' (no such file, not in dyld cache)
zsh: abort sitrep
~/Library/org.swift.swiftpm/collections.json has been deprecated. Please delete it and use the new ~/Library/org.swift.swiftpm/configuration/collections.json instead.
error: Could not find Package.swift in this directory or any of its parent directories.
Followed the steps to setup and install and got the error above.
Fingers crossed that changing the json fixes my issues. Just posting so folks are aware of changes in Xcode.
Hey @twostraws ! ๐๐ผ
Based on the screenshot here: https://twitter.com/twostraws/status/1354136797496881154/photo/1
I was wondering why imports are word-wrapped instead of formatted like everything else?
I think a format like this would be easier to read:
Imports
UIKit: 8
Foundation: 63
AppKit: 17
Structure:
UIKit View Controllers: 17
UIKit Views: 23
SwiftUI View: 0
(Also, separating "imports" into its own section seems helpful)
The tool doesn't report failures.
Hey guys,
So the title says it all, any plans?
When I attempted to install via brew on Big Sur 11.6 with Xcode 13.0 installed sitrep fails to build:
~ brew install twostraws/brew/sitrep
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 1 formula.
==> Downloading https://github.com/twostraws/Sitrep/archive/2.0.0.zip
Already downloaded: /Users/oliver/Library/Caches/Homebrew/downloads/d4eb3eace3c707e956021a5f09274a6488a1a45867c75fa7ab40206312e8a965--Sitrep-2.0.0.zip
==> Installing sitrep from twostraws/brew
Warning: Building now โ this might take a few minutes.
==> swift build --configuration release --disable-sandbox
Last 15 lines from /Users/oliver/Library/Logs/Homebrew/sitrep/01.swift:
let startOffset = Int(cnode.range.offset)
~~~~~ ^~~~~
/private/tmp/sitrep-20210922-63336-1tl3wq4/Sitrep-2.0.0/.build/checkouts/swift-syntax/Sources/SwiftSyntax/RawSyntax.swift:157:55: error: value of type 'CSyntaxNode' (aka 'swiftparse_syntax_node_t') has no member 'range'
let end = utf8.index(begin, offsetBy: Int(cnode.range.length))
~~~~~ ^~~~~
/private/tmp/sitrep-20210922-63336-1tl3wq4/Sitrep-2.0.0/.build/checkouts/swift-syntax/Sources/SwiftSyntax/RawSyntax.swift:873:32: error: value of type 'CSyntaxNode' (aka 'swiftparse_syntax_node_t') has no member 'range'
let byteLength = Int(cnode.range.length)
~~~~~ ^~~~~
/private/tmp/sitrep-20210922-63336-1tl3wq4/Sitrep-2.0.0/.build/checkouts/swift-syntax/Sources/SwiftSyntax/SyntaxParser.swift:195:57: error: missing argument for parameter #3 in call
let c_top = swiftparse_parse_string(c_parser, source)
^
, <#Int#>
_InternalSwiftSyntaxParser.swiftparse_parse_string:1:13: note: 'swiftparse_parse_string' declared here
public func swiftparse_parse_string(_: swiftparse_parser_t!, _ source: UnsafePointer<CChar>!, _ len: Int) -> swiftparse_client_node_t!
^
We should assume sensible defaults instead.
After install it by Homebrew.
I got this error fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: no files specified
when try to use it.
When i run sitrep
.
Hello,
I tried to execute the Sitrep command under the Cocoapods Classes directory. But I got an empty result.
swift run Sitrep -p ~/Users/duruldalkanat/ios_snapshot_testing/Source/VHFeature-iOS/VHFeature-iOS/Classes
Distro: OS X 12.6
Xcode 13.4.1
Build version 13F100
Overview
Files scanned: 0
Structs: 0
Classes: 0
Enums: 0
Protocols: 0
Extensions: 0
Sizes
Total lines of code: 1
Source lines of code: 1
Structure
Imports:
UIKit View Controllers: 0
UIKit Views: 0
SwiftUI Views: 0
Scanning my current branch of Alamofire, Sitrep gives these LOC results:
Sizes
Total lines of code: 11102
Source lines of code: 9481
However, cloc gives these results:
Language files blank comment code
-------------------------------------------------------------------------------
Swift 32 1606 3598 5897
Perhaps Sitrep could use a similar break down?
Typealiasing a class (e.g. typealias UIVC = UIViewController
) and inheriting from this typealias (e.g. class SomeClass: UIVC { ... }
) doesn't count inheritance from the original class (UIViewController
in this case).
It's a command-line program, and should be naturally human readable.
Hi ๐ I really like the project, but I could not find out which options can be provided inside .sitrep.yml
file. I would love to see it documented with some examples in README.md
.
It'd be nice if this tool could be run at different verbosity levels
Installing via Mint now fails since it's expecting to clone "master" but now there is no such branch but "main" instead.
You can install if you specify the branch e.g:
mint install twostraws/Sitrep@main
After installing via homebrew, then in a project directory that contains the .xcodeproj file running sitrep
this gives 0 files scanned.
Do I need to create the .yml file? Or do anything else?
I would like to make a Homebrew formula from Sitrep, but one of the requirements for all formulas in the main tap is that it should have a stable, tagged version. Is there any plans for releases?
Hey Paul,
As the good Swift developers we are, we strive to encapsulate reusable code into Swift Packages. Do you think that it would be easy to enhance SitRep to go inspecting Swift Package dependencies too and combine the results into a single report, maybe broken down by app / packages? My use case would be to only count lines of code that I've personally written.
I'm sure this could be done by just invoking SitRep on all of the local swift packages but that would require some addition and combining results from several runs.
Thoughts on the following?
How to reproduce:
Create empty directory named "Foobar"
Initialize swift package via $ swift package init
Change โฆ
struct Foobar {
var text = "Hello, World!"
}
โฆ to โฆ
struct Foobar {
var text = "Hello, World!"
// }
// extension Foobar {
func foo() -> Int {
var i: Int = 0
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
i += 1
return i
}
}
$ sitrep
Overview
Files scanned: 5
Structs: 1
Classes: 1
Enums: 0
Protocols: 0
Extensions: 0
Sizes
Total lines of code: 105
Source lines of code: 93
Longest file: Foobar.swift (45 source lines)
Longest type: Foobar (45 source lines)
Structure
Imports: XCTest (3), FoobarTests (1), Foobar (1), PackageDescription (1)
UIKit View Controllers: 0
UIKit Views: 0
SwiftUI Views: 0
// }
// extension Foobar {
$ sitrep
againOverview
Files scanned: 5
Structs: 1
Classes: 1
Enums: 0
Protocols: 0
--- Extensions: 0
+++ Extensions: 1
Sizes
Total lines of code: 105
Source lines of code: 93
Longest file: Foobar.swift (45 source lines)
--- Longest type: Foobar (45 source lines)
+++ Longest type: FoobarTests (11 source lines)
Structure
Imports: XCTest (3), FoobarTests (1), Foobar (1), PackageDescription (1)
UIKit View Controllers: 0
UIKit Views: 0
SwiftUI Views: 0
Foobar
is now suddenly not considered the longest type any more.This is wrong.
The contents of a type's extensions should be considered content of the type.
Hello!
make install
swift build -c release
Fetching https://github.com/apple/swift-syntax.git
Completed resolution in 11.75s
Cloning https://github.com/apple/swift-syntax.git
Resolving https://github.com/apple/swift-syntax.git at 0.50100.0
/Users/alur/Sitrep/.build/checkouts/swift-syntax/Sources/SwiftSyntax/AtomicCounter.swift:13:2: error: unknown attribute '_implementationOnly'
@_implementationOnly import _CSwiftSyntax
^
/Users/alur/Sitrep/.build/checkouts/swift-syntax/Sources/SwiftSyntax/SyntaxParser.swift:17:8: error: no such module '_InternalSwiftSyntaxParser'
import _InternalSwiftSyntaxParser
^
make: *** [install] Error 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.