cherfia/chromiumly

View on GitHub

Showing 32 of 32 total issues

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

    public static addPageProperties(
        data: FormData,
        pageProperties: PageProperties
    ): void {
        if (pageProperties.singlePage) {
Severity: Minor
Found in src/chromium/utils/converter.utils.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 capture has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async capture({
        html,
        assets,
        header,
        footer,
Severity: Minor
Found in src/chromium/screenshots/html.screenshot.ts - About 1 hr to fix

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

        public static addPageProperties(
            data: FormData,
            pageProperties: PageProperties
        ): void {
            if (pageProperties.landscape) {
    Severity: Minor
    Found in src/libre-office/utils/libre-office.utils.ts - About 1 hr to fix

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

              if (assets?.length) {
                  await Promise.all(
                      assets.map(({ file, name }) =>
                          GotenbergUtils.addFile(data, file, name)
                      )
      Severity: Major
      Found in src/chromium/screenshots/html.screenshot.ts and 1 other location - About 1 hr to fix
      src/chromium/converters/html.converter.ts on lines 101..107

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

      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

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

              if (assets?.length) {
                  await Promise.all(
                      assets.map(({ file, name }) =>
                          GotenbergUtils.addFile(data, file, name)
                      )
      Severity: Major
      Found in src/chromium/converters/html.converter.ts and 1 other location - About 1 hr to fix
      src/chromium/screenshots/html.screenshot.ts on lines 76..82

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

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

          public static addImageProperties(
              data: FormData,
              imageProperties: ImageProperties
          ): void {
              data.append('format', imageProperties.format);
      Severity: Minor
      Found in src/chromium/utils/screenshot.utils.ts - About 1 hr to fix

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

            async convert({
                url,
                header,
                footer,
                properties,
        Severity: Minor
        Found in src/chromium/converters/url.converter.ts - About 1 hr to fix

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

              async convert({
                  html,
                  markdown,
                  header,
                  footer,
          Severity: Minor
          Found in src/chromium/converters/markdown.converter.ts - About 1 hr to fix

            Function addFiles has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public static async addFiles(
                    files: PathLikeOrReadStream[],
                    data: FormData
                ) {
                    for (const [key, file] of files.entries()) {
            Severity: Minor
            Found in src/pdf-engines/utils/pdf-engines.utils.ts - About 55 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

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

                static get username(): string | undefined {
                    const hasUsername = config.has('gotenberg.api.basicAuth.username');
                    return hasUsername
                        ? config.get<string>('gotenberg.api.basicAuth.username')
                        : process.env.GOTENBERG_API_BASIC_AUTH_USERNAME;
            Severity: Minor
            Found in src/gotenberg.ts and 1 other location - About 40 mins to fix
            src/gotenberg.ts on lines 48..53

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

            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

                static get password(): string | undefined {
                    const hasPassword = config.has('gotenberg.api.basicAuth.password');
                    return hasPassword
                        ? config.get<string>('gotenberg.api.basicAuth.password')
                        : process.env.GOTENBERG_API_BASIC_AUTH_PASSWORD;
            Severity: Minor
            Found in src/gotenberg.ts and 1 other location - About 40 mins to fix
            src/gotenberg.ts on lines 37..42

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

            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 addImageProperties has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public static addImageProperties(
                    data: FormData,
                    imageProperties: ImageProperties
                ): void {
                    data.append('format', imageProperties.format);
            Severity: Minor
            Found in src/chromium/utils/screenshot.utils.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