jiahaog/nativefier

View on GitHub

Showing 51 of 51 total issues

Function pickElectronAppArgs has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function pickElectronAppArgs(options: AppOptions): any {
  return {
    alwaysOnTop: options.nativefier.alwaysOnTop,
    appCopyright: options.packager.appCopyright,
    appVersion: options.packager.appVersion,
Severity: Major
Found in src/build/prepareElectronApp.ts - About 2 hrs to fix

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

    export function createTrayIcon(
      nativefierOptions,
      mainWindow: BrowserWindow,
    ): Tray {
      const options = { ...nativefierOptions };
    Severity: Minor
    Found in app/src/components/trayIcon.ts - About 1 hr to fix

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

      export async function convertIconIfNecessary(
        options: AppOptions,
      ): Promise<void> {
        if (!options.packager.icon) {
          log.debug('Option "icon" not set, skipping icon conversion.');
      Severity: Minor
      Found in src/build/buildIcon.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 findSync has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function findSync(
        pattern: RegExp,
        basePath: string,
        limitSearchToDirectories = false,
      ): string[] {
      Severity: Minor
      Found in app/src/helpers/inferFlash.ts - About 1 hr to fix

        Function onNewWindowHelper has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          urlToGo: string,
          disposition,
          targetUrl: string,
          internalUrls,
          preventDefault,
        Severity: Major
        Found in app/src/components/mainWindowHelpers.ts - About 1 hr to fix

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

          export function initContextMenu(createNewWindow, createNewTab): void {
            contextMenu({
              prepend: (actions, params) => {
                const items = [];
                if (params.linkURL) {
          Severity: Minor
          Found in app/src/components/contextMenu.ts - About 1 hr to fix

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

            async function iconShellHelper(
              shellScriptPath: string,
              icoSource: string,
              icoDestination: string,
            ): Promise<string> {
            Severity: Minor
            Found in src/helpers/iconShellHelpers.ts - About 1 hr to fix

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

                (function findSyncRecurse(base) {
                  let children: string[];
                  try {
                    children = fs.readdirSync(base);
                  } catch (err) {
              Severity: Minor
              Found in app/src/helpers/inferFlash.ts - About 1 hr to fix

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

                async function maybeCopyScripts(srcs: string[], dest: string): Promise<void> {
                  if (!srcs || srcs.length === 0) {
                    log.debug('No files to inject, skipping copy.');
                    return;
                  }
                Severity: Minor
                Found in src/build/prepareElectronApp.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 3 locations. Consider refactoring.
                Open

                    case 'darwin':
                      formats.push('.icns');
                      if (pngToIcns) {
                        formats.push('.png');
                      }
                Severity: Major
                Found in src/helpers/helpers.ts and 2 other locations - About 50 mins to fix
                src/helpers/helpers.ts on lines 118..126
                src/helpers/helpers.ts on lines 127..135

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

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

                    case 'win32':
                      formats.push('.ico');
                      if (pngToIco) {
                        formats.push('.png');
                      }
                Severity: Major
                Found in src/helpers/helpers.ts and 2 other locations - About 50 mins to fix
                src/helpers/helpers.ts on lines 109..117
                src/helpers/helpers.ts on lines 118..126

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

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

                    case 'linux':
                      formats.push('.png');
                      if (icoToPng) {
                        formats.push('.ico');
                      }
                Severity: Major
                Found in src/helpers/helpers.ts and 2 other locations - About 50 mins to fix
                src/helpers/helpers.ts on lines 109..117
                src/helpers/helpers.ts on lines 127..135

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

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

                export async function convertToIco(icoSrc: string): Promise<string> {
                  return iconShellHelper(
                    SCRIPT_PATHS.convertToIco,
                    icoSrc,
                    `${getTempDir('iconconv')}/icon.ico`,
                Severity: Major
                Found in src/helpers/iconShellHelpers.ts and 2 other locations - About 50 mins to fix
                src/helpers/iconShellHelpers.ts on lines 55..61
                src/helpers/iconShellHelpers.ts on lines 63..69

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

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

                export async function convertToPng(icoSrc: string): Promise<string> {
                  return iconShellHelper(
                    SCRIPT_PATHS.convertToPng,
                    icoSrc,
                    `${getTempDir('iconconv')}/icon.png`,
                Severity: Major
                Found in src/helpers/iconShellHelpers.ts and 2 other locations - About 50 mins to fix
                src/helpers/iconShellHelpers.ts on lines 55..61
                src/helpers/iconShellHelpers.ts on lines 71..77

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

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

                export function singleIco(icoSrc: string): Promise<string> {
                  return iconShellHelper(
                    SCRIPT_PATHS.singleIco,
                    icoSrc,
                    `${getTempDir('iconconv')}/icon.ico`,
                Severity: Major
                Found in src/helpers/iconShellHelpers.ts and 2 other locations - About 50 mins to fix
                src/helpers/iconShellHelpers.ts on lines 63..69
                src/helpers/iconShellHelpers.ts on lines 71..77

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

                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

                  if (options.nativefier.width > options.nativefier.maxWidth) {
                    options.nativefier.width = options.nativefier.maxWidth;
                  }
                Severity: Minor
                Found in src/options/optionsMain.ts and 1 other location - About 45 mins to fix
                src/options/optionsMain.ts on lines 152..154

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

                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

                  test('it should call sanitize filename', async () => {
                    const result = await name(NAME_PARAMS_PROVIDED);
                
                    expect(sanitizeFilename).toHaveBeenCalledWith(
                      NAME_PARAMS_PROVIDED.packager.platform,
                Severity: Minor
                Found in src/options/fields/name.test.ts and 1 other location - About 45 mins to fix
                src/options/fields/name.test.ts on lines 69..75

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

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

                export function createTrayIcon(
                  nativefierOptions,
                  mainWindow: BrowserWindow,
                ): Tray {
                  const options = { ...nativefierOptions };
                Severity: Minor
                Found in app/src/components/trayIcon.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

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

                  test('it should call sanitize filename', async () => {
                    const result = await name(params);
                    expect(sanitizeFilename).toHaveBeenCalledWith(
                      params.packager.platform,
                      result,
                Severity: Minor
                Found in src/options/fields/name.test.ts and 1 other location - About 45 mins to fix
                src/options/fields/name.test.ts on lines 38..45

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

                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

                  if (options.nativefier.height > options.nativefier.maxHeight) {
                    options.nativefier.height = options.nativefier.maxHeight;
                  }
                Severity: Minor
                Found in src/options/optionsMain.ts and 1 other location - About 45 mins to fix
                src/options/optionsMain.ts on lines 148..150

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

                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

                Severity
                Category
                Status
                Source
                Language