presidential-innovation-fellows/code-gov-web

View on GitHub

Showing 14 of 125 total issues

File base-filter-page.component.ts has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { JsonPipe } from '@angular/common';
import { ChangeDetectorRef, Component, ElementRef, ViewEncapsulation } from '@angular/core';
import { DomSanitizer, SafeStyle } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Observable';
Severity: Minor
Found in src/app/components/base-filter-page/base-filter-page.component.ts - About 2 hrs to fix

    Function upgradeToPermissions has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      upgradeToPermissions(project) {
        project.permissions = {};
    
        project.permissions.licenses = [];
    
    
    Severity: Major
    Found in src/app/components/tools/upgrade-schema/upgrade-schema.component.ts - About 2 hrs to fix

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

        ngOnInit() {
          this.eventSub = this.route.params.subscribe(params => {
            let id = params['id'];
            if (id === 'All') {
              this.agency = { acronym: 'All', name: 'All' };
      Severity: Minor
      Found in src/app/components/explore-code/agency/agency.component.ts - About 1 hr to fix

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

            this.eventSub = this.route.params.subscribe(params => {
              let id = params['id'];
              if (id === 'All') {
                this.agency = { acronym: 'All', name: 'All' };
                this.repos = [];
        Severity: Minor
        Found in src/app/components/explore-code/agency/agency.component.ts - About 1 hr to fix

          Function sortResults has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public sortResults() {
              switch (this.selectedSortOption) {
                case 'A-Z':
                  this.finalResults.sort((a, b) => a.name.trim() < b.name.trim() ? -1 : 1);
                  break;
          Severity: Minor
          Found in src/app/components/base-filter-page/base-filter-page.component.ts - About 1 hr to fix

            Function _setRequirementStatuses has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              _setRequirementStatuses(agencyRequirements) {
                let requirements = [];
                let overallStatus = 'noncompliant';
            
                for (let requirement in agencyRequirements) {

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

              ngOnInit() {
                this.bannerImage = this.sanitizer.bypassSecurityTrustStyle(`url('${images.background}')`);
            
                this.stateService.set('section', 'browse-projects');
            
            
            Severity: Minor
            Found in src/app/components/browse-projects/browse-projects.component.ts - About 1 hr to fix

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

                getStatuses() {
                  this.statusesSub = this.clientService.getStatuses().
                    subscribe((result) => {
                      if (result) {
                        for (let statusAgency in result.statuses) {

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

                getStatuses() {
                  this.statusesSub = this.clientService.getStatuses().
                    subscribe((result) => {
                      if (result) {
                        for (let statusAgency in result.statuses) {

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

                      (response: any) => {
                        if (this.isLoading) {
                          const initialAgencies = response.agencies ? response.agencies.split(',') : [];
                          this.queryValue = ''; // blank for all repos
                          this.clientService.search(this.queryValue, 10000).subscribe(data => {
                Severity: Minor
                Found in src/app/components/browse-projects/browse-projects.component.ts - About 1 hr to fix

                  Function upgradeToPermissions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    upgradeToPermissions(project) {
                      project.permissions = {};
                  
                      project.permissions.licenses = [];
                  
                  
                  Severity: Minor
                  Found in src/app/components/tools/upgrade-schema/upgrade-schema.component.ts - 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 toAbsoluteUrl has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function toAbsoluteUrl(url: string): string {
                    if (url.startsWith('http')) {
                      return url;
                    } else if (url.startsWith('/assets')) {
                      let baseURI = document.head.baseURI;
                  Severity: Minor
                  Found in src/app/utils/urls.ts - About 35 mins 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 displayRepo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    displayRepo(repo) {
                      if (repo.agency.acronym === 'EPA') {
                        try {
                          return repo.permissions.usageType.toLowerCase().startsWith('exempt') === false;
                        } catch (error) {
                  Severity: Minor
                  Found in src/app/components/explore-code/agency/agency.component.ts - About 35 mins 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 filterLicenses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    public filterLicenses(result) {
                      const selectedLicenseIds = this.getFilterBoxValues('License');
                      const selectedLicenseNames = selectedLicenseIds.map(id => licenseIdToName[id]);
                      let selectedLicenses = Array.from(new Set(selectedLicenseIds.concat(selectedLicenseNames)));
                  
                  
                  Severity: Minor
                  Found in src/app/components/base-filter-page/base-filter-page.component.ts - About 25 mins 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

                  Severity
                  Category
                  Status
                  Source
                  Language