Swiftpack.co - Package - kenmaz/StrongSelfRewriter

StrongSelfRewriter

StrongSelfRewriter is the tool to replace variable name for guard let self = self optional binding code using SwiftSyntax

Usage

StrongSelfRewriter Sample.swift

Result

     func execute(completion: () -> Void) {
         DispatchQueue.main.async { [weak self] in
-            guard let strongSelf = self else {
+            guard let self = self else {
                 return
             }
-            strongSelf.output(text: "hello")
-            print(strongSelf)
+            self.output(text: "hello")
+            print(self)
         }
     }

Options

$ StrongSelfRewriter 
OVERVIEW: Replace optional self binding variable name to "self" or specified name by --rewrite option

USAGE: StrongSelfRewriter <path>

OPTIONS:
  --dryrun, -d   Display rewrited code simply
  --dump         Dump syntax tree
  --rewrite      Variable name for replacement. Default is self
  --help         Display available options

POSITIONAL ARGUMENTS:
  path           Path to .swift file

Build

git clone <repo>
cd <repo>
swift build

Debug run

.build/debug/StrongSelfRewriter rewrite Tests/StrongSelfRewriterTests/Sample.swift 

Generate Xcode project

swift package generate-xcodeproj

Release build

swift build -c release

Thanks

Github

link
Stars: 11
Help us keep the lights on

Used By

Total: 0

Releases

v0.0.1 - Mar 24, 2019

First release