Showing 37 of 125 total issues
File service.pb.go
has 872 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.10.1
// source: service.proto
Function file_service_proto_init
has 168 lines of code (exceeds 50 allowed). Consider refactoring. Open
func file_service_proto_init() {
if File_service_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
File proxy.pb.go
has 619 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.10.1
// source: proxy.proto
File service_grpc.pb.go
has 582 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package service
import (
File websocket.ts
has 306 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { ProtoJSONCompatible, Parser } from "@llkennedy/protoc-gen-tsjson";
import { IMutex, Mutex } from "../common";
import * as uuid from "uuid";
export const EOFMessage = "EOF";
Function file_service_proto_init
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func file_service_proto_init() {
if File_service_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function file_proxy_proto_init
has 100 lines of code (exceeds 50 allowed). Consider refactoring. Open
func file_proxy_proto_init() {
if File_proxy_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
Function initConnection
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async initConnection(): Promise<EstablishedWebsocket<ReqT, ResT>> {
if (this.initialised) {
throw new Error("cannot initialise MercuryWebSocket twice");
}
this.initialised = true;
MercuryWebSocket
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export class MercuryWebSocket<ReqT extends ProtoJSONCompatible, ResT = any> {
//#region properties
/** The logger used for all logs from this class */
public readonly logger: Logger = console;
/** The name of this websocket */
Method Server.handleClientStream
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) handleClientStream(ctx context.Context, procType reflect.Type, caller reflect.Value, srv httpapi.ExposedService_ProxyStreamServer) (err error) {
defer func() {
r := recover()
if r != nil {
err = status.Errorf(codes.Internal, "caught panic for client stream: %v", r)
Function makeMockedWebsocket
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function makeMockedWebsocket(sandbox: sinon.SinonSandbox): Promise<mockedWebsocket> {
let fake = new FakeWebsocket();
let evStub = sandbox.stub(fake, "addEventListener");
let done: ((a: any) => any)[] = [];
let wait: [Promise<(ev: CloseEvent) => void>, Promise<(ev: Event) => void>, Promise<(ev: MessageEvent) => void>, Promise<(ev: Event) => void>] = [
Method Server.handleServerStream
has 63 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) handleServerStream(ctx context.Context, procType reflect.Type, caller reflect.Value, srv httpapi.ExposedService_ProxyStreamServer) (err error) {
defer func() {
r := recover()
if r != nil {
err = status.Errorf(codes.Internal, "caught panic for server stream: %v", r)
Method stream.Serve
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (h stream) Serve(c *websocket.Conn) {
errWriter := errorWriter{
c: c,
loggers: h.loggers,
txid: h.txid,
Method Server.handleDualStream
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) handleDualStream(ctx context.Context, procType reflect.Type, caller reflect.Value, srv httpapi.ExposedService_ProxyStreamServer) (err error) {
defer func() {
r := recover()
if r != nil {
err = status.Errorf(codes.Internal, "caught panic for dual stream: %v", r)
Method Server.callStructStruct
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) callStructStruct(ctx context.Context, inputJSON []byte, procType reflect.Type, caller reflect.Value) (res *httpapi.Response, err error) {
// Create new instance of struct argument to pass into real implementation
builtRequest := reflect.New(procType.In(2).Elem())
builtRequestPtr := builtRequest.Interface()
builtRequestMessage, ok := builtRequestPtr.(proto.Message)
Function ProxyRequest
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
func ProxyRequest(ctx context.Context, w http.ResponseWriter, r *http.Request, procedure string, conn grpc.ClientConnInterface, txid string, loggers ...logs.Writer) {
remote := httpapi.NewExposedServiceClient(conn)
isWebsocket := false
upgradeHader, ok := r.Header["Upgrade"]
if ok {
Function feed
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function feed() {
let ws = new MercuryWebSocket<FeedData, FeedResponse>("ws://127.0.0.1:4848/Feed", FeedResponse.Parse, "FeedSocket", console);
await ws.init()
let stream = new ClientStream(ws);
let data1 = new FeedData();
Function getNativeTypeName
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
func getNativeTypeName(field *descriptorpb.FieldDescriptorProto, message *descriptorpb.DescriptorProto, pkgName string, fileExports []string) string {
repeatedStr := ""
if field.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REPEATED {
repeatedStr = "[]"
}
Function initConnection
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private async initConnection(): Promise<EstablishedWebsocket<ReqT, ResT>> {
if (this.initialised) {
throw new Error("cannot initialise MercuryWebSocket twice");
}
this.initialised = true;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function generateImportsForMethod
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func generateImportsForMethod(f *descriptorpb.MethodDescriptorProto, ownPkg string, fileName string, importMap map[string][]string, content *strings.Builder, impexp importsExports) (useGoogle bool) {
for _, typeName := range []string{f.GetInputType(), f.GetOutputType()} {
if typeName == "" {
continue
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"