Cloud-CV/EvalAI

View on GitHub
frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts

Summary

Maintainability
C
1 day
Test Coverage

File challengelist.component.ts has 254 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Component, HostListener, Inject, OnInit } from '@angular/core';
import { ApiService } from '../../../services/api.service';
import { GlobalService } from '../../../services/global.service';
import { AuthService } from '../../../services/auth.service';
import { EndpointsService } from '../../../services/endpoints.service';

    Function ngOnInit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      ngOnInit() {
        if (this.authService.isLoggedIn()) {
          this.isLoggedIn = true;
        }
    
    

    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 toggleFilter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      toggleFilter(filter) {
        this[filter] = !this[filter];
        if (this[filter]) {
          this.fetchChallenges(filter);
        } else {

    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 fetchMyParticipatedChallenges has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      fetchMyParticipatedChallenges(filter = null, callback = null) {
        const SELF = this;
        if (!filter) {
          const ALL_PATHS = Object.values(SELF.newApiPathMapping);
          const ALL_KEYS = Object.keys(SELF.newApiPathMapping);

    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 fetchChallenges has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      fetchChallenges(filter = null, callback = null, approved_status = "approved", visibility = "public") {
        if (!filter) {
          const ALL_PATHS = Object.values(this.apiPathMapping);
          const ALL_KEYS = Object.keys(this.apiPathMapping);
          for (let i = 0; i < ALL_PATHS.length; i++) {

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

            if (path.endsWith('present/')) {
              SELF.ongoingChallenges = data['results'];
            } else if (path.endsWith('past/')) {
              SELF.pastChallenges = data['results'];
            }
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 395..399

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

    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

            } else if (path.includes('present')) {
              SELF.ongoingChallenges = data['results'];
            } else if (path.includes('past')) {
              SELF.pastChallenges = data['results'];
            }
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 422..426

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

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

          this.filteredChallenges = this.filteredChallenges.filter(
            (v, i, a) => this.allTeams.indexOf(v['creator']['id']) > -1
          );
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 313..315
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 316..318
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 319..321

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

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

          this.filteredUpcomingChallenges = this.filteredUpcomingChallenges.filter(
            (v, i, a) => this.allTeams.indexOf(v['creator']['id']) > -1
          );
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 310..312
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 313..315
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 319..321

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

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

          this.filteredOngoingChallenges = this.filteredOngoingChallenges.filter(
            (v, i, a) => this.allTeams.indexOf(v['creator']['id']) > -1
          );
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 310..312
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 316..318
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 319..321

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

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

          this.filteredPastChallenges = this.filteredPastChallenges.filter(
            (v, i, a) => this.allTeams.indexOf(v['creator']['id']) > -1
          );
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 310..312
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 313..315
    frontend_v2/src/app/components/publiclists/challengelist/challengelist.component.ts on lines 316..318

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

    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

    There are no issues that match your filters.

    Category
    Status