jiahaog/nativefier

View on GitHub

Showing 148 of 148 total issues

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

export function isUrlShellSafe(
  urlToGo: string,
): { blocked: false } | { blocked: true; reason: string } {
  let url: URL;
  try {
Severity: Minor
Found in app/src/helpers/helpers.ts - About 1 hr to fix

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

      const looksLikeWindows =
        children.filter((c) => c.name.toLowerCase().endsWith('.exe') && c.isFile())
          .length > 0;
    Severity: Major
    Found in src/helpers/upgrade/executableHelpers.ts and 1 other location - About 1 hr to fix
    src/helpers/upgrade/executableHelpers.ts on lines 98..100

    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

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

          window.webContents.session.webRequest.send('onResponseStarted', {
            responseHeaders,
            webContents: window.webContents,
            resourceType,
            url: `test-${resourceType}`,
    Severity: Major
    Found in app/src/helpers/windowHelpers.test.ts and 1 other location - About 1 hr to fix
    app/src/helpers/windowHelpers.test.ts on lines 283..288

    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

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

      const looksLikeLinux =
        children.filter((c) => c.name.toLowerCase().endsWith('.so') && c.isFile())
          .length > 0;
    Severity: Major
    Found in src/helpers/upgrade/executableHelpers.ts and 1 other location - About 1 hr to fix
    src/helpers/upgrade/executableHelpers.ts on lines 95..97

    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

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

          window.webContents.session.webRequest.send('onResponseStarted', {
            responseHeaders,
            webContents: window.webContents,
            resourceType,
            url: `test-${resourceType}`,
    Severity: Major
    Found in app/src/helpers/windowHelpers.test.ts and 1 other location - About 1 hr to fix
    app/src/helpers/windowHelpers.test.ts on lines 252..257

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

    export function injectCSS(browserWindow: BrowserWindow): void {
      const cssToInject = getCSSToInject();
    
      if (!cssToInject) {
        return;
    Severity: Minor
    Found in app/src/helpers/windowHelpers.ts - About 1 hr to fix

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

      function setupScreenSharePickerElement(
        id: string,
        sources: Electron.DesktopCapturerSource[],
      ): void {
        const selectionElem = document.createElement('div');
      Severity: Minor
      Found in app/src/preload.ts - About 1 hr to fix

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

            const jsFiles = fs
              .readdirSync(INJECT_DIR, { withFileTypes: true })
              .filter(
                (injectFile) => injectFile.isFile() && injectFile.name.endsWith('.js'),
              )
        Severity: Major
        Found in app/src/preload.ts and 1 other location - About 1 hr to fix
        app/src/helpers/helpers.ts on lines 160..167

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

        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 cssFiles = fs
            .readdirSync(INJECT_DIR, { withFileTypes: true })
            .filter(
              (injectFile) => injectFile.isFile() && injectFile.name.endsWith('.css'),
            )
        Severity: Major
        Found in app/src/helpers/helpers.ts and 1 other location - About 1 hr to fix
        app/src/preload.ts on lines 301..306

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

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

        async function copyIconsIfNecessary(
          options: AppOptions,
          appPath: string,
        ): Promise<void> {
          log.debug('Copying icons if necessary');
        Severity: Minor
        Found in src/build/buildNativefierApp.ts - About 1 hr to fix

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

          function setupCloseEvent(options: OutputOptions, window: BrowserWindow): void {
            window.on('close', (event: Event) => {
              log.debug('mainWindow.close', event);
              if (window.isFullScreen()) {
                if (nativeTabsSupported()) {
          Severity: Minor
          Found in app/src/components/mainWindow.ts - About 1 hr to fix

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

            export function getVersionString(
              executablePath: string,
              versionString: string,
            ): string | undefined {
              let rcedit = path.resolve(
            Severity: Minor
            Found in src/helpers/upgrade/rceditGet.ts - About 1 hr to fix

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

                  if (!isJsonString) {
                    expect(args[arg]).toBe(value);
                  } else {
                    expect(args[arg]).toEqual(parseJson(value));
                  }
              Severity: Major
              Found in src/cli.test.ts and 1 other location - About 1 hr to fix
              src/cli.test.ts on lines 155..159

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

              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 (!isJsonString) {
                      expect(argsShort[arg]).toBe(value);
                    } else {
                      expect(argsShort[arg]).toEqual(parseJson(value));
                    }
              Severity: Major
              Found in src/cli.test.ts and 1 other location - About 1 hr to fix
              src/cli.test.ts on lines 145..149

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

              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

                test('potentially-malicious urls *should* be blocked', async () => {
                  await openExternal('https://hello.com/wor%00ld');
              
                  expect(mockShowNavigationBlockedMessage).toHaveBeenCalledTimes(1);
                  expect(mockShellOpenExternal).not.toHaveBeenCalled();
              Severity: Major
              Found in app/src/helpers/helpers.test.ts and 2 other locations - About 1 hr to fix
              app/src/helpers/helpers.test.ts on lines 328..333
              app/src/helpers/helpers.test.ts on lines 342..347

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

              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

                test('malformed urls *should* be blocked', async () => {
                  await openExternal('zombocom');
              
                  expect(mockShowNavigationBlockedMessage).toHaveBeenCalledTimes(1);
                  expect(mockShellOpenExternal).not.toHaveBeenCalled();
              Severity: Major
              Found in app/src/helpers/helpers.test.ts and 2 other locations - About 1 hr to fix
              app/src/helpers/helpers.test.ts on lines 328..333
              app/src/helpers/helpers.test.ts on lines 335..340

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

              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

                test('urls with non-allowlisted scheme *should* be blocked', async () => {
                  await openExternal('barf://whatever.foo');
              
                  expect(mockShowNavigationBlockedMessage).toHaveBeenCalledTimes(1);
                  expect(mockShellOpenExternal).not.toHaveBeenCalled();
              Severity: Major
              Found in app/src/helpers/helpers.test.ts and 2 other locations - About 1 hr to fix
              app/src/helpers/helpers.test.ts on lines 335..340
              app/src/helpers/helpers.test.ts on lines 342..347

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

              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('https urls scheme should *not* be blocked', async () => {
                  await openExternal('https://whatever.foo');
              
                  expect(mockShowNavigationBlockedMessage).not.toHaveBeenCalled();
                  expect(mockShellOpenExternal).toHaveBeenCalled();
              Severity: Minor
              Found in app/src/helpers/helpers.test.ts and 1 other location - About 55 mins to fix
              app/src/helpers/helpers.test.ts on lines 321..326

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

              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('urls with whitelisted scheme should *not* be blocked', async () => {
                  await openExternal('ircs://irc.libera.chat/whatever');
              
                  expect(mockShowNavigationBlockedMessage).not.toHaveBeenCalled();
                  expect(mockShellOpenExternal).toHaveBeenCalled();
              Severity: Minor
              Found in app/src/helpers/helpers.test.ts and 1 other location - About 55 mins to fix
              app/src/helpers/helpers.test.ts on lines 314..319

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

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

              export function onNewWindowHelper(
                options: WindowOptions,
                setupWindow: (options: WindowOptions, window: BrowserWindow) => void,
                details: HandlerDetails,
                parent?: BrowserWindow,
              Severity: Minor
              Found in app/src/helpers/windowEvents.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

              Severity
              Category
              Status
              Source
              Language