kpapadatos/efoodgr

View on GitHub

Showing 29 of 29 total issues

Function default has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

export default function (program: CommanderStatic, s: EFood.Session) {
    session = s;

    program
        .command('addcart')
Severity: Minor
Found in src/commands/addcart.ts - About 6 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 default has 118 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function (program: CommanderStatic, s: EFood.Session) {
    session = s;

    program
        .command('addcart')
Severity: Major
Found in src/commands/addcart.ts - About 4 hrs to fix

    Function consoleHandler has 105 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            .consoleHandler = async () => {
                console.log(`Getting menu items ...`);
    
                const store = await session.getStore();
                const categories = store.menu.categories;
    Severity: Major
    Found in src/commands/addcart.ts - About 4 hrs to fix

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

        constructor(private args: string[]) {
          super();
      
          const { red, cyan, white, green } = chalk;
          const { version } = require('../package');
      Severity: Major
      Found in src/CLI.ts - About 3 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                const response: Models.IAPIResponse = await post({
                    body: this.compileOrder(),
                    headers: { 'x-core-session-id': this.store.sessionId },
                    json: true,
                    uri: `${this.APIEndpoint}/api/v1/order/validate/`
        Severity: Major
        Found in src/classes/Session.ts and 1 other location - About 2 hrs to fix
        src/classes/Session.ts on lines 81..86

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

        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

                const response: Models.IAPIResponse = await post({
                    body: this.compileOrder(),
                    headers: { 'x-core-session-id': this.store.sessionId },
                    json: true,
                    uri: `${this.APIEndpoint}/api/v1/order/submit/`
        Severity: Major
        Found in src/classes/Session.ts and 1 other location - About 2 hrs to fix
        src/classes/Session.ts on lines 179..184

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

        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

        async function handler(storeId: number) {
            console.log(`Setting store to ${c.cyan(storeId.toString())} ...`);
            await session.setStore(storeId);
            console.log(c.green(`Success!`));
        }
        Severity: Major
        Found in src/commands/setstore.ts and 1 other location - About 2 hrs to fix
        src/commands/setaddr.ts on lines 40..44

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

        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

        async function handler(addressId: number) {
            console.log(`Setting user address to ${c.cyan(addressId.toString())} ...`);
            await session.setAddress(addressId);
            console.log(c.green(`Success!`));
        }
        Severity: Major
        Found in src/commands/setaddr.ts and 1 other location - About 2 hrs to fix
        src/commands/setstore.ts on lines 51..55

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

        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

                const response: Models.IAPIResponse = await get({
                    headers: { 'x-core-session-id': this.store.sessionId },
                    json: true,
                    uri: `${this.APIEndpoint}/api/v1/ext/piraeus/methods/`
                }) as Models.IAPIResponse;
        Severity: Major
        Found in src/classes/Session.ts and 1 other location - About 2 hrs to fix
        src/classes/Session.ts on lines 50..54

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

        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

                const response: Models.IAPIResponse = await get({
                    headers: { 'x-core-session-id': this.store.sessionId },
                    json: true,
                    uri: `${this.APIEndpoint}/api/v1/user/clients/address`
                }) as Models.IAPIResponse;
        Severity: Major
        Found in src/classes/Session.ts and 1 other location - About 2 hrs to fix
        src/classes/Session.ts on lines 214..218

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

        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

        Function default has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function (program: CommanderStatic, s: EFood.Session) {
            session = s;
        
            program
                .command('payment')
        Severity: Minor
        Found in src/commands/payment.ts - About 1 hr to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                          const cardInput = await inquirer.prompt([{
                              choices: cards.map((card) => `[${card.card_type}] ${card.card_number}`),
                              message: 'Select a card',
                              name: 'card',
                              type: 'list'
          Severity: Major
          Found in src/commands/payment.ts and 1 other location - About 1 hr to fix
          src/commands/addcart.ts on lines 60..65

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

          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

                          const input = (await inquirer.prompt([{
                              choices: offers.map((o) => `[${o.price}€] ${o.description}`),
                              message: 'Select an offer',
                              name: 'offer',
                              type: 'list'
          Severity: Major
          Found in src/commands/addcart.ts and 1 other location - About 1 hr to fix
          src/commands/payment.ts on lines 50..55

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

          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

          Function constructor has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            constructor(private args: string[]) {
              super();
          
              const { red, cyan, white, green } = chalk;
              const { version } = require('../package');
          Severity: Minor
          Found in src/CLI.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

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          export default function (program: CommanderStatic, s: EFood.Session) {
              session = s;
          
              program
                  .command('ls')
          Severity: Major
          Found in src/commands/ls.ts and 3 other locations - About 1 hr to fix
          src/commands/lscart.ts on lines 7..15
          src/commands/mkorder.ts on lines 7..15
          src/commands/validate.ts on lines 8..16

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

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

          export default function (program: CommanderStatic, s: EFood.Session) {
              session = s;
          
              program
                  .command('lscart')
          Severity: Major
          Found in src/commands/lscart.ts and 3 other locations - About 1 hr to fix
          src/commands/ls.ts on lines 7..15
          src/commands/mkorder.ts on lines 7..15
          src/commands/validate.ts on lines 8..16

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

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

          export default function (program: CommanderStatic, s: EFood.Session) {
              session = s;
          
              program
                  .command('validate')
          Severity: Major
          Found in src/commands/validate.ts and 3 other locations - About 1 hr to fix
          src/commands/ls.ts on lines 7..15
          src/commands/lscart.ts on lines 7..15
          src/commands/mkorder.ts on lines 7..15

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

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

          export default function (program: CommanderStatic, s: EFood.Session) {
              session = s;
          
              program
                  .command('mkorder')
          Severity: Major
          Found in src/commands/mkorder.ts and 3 other locations - About 1 hr to fix
          src/commands/ls.ts on lines 7..15
          src/commands/lscart.ts on lines 7..15
          src/commands/validate.ts on lines 8..16

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

          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

          Function consoleHandler has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  .consoleHandler = async () => {
                      console.log(`Getting payment methods ...`);
          
                      const store = await session.getStore();
                      const choices = [];
          Severity: Minor
          Found in src/commands/payment.ts - About 1 hr to fix

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

                function initEfoodConsole() {
                  console.log(
                    red('\n                  e-food.gr\n') +
                    white(`                    ${version} \n\n`) +
                    green(
            Severity: Minor
            Found in src/CLI.ts - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language