cloudfoundry-incubator/stratos

View on GitHub

Showing 1,111 of 1,370 total issues

Function ngOnInit has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  ngOnInit() {
    const events$ = this.eventService.events$.pipe(
      map(events => {
        if (this.endpointOnly) {
          return events.filter(event => event.key.split('-')[0] === 'endpointError');

    Function mapContainerStatus has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
    Open

    func mapContainerStatus(status v1.PodStatus, name string) NodeStatus {
        for _, cstat := range status.ContainerStatuses {
            if cstat.Name == name {
                if cstat.Ready {
                    return NodeOK
    Severity: Minor
    Found in src/jetstream/plugins/kubernetes/helm/graph_status.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 MetricsSpecification.Connect has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
    Open

    func (m *MetricsSpecification) Connect(ec echo.Context, cnsiRecord interfaces.CNSIRecord, userId string) (*interfaces.TokenRecord, bool, error) {
        log.Debug("Metrics Connect...")
    
        params := new(interfaces.LoginToCNSIParams)
        err := interfaces.BindOnce(params, ec)
    Severity: Minor
    Found in src/jetstream/plugins/metrics/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 Monocular.getRepoStatuses has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
    Open

    func (m *Monocular) getRepoStatuses(c echo.Context) error {
        log.Debug("getRepoStatuses")
    
        // Get the list of endpoints we are looking at
        // Need to extract the parameters from the request body
    Severity: Minor
    Found in src/jetstream/plugins/monocular/repository.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.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 UaaUserInfo.uaa has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
    Open

    func (userInfo *UaaUserInfo) uaa(target string, body []byte) (int, []byte, *http.Header, error) {
        log.Debug("uaa request")
    
        // Check session
        _, err := userInfo.portalProxy.GetSessionInt64Value(userInfo.echo, "exp")
    Severity: Minor
    Found in src/jetstream/plugins/userinfo/uaa_user.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 PostgresCNSIRepository.List has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
    Open

    func (p *PostgresCNSIRepository) List(encryptionKey []byte) ([]*interfaces.CNSIRecord, error) {
        log.Debug("List")
        rows, err := p.db.Query(listCNSIs)
        if err != nil {
            return nil, fmt.Errorf("Unable to retrieve CNSI records: %v", err)
    Severity: Minor
    Found in src/jetstream/repository/cnsis/pgsql_cnsis.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 PostgresCNSIRepository.listBy has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
    Open

    func (p *PostgresCNSIRepository) listBy(query string, match string, encryptionKey []byte) ([]*interfaces.CNSIRecord, error) {
        rows, err := p.db.Query(query, match)
        if err != nil {
            return nil, fmt.Errorf("Unable to retrieve CNSI records: %v", err)
        }
    Severity: Minor
    Found in src/jetstream/repository/cnsis/pgsql_cnsis.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 ConsoleConfig.IsSetupComplete has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
    Open

    func (consoleConfig *ConsoleConfig) IsSetupComplete() bool {
    
        // No auth, then setup is complete
        if AuthEndpointTypes[consoleConfig.AuthEndpointType] == AuthNone {
            return true
    Severity: Minor
    Found in src/jetstream/repository/interfaces/structs.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

    Function findFreePort has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
    Open

    function findFreePort(beg, ...rest){
      const p = rest.slice(0, rest.length - 1), cb = rest[rest.length - 1];
      let [end, ip, cnt] = Array.from(p);
      if (!ip && end && !/^\d+$/.test(end)) { // deal with method 3
        ip = end;
    Severity: Minor
    Found in electron/freeport.js - 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

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

      describe('Create Space Scoped Service Instance', () => {
        let servicesHelperE2E: ServicesHelperE2E;
        let marketplaceSummaryPage: MarketplaceSummaryPage;
        const serviceName = e2e.secrets.getDefaultCFEndpoint().services.spaceScopedService.name;
        beforeAll(() => init(setup, serviceName).then(res => {
    src/test-e2e/marketplace/marketplace-create-service-instances-e2e.spec.ts on lines 27..50
    src/test-e2e/marketplace/marketplace-create-service-instances-e2e.spec.ts on lines 52..75

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

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

      describe('Create Private Service Instance', () => {
        let servicesHelperE2E: ServicesHelperE2E;
        let marketplaceSummaryPage: MarketplaceSummaryPage;
        const serviceName = e2e.secrets.getDefaultCFEndpoint().services.privateService.name;
        beforeAll(() => init(setup, serviceName).then(res => {
    src/test-e2e/marketplace/marketplace-create-service-instances-e2e.spec.ts on lines 27..50
    src/test-e2e/marketplace/marketplace-create-service-instances-e2e.spec.ts on lines 77..101

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

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

      describe('Create Public Service Instance', () => {
        let servicesHelperE2E: ServicesHelperE2E;
        let marketplaceSummaryPage: MarketplaceSummaryPage;
        const serviceName = e2e.secrets.getDefaultCFEndpoint().services.publicService.name;
        beforeAll(() => init(setup, serviceName).then(res => {
    src/test-e2e/marketplace/marketplace-create-service-instances-e2e.spec.ts on lines 52..75
    src/test-e2e/marketplace/marketplace-create-service-instances-e2e.spec.ts on lines 77..101

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

    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 get has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      get(summary: any, appInstances: AppStat[]): ApplicationStateData {
        const appState: string = summary ? summary.state : 'UNKNOWN';
        const pkgState = this.getPackageState(appState, summary);
        const wildcard = this.stateMetadata['?'];
    
    

      Function ngOnInit has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        ngOnInit() {
      
          // Listen for the graph
          this.graph = combineLatest(
            this.helper.fetchReleaseGraph(),

        Method CFAppPush.getGitSCMSource has 67 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (cfAppPush *CFAppPush) getGitSCMSource(clientWebSocket *websocket.Conn, tempDir string, msg SocketMessage, userGUID string) (StratosProject, string, error) {
            var (
                err error
            )
        
        
        Severity: Minor
        Found in src/jetstream/plugins/cfapppush/deploy.go - About 1 hr to fix

          Method portalProxy.doRequest has 67 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (p *portalProxy) doRequest(cnsiRequest *interfaces.CNSIRequest, done chan<- *interfaces.CNSIRequest) {
              log.Debugf("doRequest for URL: %s", cnsiRequest.URL.String())
              var body io.Reader
              var res *http.Response
              var req *http.Request
          Severity: Minor
          Found in src/jetstream/passthrough.go - About 1 hr to fix

            Function login has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              login(username: string, password: string) {
                // If this is a different user to last time, then logout first
                if (SSOLoginPage.ssoLastUsername && SSOLoginPage.ssoLastUsername !== username) {
                  browser.waitForAngularEnabled(false);
                  this.logoutUAA();
            Severity: Minor
            Found in src/test-e2e/login/sso-login.po.ts - About 1 hr to fix

              Function ngOnInit has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                ngOnInit() {
              
                  const helmLastModifiedRegEx = /seconds:([0-9]*)/;
              
                  this.sessionData$ = this.store.select(s => s.auth).pipe(

                Function goNext has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  goNext() {
                    // Close previous error snackbar if there was one
                    if (this.snackBarRef) {
                      this.snackBar.dismiss();
                    }
                  Severity
                  Category
                  Status
                  Source
                  Language