simonmittag/jabba

View on GitHub
proxy.go

Summary

Maintainability
A
2 hrs
Test Coverage
B
85%

File proxy.go has 853 lines of code (exceeds 500 allowed). Consider refactoring.
Wontfix

package j8a

import (
    "bufio"
    "bytes"
Severity: Major
Found in proxy.go - About 1 day to fix

    Proxy has 25 methods (exceeds 20 allowed). Consider refactoring.
    Wontfix

    type Proxy struct {
        XRequestID   string
        XRequestInfo bool
        Up           Up
        Dwn          Down
    Severity: Minor
    Found in proxy.go - About 2 hrs to fix

      Method Proxy.parseRequestBody has 53 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (proxy *Proxy) parseRequestBody(request *http.Request) {
          //content length 0, do not read just go back
          if request.ContentLength == 0 {
              infoOrTraceEv(proxy).
                  Int64(dwnElpsdMicros, time.Since(proxy.Dwn.startDate).Microseconds()).
      Severity: Minor
      Found in proxy.go - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                    if len(atmpt.ContentEncoding) > 0 {
                        //only set this if it was present upstream, otherwise assume nothing and leave empty.
                        proxy.Dwn.Resp.ContentEncoding = atmpt.ContentEncoding
                    } else {
                        proxy.Dwn.Resp.ContentEncoding = EncIdentity
        Severity: Major
        Found in proxy.go - About 45 mins to fix

          Method ContentEncoding.matches has 5 return statements (exceeds 4 allowed).
          Open

          func (c ContentEncoding) matches(encoding ContentEncoding) bool {
              if len(c) == 0 && encoding == EncIdentity {
                  return true
              } else if len(string(encoding)) == 0 {
                  return false
          Severity: Major
          Found in proxy.go - About 35 mins to fix

            Similar blocks of code found in 3 locations. Consider refactoring.
            Wontfix

                if parsed.NotBefore().Unix() > 1 {
                    ev.Bool("jwtClaimsNbf", true)
                    ev.Str("jwtNbfUtcIso", parsed.NotBefore().Format(time.RFC3339))
                    ev.Str("jwtNbfLclIso", parsed.NotBefore().Local().Format(time.RFC3339))
                    ev.Int64("jwtNbfUnix", parsed.NotBefore().Unix())
            Severity: Major
            Found in proxy.go and 2 other locations - About 1 hr to fix
            proxy.go on lines 979..986
            proxy.go on lines 997..1004

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 139.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Wontfix

                if parsed.IssuedAt().Unix() > 1 {
                    ev.Bool("jwtClaimsIat", true)
                    ev.Str("jwtIatUtcIso", parsed.IssuedAt().Format(time.RFC3339))
                    ev.Str("jwtIatLclIso", parsed.IssuedAt().Local().Format(time.RFC3339))
                    ev.Int64("jwtIatUnix", parsed.IssuedAt().Unix())
            Severity: Major
            Found in proxy.go and 2 other locations - About 1 hr to fix
            proxy.go on lines 988..995
            proxy.go on lines 997..1004

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 139.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Wontfix

                if parsed.Expiration().Unix() > 1 {
                    ev.Bool("jwtClaimsExp", true)
                    ev.Str("jwtExpUtcIso", parsed.Expiration().Format(time.RFC3339))
                    ev.Str("jwtExpLclIso", parsed.Expiration().Local().Format(time.RFC3339))
                    ev.Int64("jwtExpUnix", parsed.Expiration().Unix())
            Severity: Major
            Found in proxy.go and 2 other locations - About 1 hr to fix
            proxy.go on lines 979..986
            proxy.go on lines 988..995

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 139.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status