https://github.com/kitasuke/swiftconst
Find in Swift repeated strings that could be replaced by a constant using SwiftSyntax
https://github.com/kitasuke/swiftconst
Last synced: 11 months ago
JSON representation
Find in Swift repeated strings that could be replaced by a constant using SwiftSyntax
- Host: GitHub
- URL: https://github.com/kitasuke/swiftconst
- Owner: kitasuke
- License: mit
- Created: 2019-03-21T15:37:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-26T09:47:08.000Z (over 6 years ago)
- Last Synced: 2025-05-30T18:07:32.869Z (about 1 year ago)
- Language: Swift
- Homepage:
- Size: 61.5 KB
- Stars: 37
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swiftconst
[](https://swift.org/download/)
[](https://app.bitrise.io/app/f45d3e8ffa077288)
[](https://codecov.io/gh/kitasuke/SwiftConst)
## Overview
Find in Swift repeated strings that could be replaced by a constant using [SwiftSyntax](https://github.com/apple/swift-syntax).
This is highly inspired by [goconst](https://github.com/jgautheron/goconst) and Swift version of it.
## Requirements
Swift 5.1+
Xcode 11.0+ beta
## How to use
### Installation
Run below command
```terminal
$ make install
$ swiftconst help
```
### Available Commands
#### `help`
Display general or command-specific help
#### `run --path --ignore `
Display repeated strings
## Examples
```terminal
$ swiftconst run --ignore "/Users/kitasuke/SwiftConst/Tests/,/Users/kitasuke/SwiftConst/Package.swift"
other occurrence(s) of "error" found in: /Users/kitasuke/SwiftConst/main.swift:7:11
other occurrence(s) of "help" found in: /Users/kitasuke/SwiftConst/main.swift:18:19
other occurrence(s) of "error" found in: /Users/kitasuke/SwiftConst/main.swift:19:28
other occurrence(s) of "help" found in: /Users/kitasuke/SwiftConst/main.swift:21:19
```
## TODOs
- [ ] Recursive run in subfolders
## Acknowledgements
- [goconst](https://github.com/jgautheron/goconst)
- [SwiftRewriter](https://github.com/inamiy/SwiftRewriter)
- [swift-ast-explorer-playground](https://github.com/kishikawakatsumi/swift-ast-explorer-playground)