Initial dead code finding code
This commit is contained in:
parent
ff48dc3ea6
commit
5c0c39c0ae
4 changed files with 165 additions and 0 deletions
1
tests/config.nims
Normal file
1
tests/config.nims
Normal file
|
|
@ -0,0 +1 @@
|
|||
switch("path", "$projectDir/../src")
|
||||
33
tests/testmort.nim
Normal file
33
tests/testmort.nim
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import strutils
|
||||
|
||||
import mort
|
||||
|
||||
proc mysnakeToCamel(s: cstring): string {.findDeadCode.} =
|
||||
var i, j: int
|
||||
result = newString(s.len)
|
||||
if s[i] == '_': inc(i)
|
||||
while true:
|
||||
if s[i] == '_' and (s[i + 1] == '\0' or s[i + 1] == '_'):
|
||||
inc(i)
|
||||
elif (s[i] == '_' or s[i] == '-') and s[i + 1].isLowerAscii and not s[i - 1].isUpperAscii:
|
||||
inc(i)
|
||||
result[j] = toUpperAscii(s[i])
|
||||
inc(i)
|
||||
inc(j)
|
||||
else:
|
||||
result[j] = s[i]
|
||||
inc(i)
|
||||
inc(j)
|
||||
if s[i] == '\0':
|
||||
result.setLen(j)
|
||||
break
|
||||
if result[0] == '\0': # this may result, so we emit a dummy name as marker
|
||||
result = "QQQ"
|
||||
|
||||
proc main() =
|
||||
discard mySnakeToCamel("diff_is_good")
|
||||
discard mySnakeToCamel("_diff_is_good")
|
||||
printCodeUsage()
|
||||
printDeadLines()
|
||||
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue