cloudfoundry/stratos

View on GitHub
src/jetstream/plugins/monocular/artifacthub.go

Summary

Maintainability
C
1 day
Test Coverage

Method Monocular.artifactHubGetIcon has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
Open

func (m *Monocular) artifactHubGetIcon(c echo.Context) error {
    endpoint := c.Param("guid")
    repo := c.Param("repo")
    chartName := c.Param("name")
    version := c.Param("version")
Severity: Minor
Found in src/jetstream/plugins/monocular/artifacthub.go - About 2 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 Monocular.artifactHubGetPackageInfo has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
Open

func (m *Monocular) artifactHubGetPackageInfo(endpointID, repo, name, version string) (*ahInfo, error) {
    // Make sure we handle an empty version correctly
    var cacheName string
    var versionPart = ""
    if len(version) > 0 {
Severity: Minor
Found in src/jetstream/plugins/monocular/artifacthub.go - About 1 hr 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 Monocular.getChartURL has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
Open

func (m *Monocular) getChartURL(repoURL, name, version string) (string, error) {
    httpClient := m.portalProxy.GetHttpClient(true)

    helmIndexURL := joinURL(repoURL, "index.yaml")
    resp, err := httpClient.Get(helmIndexURL)
Severity: Minor
Found in src/jetstream/plugins/monocular/artifacthub.go - About 1 hr 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 Monocular.fetchChartsFromArtifactHub has 52 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (m *Monocular) fetchChartsFromArtifactHub(c echo.Context, endpointID string) error {
    cacheFolder := path.Join(m.CacheFolder, endpointID)
    indexFile := path.Join(cacheFolder, "hub_index.json")
    if ok := useCachedFile(indexFile); ok {
        // Just send the cached file
Severity: Minor
Found in src/jetstream/plugins/monocular/artifacthub.go - About 1 hr to fix

    Method Monocular.artifactHubGetIcon has 8 return statements (exceeds 4 allowed).
    Open

    func (m *Monocular) artifactHubGetIcon(c echo.Context) error {
        endpoint := c.Param("guid")
        repo := c.Param("repo")
        chartName := c.Param("name")
        version := c.Param("version")
    Severity: Major
    Found in src/jetstream/plugins/monocular/artifacthub.go - About 50 mins to fix

      Method Monocular.artifactHubCacheChartFiles has 5 return statements (exceeds 4 allowed).
      Open

      func (m *Monocular) artifactHubCacheChartFiles(endpointID, repoName, repoURL, name, version, digest string) (string, error) {
      
          // First look to see if there is a digest file
          cacheFolder := path.Join(m.CacheFolder, endpointID, fmt.Sprintf("%s_%s_%s", repoName, name, version))
          if hasDigestFile(cacheFolder, digest) {
      Severity: Major
      Found in src/jetstream/plugins/monocular/artifacthub.go - About 35 mins to fix

        Method Monocular.getChartURL has 5 return statements (exceeds 4 allowed).
        Open

        func (m *Monocular) getChartURL(repoURL, name, version string) (string, error) {
            httpClient := m.portalProxy.GetHttpClient(true)
        
            helmIndexURL := joinURL(repoURL, "index.yaml")
            resp, err := httpClient.Get(helmIndexURL)
        Severity: Major
        Found in src/jetstream/plugins/monocular/artifacthub.go - About 35 mins to fix

          Method Monocular.fetchChartsFromArtifactHub has 5 return statements (exceeds 4 allowed).
          Open

          func (m *Monocular) fetchChartsFromArtifactHub(c echo.Context, endpointID string) error {
              cacheFolder := path.Join(m.CacheFolder, endpointID)
              indexFile := path.Join(cacheFolder, "hub_index.json")
              if ok := useCachedFile(indexFile); ok {
                  // Just send the cached file
          Severity: Major
          Found in src/jetstream/plugins/monocular/artifacthub.go - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status