Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use luacheck (linter) #7

Closed
jirutka opened this issue Nov 17, 2015 · 8 comments
Closed

Use luacheck (linter) #7

jirutka opened this issue Nov 17, 2015 · 8 comments

Comments

@jirutka
Copy link
Contributor

jirutka commented Nov 17, 2015

Luacheck is very useful to prevent some mistakes.

$ luacheck lockbox/
Checking lockbox//cipher/aes128.lua               11 warnings

    lockbox//cipher/aes128.lua:1:7: unused variable Stream
    lockbox//cipher/aes128.lua:5:7: unused variable Math
    lockbox//cipher/aes128.lua:8:7: unused variable AND
    lockbox//cipher/aes128.lua:9:7: unused variable OR
    lockbox//cipher/aes128.lua:10:7: unused variable NOT
    lockbox//cipher/aes128.lua:12:7: unused variable LROT
    lockbox//cipher/aes128.lua:13:7: unused variable RROT
    lockbox//cipher/aes128.lua:14:7: unused variable LSHIFT
    lockbox//cipher/aes128.lua:15:7: unused variable RSHIFT
    lockbox//cipher/aes128.lua:289:8: variable key was previously defined as an argument on line 287
    lockbox//cipher/aes128.lua:359:8: variable key was previously defined as an argument on line 357

Checking lockbox//cipher/aes192.lua               11 warnings

    lockbox//cipher/aes192.lua:1:7: unused variable Stream
    lockbox//cipher/aes192.lua:5:7: unused variable Math
    lockbox//cipher/aes192.lua:8:7: unused variable AND
    lockbox//cipher/aes192.lua:9:7: unused variable OR
    lockbox//cipher/aes192.lua:10:7: unused variable NOT
    lockbox//cipher/aes192.lua:12:7: unused variable LROT
    lockbox//cipher/aes192.lua:13:7: unused variable RROT
    lockbox//cipher/aes192.lua:14:7: unused variable LSHIFT
    lockbox//cipher/aes192.lua:15:7: unused variable RSHIFT
    lockbox//cipher/aes192.lua:311:8: variable key was previously defined as an argument on line 309
    lockbox//cipher/aes192.lua:393:8: variable key was previously defined as an argument on line 391

Checking lockbox//cipher/aes256.lua               11 warnings

    lockbox//cipher/aes256.lua:1:7: unused variable Stream
    lockbox//cipher/aes256.lua:5:7: unused variable Math
    lockbox//cipher/aes256.lua:8:7: unused variable AND
    lockbox//cipher/aes256.lua:9:7: unused variable OR
    lockbox//cipher/aes256.lua:10:7: unused variable NOT
    lockbox//cipher/aes256.lua:12:7: unused variable LROT
    lockbox//cipher/aes256.lua:13:7: unused variable RROT
    lockbox//cipher/aes256.lua:14:7: unused variable LSHIFT
    lockbox//cipher/aes256.lua:15:7: unused variable RSHIFT
    lockbox//cipher/aes256.lua:324:8: variable key was previously defined as an argument on line 322
    lockbox//cipher/aes256.lua:418:8: variable key was previously defined as an argument on line 416

Checking lockbox//cipher/des.lua                  47 warnings

    lockbox//cipher/des.lua:3:7: unused variable Stream
    lockbox//cipher/des.lua:12:7: unused variable NOT
    lockbox//cipher/des.lua:14:7: unused variable LROT
    lockbox//cipher/des.lua:15:7: unused variable RROT
    lockbox//cipher/des.lua:80:7: unused variable SIND1
    lockbox//cipher/des.lua:81:7: unused variable SIND2
    lockbox//cipher/des.lua:82:7: unused variable SIND3
    lockbox//cipher/des.lua:83:7: unused variable SIND4
    lockbox//cipher/des.lua:84:7: unused variable SIND5
    lockbox//cipher/des.lua:85:7: unused variable SIND6
    lockbox//cipher/des.lua:86:7: unused variable SIND7
    lockbox//cipher/des.lua:87:7: unused variable SIND8
    lockbox//cipher/des.lua:137:6: unused loop variable k
    lockbox//cipher/des.lua:154:8: unused loop variable v
    lockbox//cipher/des.lua:173:8: unused loop variable v
    lockbox//cipher/des.lua:338:8: unused loop variable v
    lockbox//cipher/des.lua:342:8: unused loop variable v
    lockbox//cipher/des.lua:346:8: unused loop variable v
    lockbox//cipher/des.lua:350:8: unused loop variable v
    lockbox//cipher/des.lua:354:8: unused loop variable v
    lockbox//cipher/des.lua:358:8: unused loop variable v
    lockbox//cipher/des.lua:362:8: unused loop variable v
    lockbox//cipher/des.lua:366:8: unused loop variable v
    lockbox//cipher/des.lua:370:8: unused loop variable v
    lockbox//cipher/des.lua:374:8: unused loop variable v
    lockbox//cipher/des.lua:378:8: unused loop variable v
    lockbox//cipher/des.lua:382:8: unused loop variable v
    lockbox//cipher/des.lua:386:8: unused loop variable v
    lockbox//cipher/des.lua:390:8: unused loop variable v
    lockbox//cipher/des.lua:394:8: unused loop variable v
    lockbox//cipher/des.lua:398:8: unused loop variable v
    lockbox//cipher/des.lua:440:8: unused loop variable v
    lockbox//cipher/des.lua:444:8: unused loop variable v
    lockbox//cipher/des.lua:448:8: unused loop variable v
    lockbox//cipher/des.lua:452:8: unused loop variable v
    lockbox//cipher/des.lua:456:8: unused loop variable v
    lockbox//cipher/des.lua:460:8: unused loop variable v
    lockbox//cipher/des.lua:464:8: unused loop variable v
    lockbox//cipher/des.lua:468:8: unused loop variable v
    lockbox//cipher/des.lua:472:8: unused loop variable v
    lockbox//cipher/des.lua:476:8: unused loop variable v
    lockbox//cipher/des.lua:480:8: unused loop variable v
    lockbox//cipher/des.lua:484:8: unused loop variable v
    lockbox//cipher/des.lua:488:8: unused loop variable v
    lockbox//cipher/des.lua:492:8: unused loop variable v
    lockbox//cipher/des.lua:496:8: unused loop variable v
    lockbox//cipher/des.lua:500:8: unused loop variable v

Checking lockbox//cipher/des3.lua                 OK
Checking lockbox//cipher/mode/cbc.lua             6 warnings

    lockbox//cipher/mode/cbc.lua:5:7: unused variable String
    lockbox//cipher/mode/cbc.lua:6:7: unused variable Bit
    lockbox//cipher/mode/cbc.lua:65:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/cbc.lua:66:17: accessing undefined variable paddingStream
    lockbox//cipher/mode/cbc.lua:144:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/cbc.lua:145:17: accessing undefined variable paddingStream

Checking lockbox//cipher/mode/cfb.lua             6 warnings

    lockbox//cipher/mode/cfb.lua:5:7: unused variable String
    lockbox//cipher/mode/cfb.lua:6:7: unused variable Bit
    lockbox//cipher/mode/cfb.lua:66:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/cfb.lua:67:17: accessing undefined variable paddingStream
    lockbox//cipher/mode/cfb.lua:144:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/cfb.lua:145:17: accessing undefined variable paddingStream

Checking lockbox//cipher/mode/ctr.lua             11 warnings

    lockbox//cipher/mode/ctr.lua:5:7: unused variable String
    lockbox//cipher/mode/ctr.lua:10:7: unused variable NOT
    lockbox//cipher/mode/ctr.lua:11:7: unused variable XOR
    lockbox//cipher/mode/ctr.lua:12:7: unused variable LROT
    lockbox//cipher/mode/ctr.lua:13:7: unused variable RROT
    lockbox//cipher/mode/ctr.lua:18:7: unused function bytes2word
    lockbox//cipher/mode/ctr.lua:26:7: unused function word2bytes
    lockbox//cipher/mode/ctr.lua:132:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/ctr.lua:133:17: accessing undefined variable paddingStream
    lockbox//cipher/mode/ctr.lua:249:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/ctr.lua:250:17: accessing undefined variable paddingStream

Checking lockbox//cipher/mode/ecb.lua             6 warnings

    lockbox//cipher/mode/ecb.lua:7:7: unused variable String
    lockbox//cipher/mode/ecb.lua:8:7: unused variable Bit
    lockbox//cipher/mode/ecb.lua:60:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/ecb.lua:61:17: accessing undefined variable paddingStream
    lockbox//cipher/mode/ecb.lua:130:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/ecb.lua:131:17: accessing undefined variable paddingStream

Checking lockbox//cipher/mode/ofb.lua             6 warnings

    lockbox//cipher/mode/ofb.lua:5:7: unused variable String
    lockbox//cipher/mode/ofb.lua:6:7: unused variable Bit
    lockbox//cipher/mode/ofb.lua:66:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/ofb.lua:67:17: accessing undefined variable paddingStream
    lockbox//cipher/mode/ofb.lua:144:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/ofb.lua:145:17: accessing undefined variable paddingStream

Checking lockbox//cipher/mode/pcbc.lua            6 warnings

    lockbox//cipher/mode/pcbc.lua:5:7: unused variable String
    lockbox//cipher/mode/pcbc.lua:6:7: unused variable Bit
    lockbox//cipher/mode/pcbc.lua:66:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/pcbc.lua:67:17: accessing undefined variable paddingStream
    lockbox//cipher/mode/pcbc.lua:144:3: setting non-standard global variable paddingStream
    lockbox//cipher/mode/pcbc.lua:145:17: accessing undefined variable paddingStream

Checking lockbox//cipher/tea.lua                  9 warnings

    lockbox//cipher/tea.lua:3:7: unused variable Stream
    lockbox//cipher/tea.lua:4:7: unused variable Array
    lockbox//cipher/tea.lua:6:7: unused variable String
    lockbox//cipher/tea.lua:8:7: unused variable Math
    lockbox//cipher/tea.lua:12:7: unused variable NOT
    lockbox//cipher/tea.lua:14:7: unused variable LROT
    lockbox//cipher/tea.lua:15:7: unused variable RROT
    lockbox//cipher/tea.lua:55:6: unused loop variable i
    lockbox//cipher/tea.lua:91:6: unused loop variable i

Checking lockbox//cipher/xtea.lua                 9 warnings

    lockbox//cipher/xtea.lua:3:7: unused variable Stream
    lockbox//cipher/xtea.lua:4:7: unused variable Array
    lockbox//cipher/xtea.lua:6:7: unused variable String
    lockbox//cipher/xtea.lua:8:7: unused variable Math
    lockbox//cipher/xtea.lua:12:7: unused variable NOT
    lockbox//cipher/xtea.lua:14:7: unused variable LROT
    lockbox//cipher/xtea.lua:15:7: unused variable RROT
    lockbox//cipher/xtea.lua:56:6: unused loop variable i
    lockbox//cipher/xtea.lua:91:6: unused loop variable i

Checking lockbox//digest/md2.lua                  8 warnings

    lockbox//digest/md2.lua:25:7: unused variable AND
    lockbox//digest/md2.lua:26:7: unused variable OR
    lockbox//digest/md2.lua:27:7: unused variable NOT
    lockbox//digest/md2.lua:29:7: unused variable LROT
    lockbox//digest/md2.lua:30:7: unused variable RROT
    lockbox//digest/md2.lua:31:7: unused variable LSHIFT
    lockbox//digest/md2.lua:32:7: unused variable RSHIFT
    lockbox//digest/md2.lua:43:8: variable L is never accessed

Checking lockbox//digest/md4.lua                  4 warnings

    lockbox//digest/md4.lua:8:7: unused variable SHIFT
    lockbox//digest/md4.lua:12:7: unused variable WORD
    lockbox//digest/md4.lua:21:7: unused variable RROT
    lockbox//digest/md4.lua:43:7: unused function bytes2dword

Checking lockbox//digest/md5.lua                  2 warnings

    lockbox//digest/md5.lua:35:7: unused variable RROT
    lockbox//digest/md5.lua:57:7: unused function bytes2dword

Checking lockbox//digest/ripemd128.lua            2 warnings

    lockbox//digest/ripemd128.lua:13:7: unused variable RROT
    lockbox//digest/ripemd128.lua:35:7: unused function bytes2dword

Checking lockbox//digest/ripemd160.lua            2 warnings

    lockbox//digest/ripemd160.lua:13:7: unused variable RROT
    lockbox//digest/ripemd160.lua:35:7: unused function bytes2dword

Checking lockbox//digest/sha1.lua                 2 warnings

    lockbox//digest/sha1.lua:13:7: unused variable RROT
    lockbox//digest/sha1.lua:35:7: unused function bytes2dword

Checking lockbox//digest/sha2_224.lua             2 warnings

    lockbox//digest/sha2_224.lua:20:7: unused variable LROT
    lockbox//digest/sha2_224.lua:43:7: unused function bytes2dword

Checking lockbox//digest/sha2_256.lua             2 warnings

    lockbox//digest/sha2_256.lua:20:7: unused variable LROT
    lockbox//digest/sha2_256.lua:43:7: unused function bytes2dword

Checking lockbox//init.lua                        OK
Checking lockbox//kdf/pbkdf2.lua                  7 warnings

    lockbox//kdf/pbkdf2.lua:2:7: unused variable String
    lockbox//kdf/pbkdf2.lua:9:7: unused variable NOT
    lockbox//kdf/pbkdf2.lua:10:7: unused variable XOR
    lockbox//kdf/pbkdf2.lua:11:7: unused variable LROT
    lockbox//kdf/pbkdf2.lua:12:7: unused variable RROT
    lockbox//kdf/pbkdf2.lua:34:7: unused function bytes2dword
    lockbox//kdf/pbkdf2.lua:40:7: unused function dword2bytes

Checking lockbox//mac/hmac.lua                    1 warning

    lockbox//mac/hmac.lua:2:7: unused variable String

Checking lockbox//padding/ansix923.lua            1 warning

    lockbox//padding/ansix923.lua:1:7: unused variable Stream

Checking lockbox//padding/isoiec7816.lua          1 warning

    lockbox//padding/isoiec7816.lua:1:7: unused variable Stream

Checking lockbox//padding/pkcs7.lua               1 warning

    lockbox//padding/pkcs7.lua:1:7: unused variable Stream

Checking lockbox//padding/zero.lua                1 warning

    lockbox//padding/zero.lua:1:7: unused variable Stream

Checking lockbox//util/array.lua                  3 warnings

    lockbox//util/array.lua:75:16: accessing undefined variable Queue
    lockbox//util/array.lua:140:8: variable i was previously defined on line 131
    lockbox//util/array.lua:141:8: variable byte was previously defined on line 132

Checking lockbox//util/base64.lua                 3 warnings

    lockbox//util/base64.lua:10:7: unused variable XOR
    lockbox//util/base64.lua:11:7: unused variable LROT
    lockbox//util/base64.lua:12:7: unused variable RROT

Checking lockbox//util/bit.lua                    1 warning

    lockbox//util/bit.lua:2:8: accessing uninitialized variable ok

Checking lockbox//util/queue.lua                  OK
Checking lockbox//util/stream.lua                 OK

Total: 182 warnings / 0 errors in 33 files
@somesocks
Copy link
Owner

👍 I'll check these out this week. Some of them, namely the unused imports and unused bit functions, are intentional. How would you suppress some of these warnings?

@tst2005
Copy link
Collaborator

tst2005 commented Nov 18, 2015

I think it's not easy to ignore.
But you should prefixe by '_' each unused variable names.
It becomes (humanly) easier to differenciate the already known cases between new cases.

@somesocks
Copy link
Owner

Perhaps its best to comment out unused variables then. I'd rather do that than leave them as warnings.

@tst2005
Copy link
Collaborator

tst2005 commented Nov 18, 2015

Yes, but in some cases you can't :

for _i, v in ipairs({}) do print(v) end

_i is unused but you can not remove it...

@jirutka
Copy link
Contributor Author

jirutka commented Nov 18, 2015

In this case:

for _i, v in ipairs({}) do print(v) end

it's common idiom to use _ as name of an unused yet required variable:

for _, v in ipairs({}) do print(v) end

@evkornev
Copy link
Collaborator

evkornev commented Jan 9, 2021

I think this issue might be closed since all commits for luacheck is merged already?

@somesocks
Copy link
Owner

I think this issue might be closed since all commits for luacheck is merged already?

👍 makes sense, feel free to close it @evkornev

@evkornev evkornev closed this as completed Jan 9, 2021
@evkornev
Copy link
Collaborator

evkornev commented Jan 9, 2021

All luacheck's related code is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants