twostraws / Sitrep
- понедельник, 10 февраля 2020 г. в 00:19:43
Swift
A source code analyzer for Swift projects.
Sitrep is source code analyzer for Swift projects, giving you a high-level overview of your code:
Behind the scenes, Sitrep captures a lot more information that could be utilized – how many functions you have, how many comments (regular and documentation), how large your enums are, and more. These aren’t currently reported, but could be in a future release. It’s also written as both a library and an executable, so it can be integrated elsewhere as needed.
Sitrep is built using Apple’s SwiftSyntax, which means it parses Swift code accurately and efficiently.
Sitrep can be used through the Swift Package Manager. You can add it as a dependency in your Package.swift file:
let package = Package(
//...
dependencies: [
.package(url: "https://github.com/twostraws/Sitrep", .branch("master"))
],
//...
)Then import SitrepCore wherever you’d like to use it.
To install the Sitrep command line tool, clone the repository and run make install:
git clone https://github.com/twostraws/Sitrep
cd Sitrep
make installFrom now on you can use the sitrep command to scan Swift projects.
Sitrep is written using Swift 5.1. You can either build and run the executable directly, or integrate the SitrepCore library into your own code.
To build Sitrep, clone this repository and open Terminal in the repository root directory. Then run:
swift build
swift run sitrep ~/path/to/your/project/root
If you would like to keep a copy of the sitrep executable around, find it in the .debug directory after running swift build.
To run Sitrep from the command line just provide it with the name of a project directory to parse – it will locate all Swift files recursively from there. Alternatively, just using sitrep by itself will scan the current directory.
Any help you can offer with this project is most welcome, and trust me: there are opportunities big and small, so that someone with only a small amount of Swift experience can help.
Some suggestions you might want to explore:
BodyStripper.Please ensure you write tests to accompany any code you contribute, and that SwiftLint returns no errors or warnings.
Sitrep was designed and built by Paul Hudson, and is copyright © Paul Hudson 2020. Sitrep is licensed under the Apache License v2.0 with Runtime Library Exception; for the full license please see the LICENSE file.
Sitrep is built on top of Apple’s SwiftSyntax library for parsing code, which is also available under the Apache License v2.0 with Runtime Library Exception.
Swift, the Swift logo, and Xcode are trademarks of Apple Inc., registered in the U.S. and other countries.
If you find Sitrep useful, you might find my website full of Swift tutorials equally useful: Hacking with Swift.