LLKennedy/httpgrpc

View on GitHub
internal/codegen/run.go

Summary

Maintainability
A
3 hrs
Test Coverage

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 = "[]"
    }
Severity: Minor
Found in internal/codegen/run.go - About 1 hr to fix

    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
            }
    Severity: Minor
    Found in internal/codegen/run.go - About 55 mins to fix

    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 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func generateImportsForMethod(f *descriptorpb.MethodDescriptorProto, ownPkg string, fileName string, importMap map[string][]string, content *strings.Builder, impexp importsExports) (useGoogle bool) {
    Severity: Minor
    Found in internal/codegen/run.go - About 45 mins to fix

      Function generateService has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func generateService(f *descriptorpb.FileDescriptorProto, service *descriptorpb.ServiceDescriptorProto, content *strings.Builder, impexp importsExports, parsedMethods map[string]parsedMethod) {
      Severity: Minor
      Found in internal/codegen/run.go - About 35 mins to fix

        Function getNativeTypeName has a Cognitive Complexity of 21 (exceeds 20 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 = "[]"
            }
        Severity: Minor
        Found in internal/codegen/run.go - About 25 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status