cloudfoundry/stratos

View on GitHub
src/jetstream/plugins/cloudfoundryhosting/main.go

Summary

Maintainability
C
1 day
Test Coverage

Method CFHosting.Init has a Cognitive Complexity of 29 (exceeds 8 allowed). Consider refactoring.
Open

func (ch *CFHosting) Init() error {

    // Determine if we are running CF by presence of env var "VCAP_APPLICATION" and configure appropriately
    if ch.portalProxy.Env().IsSet(VCapApplication) {
        log.Info("Detected that Console is deployed as a Cloud Foundry Application")
Severity: Minor
Found in src/jetstream/plugins/cloudfoundryhosting/main.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 CFHosting.Init has 84 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (ch *CFHosting) Init() error {

    // Determine if we are running CF by presence of env var "VCAP_APPLICATION" and configure appropriately
    if ch.portalProxy.Env().IsSet(VCapApplication) {
        log.Info("Detected that Console is deployed as a Cloud Foundry Application")
Severity: Major
Found in src/jetstream/plugins/cloudfoundryhosting/main.go - About 2 hrs to fix

    Function ConfigInit has a Cognitive Complexity of 18 (exceeds 8 allowed). Consider refactoring.
    Open

    func ConfigInit(envLookup *env.VarSet, jetstreamConfig *interfaces.PortalConfig) {
    
        // Check we are deployed in Cloud Foundry
        if !envLookup.IsSet(VCapApplication) {
            return
    Severity: Minor
    Found in src/jetstream/plugins/cloudfoundryhosting/main.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 CFHosting.Init has 5 return statements (exceeds 4 allowed).
    Open

    func (ch *CFHosting) Init() error {
    
        // Determine if we are running CF by presence of env var "VCAP_APPLICATION" and configure appropriately
        if ch.portalProxy.Env().IsSet(VCapApplication) {
            log.Info("Detected that Console is deployed as a Cloud Foundry Application")
    Severity: Major
    Found in src/jetstream/plugins/cloudfoundryhosting/main.go - About 35 mins to fix

      There are no issues that match your filters.

      Category
      Status