open-learning-exchange/planet

View on GitHub

Showing 58 of 299 total issues

Function validate_doc_update has 30 lines of code (exceeds 25 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 1 hr to fix

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

      ngOnInit() {
        this.titleSearch = '';
        this.getCourses();
        this.userShelf = this.userService.shelf;
        this.courses.filterPredicate = this.filterPredicate;
    Severity: Minor
    Found in src/app/courses/courses.component.ts - About 1 hr to fix

      Function createForm has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        createForm() {
          this.resourceForm = this.fb.group({
            title: [
              '',
              CustomValidators.required,
      Severity: Minor
      Found in src/app/resources/resources-add.component.ts - About 1 hr to fix

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

        module.exports = function (config) {
          config.set({
            basePath: '',
            frameworks: ['jasmine', '@angular-devkit/build-angular'],
            plugins: [
        Severity: Minor
        Found in karma.conf.js - About 1 hr to fix

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

            static endDateValidator(): ValidatorFn {
              let startDate: AbstractControl;
              let endDate: AbstractControl;
          
              // for unsubscribing from Observables
          Severity: Minor
          Found in src/app/validators/custom-validators.ts - About 1 hr to fix

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

              ngOnInit() {
                combineLatest(
                  this.coursesService.courseUpdated$,
                  this.resourcesService.resourcesListener(this.parent),
                  this.stateService.getCouchState('exams', 'local')
            Severity: Minor
            Found in src/app/courses/step-view-courses/courses-step-view.component.ts - About 1 hr to fix

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

                async login({ name, password }: { name: string, password: string }, isCreate: boolean) {
                  const configuration = this.stateService.configuration;
                  const userId = `org.couchdb.user:${name}`;
              
                  try {
              Severity: Minor
              Found in src/app/login/login-form.component.ts - About 1 hr to fix

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

                const initialize = async () => {
                  try {
                    const doc = await getConfig();
                    if (!doc) {
                      console.error('Configuration not found');
                Severity: Minor
                Found in chatapi/src/config/ai-providers.config.ts - About 1 hr to fix

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

                    submitPrompt() {
                      const content = this.promptForm.get('prompt').value;
                      this.data = { ...this.data, content, aiProvider: this.provider };
                  
                      this.setSelectedConversation();
                  Severity: Minor
                  Found in src/app/chat/chat-window/chat-window.component.ts - About 1 hr to fix

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

                      ngOnInit() {
                        this.isLoading = true;
                        this.coursesService.courseUpdated$.pipe(
                          switchMap(({ course, progress = [ { stepNum: 0 } ] }: { course: any, progress: any }) => {
                            this.courseDetail = course;
                    Severity: Minor
                    Found in src/app/courses/view-courses/courses-view.component.ts - About 1 hr to fix

                      Function openEditTransactionDialog has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        openEditTransactionDialog(transaction: any = {}) {
                          this.couchService.currentTime().subscribe((time: number) => {
                            this.dialogsFormService.openDialogsForm(
                              transaction._id ? $localize`Edit Transaction` : $localize`Add Transaction`,
                              [
                      Severity: Minor
                      Found in src/app/teams/teams-view-finances.component.ts - About 1 hr to fix

                        Function exports has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        module.exports = function(timeStamp) {
                          const user = 'e2e_' + timeStamp;
                        
                          return {
                            get: function() {
                        Severity: Minor
                        Found in e2e/userHandler.ts - About 1 hr to fix

                          Function uploadImage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            uploadImage(event) {
                              const file = event.target.files[0];
                          
                              const sanitizedFileName = file.name.trim().replace(/\s+/g, '_');
                              const imageExists = this.images.some(img => sanitizedFileName === img.filename);
                          Severity: Minor
                          Found in src/app/shared/dialogs/dialogs-images.component.ts - About 1 hr to fix

                            Function exportSummary has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              exportSummary(dateRange: any, members: any[], sortBy: string) {
                                const loginData = filterByMember(filterByDate(this.loginActivities?.data, 'loginTime', dateRange), members);
                                const resourceData = filterByMember(filterByDate(this.resourceActivities?.total?.data, 'time', dateRange), members);
                                const courseData = filterByMember(filterByDate(this.courseActivities?.total?.data, 'time', dateRange), members);
                                const progressData = filterByMember(filterByDate(this.progress?.steps?.data, 'time', dateRange), members);
                            Severity: Minor
                            Found in src/app/manager-dashboard/reports/reports-detail.component.ts - About 1 hr to fix

                              Function aiChat has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                messages: ChatMessage[],
                                aiProvider: AIProvider,
                                assistant: boolean,
                                context?: any,
                                stream?: boolean,
                              Severity: Minor
                              Found in chatapi/src/utils/chat.utils.ts - About 45 mins to fix

                                Function chat has a Cognitive Complexity of 8 (exceeds 5 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 45 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 chatNoSave has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                  content: any,
                                  aiProvider: AIProvider,
                                  assistant: boolean,
                                  context?: any,
                                  stream?: boolean,
                                Severity: Minor
                                Found in chatapi/src/services/chat.service.ts - About 45 mins to fix

                                  Function findDocuments has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  export function findDocuments(selectors, fields: any = 0, sort: any = 0, limit = 1000, skip = 0) {
                                  Severity: Minor
                                  Found in src/app/shared/mangoQueries.ts - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language