omissis/kube-apiserver-proxy

View on GitHub

Showing 6 of 6 total issues

Function NewServeCommand has 8 return statements (exceeds 4 allowed).
Open

func NewServeCommand(ctr *app.Container) *cobra.Command {
    cmd := &cobra.Command{
        Use:   "serve",
        Short: "Run kube-apiserver-proxy server",
        Args:  cobra.ExactArgs(0),
Severity: Major
Found in internal/cmd/serve.go - About 50 mins to fix

    Method HTTP.DoServeHTTP has 7 return statements (exceeds 4 allowed).
    Open

    func (h *HTTP) DoServeHTTP(ctx context.Context, w http.ResponseWriter, r http.Request) error {
        if ctx == nil {
            return ErrContextIsNil
        }
    
    
    Severity: Major
    Found in pkg/kube/proxy/http.go - About 45 mins to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (mr *MockRESTConfigFactoryMockRecorder) New(kubeconfigPath interface{}) *gomock.Call {
          mr.mock.ctrl.T.Helper()
          return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "New", reflect.TypeOf((*MockRESTConfigFactory)(nil).New), kubeconfigPath)
      }
      Severity: Minor
      Found in pkg/kube/config_mock.gen.go and 1 other location - About 40 mins to fix
      pkg/kube/client_mock.gen.go on lines 63..66

      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 111.

      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 2 locations. Consider refactoring.
      Open

      func (mr *MockRESTClientFactoryMockRecorder) Request(r interface{}) *gomock.Call {
          mr.mock.ctrl.T.Helper()
          return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Request", reflect.TypeOf((*MockRESTClientFactory)(nil).Request), r)
      }
      Severity: Minor
      Found in pkg/kube/client_mock.gen.go and 1 other location - About 40 mins to fix
      pkg/kube/config_mock.gen.go on lines 47..50

      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 111.

      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

      Function GetGroupVersionFromURI has 6 return statements (exceeds 4 allowed).
      Open

      func GetGroupVersionFromURI(uri string) (string, string, error) {
          if uri == "/api" {
              return "core", "", nil
          }
      
      
      Severity: Major
      Found in pkg/kube/uri.go - About 40 mins to fix

        Method JqResponseBodyTransformer.Run has 5 return statements (exceeds 4 allowed).
        Open

        func (jq *JqResponseBodyTransformer) Run(body []byte, opts map[string]any) ([]byte, error) {
            query, err := gojq.Parse(opts["src"].(string))
            if err != nil {
                return nil, err
            }
        Severity: Major
        Found in pkg/kube/proxy/transformers.go - About 35 mins to fix
          Severity
          Category
          Status
          Source
          Language