portainer/portainer

View on GitHub
api/http/proxy/factory/docker/containers.go

Summary

Maintainability
B
6 hrs
Test Coverage

Method Transport.decorateContainerCreationOperation has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
Open

func (transport *Transport) decorateContainerCreationOperation(request *http.Request, resourceIdentifierAttribute string, resourceType portainer.ResourceControlType) (*http.Response, error) {
    type PartialContainer struct {
        HostConfig struct {
            Privileged bool                   `json:"Privileged"`
            PidMode    string                 `json:"PidMode"`
Severity: Minor
Found in api/http/proxy/factory/docker/containers.go - About 3 hrs 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

Method Transport.decorateContainerCreationOperation has 68 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (transport *Transport) decorateContainerCreationOperation(request *http.Request, resourceIdentifierAttribute string, resourceType portainer.ResourceControlType) (*http.Response, error) {
    type PartialContainer struct {
        HostConfig struct {
            Privileged bool                   `json:"Privileged"`
            PidMode    string                 `json:"PidMode"`
Severity: Minor
Found in api/http/proxy/factory/docker/containers.go - About 1 hr to fix

    Method Transport.decorateContainerCreationOperation has 13 return statements (exceeds 4 allowed).
    Open

    func (transport *Transport) decorateContainerCreationOperation(request *http.Request, resourceIdentifierAttribute string, resourceType portainer.ResourceControlType) (*http.Response, error) {
        type PartialContainer struct {
            HostConfig struct {
                Privileged bool                   `json:"Privileged"`
                PidMode    string                 `json:"PidMode"`
    Severity: Major
    Found in api/http/proxy/factory/docker/containers.go - About 1 hr to fix

      Method Transport.containerListOperation has 5 return statements (exceeds 4 allowed).
      Open

      func (transport *Transport) containerListOperation(response *http.Response, executor *operationExecutor) error {
          // ContainerList response is a JSON array
          // https://docs.docker.com/engine/api/v1.28/#operation/ContainerList
          responseArray, err := utils.GetResponseAsJSONArray(response)
          if err != nil {
      Severity: Major
      Found in api/http/proxy/factory/docker/containers.go - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status