Cloud-CV/EvalAI

View on GitHub
frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.ts

Summary

Maintainability
F
4 days
Test Coverage

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

import { Component, OnInit, QueryList, ViewChildren } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { NGXLogger } from 'ngx-logger';

// import service

    Function formSubmit has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      formSubmit(self) {
        self.submissionError = '';
        let metaValue = true;
        const submissionFile = self.globalService.formItemForLabel(self.components, 'input_file').fileValue;
        const submissionProjectUrl = self.globalService.formValueForLabel(self.components, 'project_url');

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

        fetchRemainingSubmissions(challenge, phase) {
          const API_PATH = this.endpointsService.challengeSubmissionsRemainingURL(challenge);
          const SELF = this;
          clearInterval(SELF.timer);
          SELF.isClockStarted = false;

        Function editSubmissionGuidelineUpload has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

           editSubmissionGuidelineUpload() {
            const SELF = this;
            SELF.apiCall = (params) => {
              const FORM_DATA: FormData = new FormData();
              FORM_DATA.append('submission_guidelines_file', params['submission_guidelines_file']);

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

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

            Function countDownTimer has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              countDownTimer(SELF, eachPhase) {
                if (!SELF.isClockStarted) {
                  SELF.remainingTime = parseInt(eachPhase.limits.remaining_time, 10);
                }
                SELF.days = Math.floor(SELF.remainingTime / 24 / 60 / 60);

              Function formSubmit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                formSubmit(self) {
                  self.submissionError = '';
                  let metaValue = true;
                  const submissionFile = self.globalService.formItemForLabel(self.components, 'input_file').fileValue;
                  const submissionProjectUrl = self.globalService.formValueForLabel(self.components, 'project_url');

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

                storeMetadata(data) {
                  for (let i = 0; i < data.count; i++) {
                    if (data.results[i].submission_meta_attributes) {
                      const attributes = data.results[i].submission_meta_attributes;
                      attributes.forEach(function (attribute) {

                Function displayDockerSubmissionInstructions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  displayDockerSubmissionInstructions(challenge, isParticipated) {
                    if (isParticipated) {
                      const API_PATH = this.endpointsService.challengeSubmissionsRemainingURL(challenge);
                      const SELF = this;
                      this.apiService.getUrl(API_PATH).subscribe(

                  Function editSubmissionGuideline has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    editSubmissionGuideline() {
                      const SELF = this;
                      SELF.apiCall = (params) => {
                        const BODY = JSON.stringify(params);
                        SELF.apiService

                    Function validateInput has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      validateInput(inputValue) {
                        const regex = new RegExp(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/);
                        const validExtensions = ['json', 'zip', 'txt', 'tsv', 'gz', 'csv', 'h5', 'npy'];
                        if (this.isSubmissionUsingUrl) {
                          if (regex.test(inputValue)) {

                    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

                    Avoid deeply nested control flow statements.
                    Open

                                if (attribute.value === null || attribute.value === undefined) {
                                  metaValue = false;
                                }

                      Avoid deeply nested control flow statements.
                      Open

                                  if (value === null || value === undefined || value.length === 0) {
                                    metaValue = false;
                                  }

                        Function storeMetadata has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                          storeMetadata(data) {
                            for (let i = 0; i < data.count; i++) {
                              if (data.results[i].submission_meta_attributes) {
                                const attributes = data.results[i].submission_meta_attributes;
                                attributes.forEach(function (attribute) {

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

                          countDownTimer(SELF, eachPhase) {
                            if (!SELF.isClockStarted) {
                              SELF.remainingTime = parseInt(eachPhase.limits.remaining_time, 10);
                            }
                            SELF.days = Math.floor(SELF.remainingTime / 24 / 60 / 60);

                        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

                        Avoid too many return statements within this function.
                        Open

                              return;

                          Avoid too many return statements within this function.
                          Open

                                return;

                            Identical blocks of code found in 2 locations. Consider refactoring.
                            Open

                              copyTextToClipboard(ref: HTMLElement) {
                                const textBox = document.createElement('textarea');
                                textBox.style.position = 'fixed';
                                textBox.style.left = '0';
                                textBox.style.top = '0';
                            frontend_v2/src/app/components/utility/modal/modal.component.ts on lines 268..282

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

                            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

                              constructor(
                                private authService: AuthService,
                                private router: Router,
                                private route: ActivatedRoute,
                                private challengeService: ChallengeService,
                            frontend_v2/src/app/components/challenge/challengeleaderboard/challengeleaderboard.component.ts on lines 225..234

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

                            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

                                const PARAMS = {
                                  title: 'Edit Submission Guidelines',
                                  label: 'submission_guidelines',
                                  isEditorRequired: true,
                                  editorContent: this.challenge.submission_guidelines,
                            frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts on lines 635..643

                            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