open-learning-exchange/planet

View on GitHub

Showing 58 of 299 total issues

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

import { Component, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { CouchService } from '../shared/couchdb.service';
import { ValidatorService } from '../validators/validator.service';
import { PlanetMessageService } from '../shared/planet-message.service';
Severity: Minor
Found in src/app/configuration/configuration.component.ts - About 2 hrs to fix

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

    import { Component, OnInit, ViewChild, AfterViewInit, Input, EventEmitter, Output, HostListener } from '@angular/core';
    import { MatDialog } from '@angular/material/dialog';
    import { MatPaginator } from '@angular/material/paginator';
    import { MatSort } from '@angular/material/sort';
    import { MatTableDataSource } from '@angular/material/table';
    Severity: Minor
    Found in src/app/teams/teams.component.ts - About 2 hrs to fix

      CommunityComponent has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      @Component({
        selector: 'planet-community',
        templateUrl: './community.component.html',
        preserveWhitespaces: true,
        styleUrls: [ './community.scss' ],
      Severity: Minor
      Found in src/app/community/community.component.ts - About 2 hrs to fix

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

        import { Component, OnInit, ViewChild, AfterViewInit, OnDestroy } from '@angular/core';
        import { Router, ActivatedRoute } from '@angular/router';
        import { FormGroup } from '@angular/forms';
        import { MatDialog, MatDialogRef } from '@angular/material/dialog';
        import { MatPaginator, PageEvent } from '@angular/material/paginator';
        Severity: Minor
        Found in src/app/surveys/surveys.component.ts - About 2 hrs to fix

          SurveysComponent has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          @Component({
            templateUrl: './surveys.component.html',
            styleUrls: [ './surveys.component.scss' ]
          })
          export class SurveysComponent implements OnInit, AfterViewInit, OnDestroy {
          Severity: Minor
          Found in src/app/surveys/surveys.component.ts - About 2 hrs to fix

            CoursesAddComponent has 21 functions (exceeds 20 allowed). Consider refactoring.
            Open

            @Component({
              templateUrl: 'courses-add.component.html',
              styleUrls: [ './courses-add.scss' ]
            })
            export class CoursesAddComponent implements OnInit, OnDestroy {
            Severity: Minor
            Found in src/app/courses/add-courses/courses-add.component.ts - About 2 hrs to fix

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

              import { Injectable } from '@angular/core';
              import { CouchService } from './couchdb.service';
              import { catchError, switchMap, map, tap } from 'rxjs/operators';
              import { of, Observable, Subject, BehaviorSubject, forkJoin } from 'rxjs';
              import { findDocuments } from '../shared/mangoQueries';
              Severity: Minor
              Found in src/app/shared/user.service.ts - About 2 hrs to fix

                Function validate_doc_update has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                  function (newDoc, oldDoc, userCtx, secObj) {
                    function require(field) {
                      var errMessage = field + ' is required';
                      if (!newDoc[field]) {
                        throw { forbidden: errMessage };
                Severity: Minor
                Found in design/nations/nation-validators.js - About 2 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 aiChatNonStream has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export async function aiChatNonStream(
                  messages: ChatMessage[],
                  aiProvider: AIProvider,
                  assistant: boolean,
                  context: any = '',
                Severity: Minor
                Found in chatapi/src/utils/chat-helpers.utils.ts - About 1 hr to fix

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

                    constructor(
                      iconRegistry: MatIconRegistry,
                      sanitizer: DomSanitizer,
                      public router: Router,
                      private stateService: StateService
                  Severity: Minor
                  Found in src/app/app.component.ts - About 1 hr to fix

                    Function aiChatStream has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export async function aiChatStream(
                      messages: ChatMessage[],
                      aiProvider: AIProvider,
                      assistant: boolean,
                      callback?: (response: string) => void
                    Severity: Minor
                    Found in chatapi/src/utils/chat-helpers.utils.ts - About 1 hr to fix

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

                        ngOnInit() {
                          this.myPlanets.sortingDataAccessor = (item: any, property) => {
                            switch (property) {
                              case 'versionName': return (item.versionName || item.version || '').split('.').reduce((v, n) => v + n.padStart(3, '0'), '');
                              case 'name': return (item.customDeviceName || item.deviceName || '').toLowerCase();
                      Severity: Minor
                      Found in src/app/manager-dashboard/reports/myplanet-table.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 createAndHandleRunWithStreaming has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export async function createAndHandleRunWithStreaming(
                        threadID: any, assistantID: any, callback?: (response: string) => void
                      ): Promise<string> {
                        let completionText = '';
                      
                      
                      Severity: Minor
                      Found in chatapi/src/utils/chat-assistant.utils.ts - About 1 hr to fix

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

                        export async function chat(data: any, stream?: boolean, callback?: (response: string) => void): Promise<{
                          completionText: string;
                          couchSaveResponse: DocumentInsertResponse;
                        } | undefined> {
                          const { content, ...dbData } = data;
                        Severity: Minor
                        Found in chatapi/src/services/chat.service.ts - About 1 hr to fix

                          Function openExportDialog has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            openExportDialog(reportType: 'logins' | 'resourceViews' | 'courseViews' | 'summary' | 'health' | 'stepCompletions') {
                              const minDate = new Date(this.activityService.minTime(this.loginActivities.data, 'loginTime')).setHours(0, 0, 0, 0);
                              const commonProps = { 'type': 'date', 'required': true, 'min': new Date(minDate), 'max': new Date(this.today) };
                              const teamOptions = [
                                { name: $localize`All Members`, value: 'All' },
                          Severity: Minor
                          Found in src/app/manager-dashboard/reports/reports-detail.component.ts - About 1 hr to fix

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

                              ngOnInit() {
                                this.setMode();
                                this.onFilterChange(this.route.snapshot.paramMap.get('type') || 'exam', 'type');
                                if (this.mode === 'survey') {
                                  this.onFilterChange('survey', 'type');
                            Severity: Minor
                            Found in src/app/submissions/submissions.component.ts - About 1 hr to fix

                              Function createConfigurationDocs has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                createConfigurationDocs() {
                                  const {
                                    confirmPassword,
                                    ...credentials
                                  } = this.loginForm.value;
                              Severity: Minor
                              Found in src/app/configuration/configuration.component.ts - About 1 hr to fix

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

                                  generatePDF() {
                                    const formattedBirthDate = format(new Date(this.user.birthDate), 'MMM d, y');
                                    let contentArray = [
                                      {
                                        text: $localize`${`${this.user.firstName}'s achievements`}`,
                                Severity: Minor
                                Found in src/app/users/users-achievements/users-achievements.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 exportCSV has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  exportCSV(reportType: string, dateRange: { startDate: Date, endDate: Date }, members: any[], sortBy: string) {
                                    switch (reportType) {
                                      case 'logins':
                                        let data = filterByMember(filterByDate(this.loginActivities.data, 'loginTime', dateRange), members)
                                          .map(activity => ({
                                Severity: Minor
                                Found in src/app/manager-dashboard/reports/reports-detail.component.ts - About 1 hr to fix

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

                                    ngOnInit() {
                                      if (this.myView !== 'myPersonals') {
                                        this.displayedColumns = [ 'select', ...this.displayedColumns, 'rating' ];
                                      }
                                      this.titleSearch = '';
                                  Severity: Minor
                                  Found in src/app/resources/resources.component.ts - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language