diff --git a/examples/autobahn_client.nim b/examples/autobahn_client.nim index 5345d79f..8d6ff037 100644 --- a/examples/autobahn_client.nim +++ b/examples/autobahn_client.nim @@ -78,7 +78,7 @@ proc main() {.async.} = try: let ws = await connectServer(path, deflateFactory) - while ws.readystate != ReadyState.Closed: + while ws.readyState != ReadyState.Closed: # echo back let data = await ws.recvMsg() let opCode = if ws.binary: diff --git a/tests/helpers.nim b/tests/helpers.nim index 930bee00..7aeee047 100644 --- a/tests/helpers.nim +++ b/tests/helpers.nim @@ -31,7 +31,7 @@ proc rndBin*(size: int): seq[byte] = proc waitForClose*(ws: WSSession) {.async.} = try: - while ws.readystate != ReadyState.Closed: + while ws.readyState != ReadyState.Closed: discard await ws.recvMsg() except CatchableError: trace "Closing websocket" diff --git a/tests/testutf8.nim b/tests/testutf8.nim index 18460409..dcea2c9b 100644 --- a/tests/testutf8.nim +++ b/tests/testutf8.nim @@ -73,7 +73,7 @@ suite "UTF-8 DFA validator": proc waitForClose(ws: WSSession) {.async.} = try: - while ws.readystate != ReadyState.Closed: + while ws.readyState != ReadyState.Closed: discard await ws.recvMsg() except CatchableError: trace "Closing websocket" diff --git a/websock.nimble b/websock.nimble index 64047448..9eea0de9 100644 --- a/websock.nimble +++ b/websock.nimble @@ -26,7 +26,7 @@ requires "zlib" task test, "run tests": # dont't need to run it, only want to test if it is compileable - exec "nim c -c --verbosity:0 --hints:off -d:chronicles_log_level=TRACE -d:chronicles_sinks:json ./tests/testcommon" + exec "nim c -c --verbosity:0 --hints:off -d:chronicles_log_level=TRACE -d:chronicles_sinks:json --styleCheck:usages --styleCheck:error ./tests/testcommon" exec "nim --hints:off c -r --opt:speed -d:debug --verbosity:0 --hints:off -d:chronicles_log_level=INFO ./tests/testcommon.nim" rmFile "./tests/testcommon" diff --git a/websock/extensions/extutils.nim b/websock/extensions/extutils.nim index bf05bfff..7e768ad6 100644 --- a/websock/extensions/extutils.nim +++ b/websock/extensions/extutils.nim @@ -19,7 +19,7 @@ type TokenKind = enum tkError - tkSemcol + tkSemCol tkComma tkEqual tkName @@ -38,7 +38,7 @@ const '[','{',']','}', ';',':','\'',',','<','.','>','/','?','|'} QCHAR = WHITES + LCHAR + SEPARATORS -proc parseName[T: BChar](lex: var Lexer, data: openarray[T]) = +proc parseName[T: BChar](lex: var Lexer, data: openArray[T]) = while lex.pos < data.len: let cc = data[lex.pos] if cc notin LCHAR: @@ -46,7 +46,7 @@ proc parseName[T: BChar](lex: var Lexer, data: openarray[T]) = lex.token.add cc inc lex.pos -proc parseQuoted[T: BChar](lex: var Lexer, data: openarray[T]) = +proc parseQuoted[T: BChar](lex: var Lexer, data: openArray[T]) = while lex.pos < data.len: let cc = data[lex.pos] case cc: @@ -70,7 +70,7 @@ proc parseQuoted[T: BChar](lex: var Lexer, data: openarray[T]) = lex.tok = tkError -proc next[T: BChar](lex: var Lexer, data: openarray[T]) = +proc next[T: BChar](lex: var Lexer, data: openArray[T]) = while lex.pos < data.len: if data[lex.pos] notin WHITES: break @@ -85,7 +85,7 @@ proc next[T: BChar](lex: var Lexer, data: openarray[T]) = case c of ';': inc lex.pos - lex.tok = tkSemcol + lex.tok = tkSemCol return of ',': inc lex.pos @@ -107,7 +107,7 @@ proc next[T: BChar](lex: var Lexer, data: openarray[T]) = lex.tok = tkError return -proc parseExt*[T: BChar](data: openarray[T], output: var seq[AppExt]): bool = +proc parseExt*[T: BChar](data: openArray[T], output: var seq[AppExt]): bool = var lex: Lexer var ext: AppExt lex.next(data) diff --git a/websock/http/server.nim b/websock/http/server.nim index c00a3eb0..e0cb0c49 100644 --- a/websock/http/server.nim +++ b/websock/http/server.nim @@ -147,7 +147,7 @@ proc handleTlsConnCb( maxVersion = tlsHttpServer.maxVersion, flags = tlsHttpServer.tlsFlags) - var stream: ASyncStream + var stream: AsyncStream try: stream = AsyncStream( reader: tlsStream.reader, diff --git a/websock/session.nim b/websock/session.nim index 7459384b..6af9e770 100644 --- a/websock/session.nim +++ b/websock/session.nim @@ -133,7 +133,7 @@ proc send*( proc handleClose*( ws: WSSession, frame: Frame, - payLoad: seq[byte] = @[]) {.async.} = + payload: seq[byte] = @[]) {.async.} = ## Handle close sequence ## @@ -161,7 +161,7 @@ proc handleClose*( "Invalid close frame with payload length 1!") else: try: - code = StatusCodes(uint16.fromBytesBE(payLoad[0..<2])) + code = StatusCodes(uint16.fromBytesBE(payload[0..<2])) except RangeError: raise newException(WSInvalidCloseCodeError, "Status code out of range!") @@ -178,7 +178,7 @@ proc handleClose*( &"Can't use reserved status code: {code}") # remaining payload bytes are reason for closing - reason = string.fromBytes(payLoad[2..payLoad.high]) + reason = string.fromBytes(payload[2..payload.high]) if not ws.binary and validateUTF8(reason) == false: raise newException(WSInvalidUTF8, @@ -231,14 +231,14 @@ proc handleControl*(ws: WSSession, frame: Frame) {.async.} = raise newException(WSPayloadTooLarge, "Control message payload is greater than 125 bytes!") - var payLoad = newSeq[byte](frame.length.int) + var payload = newSeq[byte](frame.length.int) if frame.length > 0: - payLoad.setLen(frame.length.int) + payload.setLen(frame.length.int) # Read control frame payload. - await ws.stream.reader.readExactly(addr payLoad[0], frame.length.int) + await ws.stream.reader.readExactly(addr payload[0], frame.length.int) if frame.mask: mask( - payLoad.toOpenArray(0, payLoad.high), + payload.toOpenArray(0, payload.high), frame.maskKey) # Process control frame payload. @@ -246,20 +246,20 @@ proc handleControl*(ws: WSSession, frame: Frame) {.async.} = of Opcode.Ping: if not isNil(ws.onPing): try: - ws.onPing(payLoad) + ws.onPing(payload) except CatchableError as exc: trace "Exception in Ping callback, this is most likely a bug", exc = exc.msg # send pong to remote - await ws.send(payLoad, Opcode.Pong) + await ws.send(payload, Opcode.Pong) of Opcode.Pong: if not isNil(ws.onPong): try: - ws.onPong(payLoad) + ws.onPong(payload) except CatchableError as exc: trace "Exception in Pong callback, this is most likely a bug", exc = exc.msg of Opcode.Close: - await ws.handleClose(frame, payLoad) + await ws.handleClose(frame, payload) else: raise newException(WSInvalidOpcodeError, "Invalid control opcode!")