emilepharand/Babilonia

View on GitHub

Showing 15 of 50 total issues

Function performAssertions has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function performAssertions(userDbPath: string) {
    const userDbHandler = new DatabaseHandler(userDbPath);
    try {
        const userDb = await userDbHandler.open();
        const languageManager = new LanguageManager(userDb);
Severity: Major
Found in tests/integration/guid.ts - About 2 hrs to fix

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

        private async getAllLanguageStats(): Promise<LanguageStats[]> {
            const query = `
                with totalExpressions as (select
                languages.id as languageId,
                count(languageId) as totalExpressionsCount
    Severity: Major
    Found in server/stats/statsCounter.ts - About 2 hrs to fix

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

      export function addLanguages() {
          const languageNames = [
              'français',
              'english',
              'español',
      Severity: Minor
      Found in tests/e2e/cy-utils.ts - About 1 hr to fix

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

        async function fillDatabasePreviousVersion(previousDb: Database) {
            await clearDatabaseAndCreateSchema(previousDb);
        
            const languageManager = new LanguageManager(previousDb);
            const ideaManager = new IdeaManager(previousDb, languageManager);
        Severity: Minor
        Found in tests/integration/guid.ts - About 1 hr to fix

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

          export function validateContextParentheses(ee: ExpressionForAdding[]) {
              for (const e of ee) {
                  const contexts = e.text.match(/\([^)(]*\)/g) ?? [];
                  // No context is empty
                  if (contexts.some(x => x.substring(1, x.length - 1).trim().length === 0)) {
          Severity: Minor
          Found in server/model/inputValidator.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 editAndTest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export async function editAndTest(
              newLanguage1: Language,
              newLanguage2: Language,
              changes: boolean,
          ): Promise<void> {
          Severity: Minor
          Found in tests/api/languages/utils.ts - About 1 hr to fix

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

                public init(): void {
                    this.app.use('/', this.router);
                    if (process.env.TEST_MODE) {
                        // Signals that the server is running in tests
                        this.router.get('/', (_, res) => {
            Severity: Minor
            Found in server/routes.ts - About 1 hr to fix

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

              export async function validateIdea(responseIdea: Idea, ideaForAdding: IdeaForAdding, expressionsInOrder?: ExpressionForAdding[]): Promise<void> {
                  expect(validate(responseIdea)).toEqual(true);
              
                  const r = await FetchUtils.fetchIdea(responseIdea.id);
                  const fetchedIdea = (await r.json()) as Idea;
              Severity: Minor
              Found in tests/api/ideas/utils.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

              Avoid too many return statements within this function.
              Open

                          return false;
              Severity: Major
              Found in server/model/inputValidator.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return validateContextParentheses(ideaForAdding.ee);
                Severity: Major
                Found in server/model/inputValidator.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return false;
                  Severity: Major
                  Found in server/model/inputValidator.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return false;
                    Severity: Major
                    Found in server/model/inputValidator.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return InputValidator.isValidOrdering(ll.map(l => l.ordering));
                      Severity: Major
                      Found in server/model/inputValidator.ts - About 30 mins to fix

                        Function validateLanguagesForEditing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public async validateLanguagesForEditing(toValidate: unknown): Promise<boolean> {
                                // Object is an array
                                if (!Array.isArray(toValidate)) {
                                    return false;
                                }
                        Severity: Minor
                        Found in server/model/inputValidator.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

                        Function testAllGuidsDefinedOrNot has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        async function testAllGuidsDefinedOrNot(databasePath: string, defined: boolean) {
                            const dbHandler = new DatabaseHandler(databasePath);
                            try {
                                const db = await dbHandler.open();
                                const ideasQuery = async () => db.all(`SELECT * FROM ideas where guid is ${defined ? '' : 'not'} null`);
                        Severity: Minor
                        Found in tests/api/database/database.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