Cloud-CV/EvalAI

View on GitHub
frontend_v2/src/app/components/utility/modal/modal.component.ts

Summary

Maintainability
F
5 days
Test Coverage

Function validateModalInput has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

  validateModalInput(e) {
    this.inputErrorMessage = '';
    if (e.target.name === 'challegenDeleteInput') {
      this.isDisabled = e.target.value !== this.challenge.title;
    } else if (e.target.name === 'editChallengeTitle') {
Severity: Minor
Found in frontend_v2/src/app/components/utility/modal/modal.component.ts - About 5 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

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

  ngOnInit() {
    if (this.params) {
      if (this.params['title']) {
        this.title = this.params['title'];
      }
Severity: Minor
Found in frontend_v2/src/app/components/utility/modal/modal.component.ts - About 4 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

Function validateModalInput has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  validateModalInput(e) {
    this.inputErrorMessage = '';
    if (e.target.name === 'challegenDeleteInput') {
      this.isDisabled = e.target.value !== this.challenge.title;
    } else if (e.target.name === 'editChallengeTitle') {
Severity: Major
Found in frontend_v2/src/app/components/utility/modal/modal.component.ts - About 2 hrs to fix

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

      ngOnInit() {
        if (this.params) {
          if (this.params['title']) {
            this.title = this.params['title'];
          }
    Severity: Major
    Found in frontend_v2/src/app/components/utility/modal/modal.component.ts - About 2 hrs to fix

      Avoid deeply nested control flow statements.
      Open

              if (!this.invalidFields.find((element) => element === 'LinkedIn')) {
                this.invalidFields.push('LinkedIn');
              }
      Severity: Major
      Found in frontend_v2/src/app/components/utility/modal/modal.component.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

            } else if (e.target.name === 'new_password2') {
              this.retype_newPassword = e.target.value;
              if (e.target.value !== this.newPassword) {
                this.inputErrorMessage = 'Password do not match';
              }
        Severity: Major
        Found in frontend_v2/src/app/components/utility/modal/modal.component.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                if (e.target.value === this.oldPassword) {
                  this.inputErrorMessage = 'Old password cannot be same as New Password';
                }
          Severity: Major
          Found in frontend_v2/src/app/components/utility/modal/modal.component.ts - About 45 mins to fix

            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/challenge/challengesubmit/challengesubmit.component.ts on lines 636..650

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

                } else if (e.target.name === 'update_google_scholar_url') {
                  if (this.validURL(e.target.value) || e.target.value === '') {
                    this.isDisabled = false;
            
                    this.invalidFields = this.invalidFields.filter((element) => element !== 'Google Scholar');
            frontend_v2/src/app/components/utility/modal/modal.component.ts on lines 336..370
            frontend_v2/src/app/components/utility/modal/modal.component.ts on lines 347..370

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

            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

                } else if (e.target.name === 'update_github_url') {
                  if (this.validURL(e.target.value) || e.target.value === '') {
                    this.isDisabled = false;
            
                    this.invalidFields = this.invalidFields.filter((element) => element !== 'GitHub');
            frontend_v2/src/app/components/utility/modal/modal.component.ts on lines 325..370
            frontend_v2/src/app/components/utility/modal/modal.component.ts on lines 347..370

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

            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

                } else if (e.target.name === 'update_linkedin_url') {
                  if (this.validURL(e.target.value) || e.target.value === '') {
                    this.isDisabled = false;
            
                    this.invalidFields = this.invalidFields.filter((element) => element !== 'LinkedIn');
            frontend_v2/src/app/components/utility/modal/modal.component.ts on lines 325..370
            frontend_v2/src/app/components/utility/modal/modal.component.ts on lines 336..370

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

            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 (e.target.name === 'new_password1') {
                  this.newPassword = e.target.value;
                  if (e.target.value === this.oldPassword) {
                    this.inputErrorMessage = 'Old password cannot be same as New Password';
                  }
            frontend_v2/src/app/components/utility/modal/modal.component.ts on lines 365..370

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

            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 (e.target.name === 'new_password2') {
                  this.retype_newPassword = e.target.value;
                  if (e.target.value !== this.newPassword) {
                    this.inputErrorMessage = 'Password do not match';
                  }
            frontend_v2/src/app/components/utility/modal/modal.component.ts on lines 360..370

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

            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