jiahaog/nativefier

View on GitHub

Showing 148 of 148 total issues

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

    options = {
      nativefier: {
        accessibilityPrompt: false,
        alwaysOnTop: false,
        backgroundColor: undefined,
Severity: Major
Found in src/options/fields/fields.test.ts and 1 other location - About 1 day to fix
src/options/optionsMain.test.ts on lines 7..70

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

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 mockedAsyncConfig: AppOptions = {
  nativefier: {
    accessibilityPrompt: false,
    alwaysOnTop: false,
    backgroundColor: undefined,
Severity: Major
Found in src/options/optionsMain.test.ts and 1 other location - About 1 day to fix
src/options/fields/fields.test.ts on lines 7..70

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

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.each([true, false])(
    'has a fullscreen menu item that toggles simplefullscreen as a fallback on mac',
    (isFullScreen) => {
      mockIsOSX.mockReturnValue(true);
      mockIsFullScreenable.mockReturnValue(false);
Severity: Major
Found in app/src/components/menu.test.ts and 1 other location - About 1 day to fix
app/src/components/menu.test.ts on lines 94..129

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

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.each([true, false])(
    'has a fullscreen menu item that toggles fullscreen',
    (isFullScreen) => {
      mockIsOSX.mockReturnValue(false);
      mockIsFullScreenable.mockReturnValue(true);
Severity: Major
Found in app/src/components/menu.test.ts and 1 other location - About 1 day to fix
app/src/components/menu.test.ts on lines 131..166

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

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

export function generateMenu(
  options: {
    disableDevTools: boolean;
    nativefierVersion: string;
    zoom?: number;
Severity: Major
Found in app/src/components/menu.ts - About 1 day to fix

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

      test('has fullscreen no matter what on mac', () => {
        mockIsOSX.mockReturnValue(true);
        mockIsFullScreenable.mockReturnValue(false);
    
        const menu = generateMenu(
    Severity: Major
    Found in app/src/components/menu.test.ts and 1 other location - About 1 day to fix
    app/src/components/menu.test.ts on lines 40..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 222.

    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('does not have fullscreen if not supported', () => {
        mockIsOSX.mockReturnValue(false);
        mockIsFullScreenable.mockReturnValue(false);
    
        const menu = generateMenu(
    Severity: Major
    Found in app/src/components/menu.test.ts and 1 other location - About 1 day to fix
    app/src/components/menu.test.ts on lines 67..92

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

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

    export async function getOptions(rawOptions: RawOptions): Promise<AppOptions> {
      const options: AppOptions = {
        packager: {
          appCopyright: rawOptions.appCopyright,
          appVersion: rawOptions.appVersion,
    Severity: Major
    Found in src/options/optionsMain.ts - About 1 day to fix

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

        test('background tabs with internal urls should be opened in background tabs', () => {
          mockNativeTabsSupported.mockReturnValue(true);
      
          const result = onNewWindowHelper(baseOptions, setupWindow, {
            url: internalURL,
      Severity: Major
      Found in app/src/helpers/windowEvents.test.ts and 1 other location - About 5 hrs to fix
      app/src/helpers/windowEvents.test.ts on lines 156..175

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

      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('foreground tabs with internal urls should be opened in the foreground', () => {
          mockNativeTabsSupported.mockReturnValue(true);
      
          const result = onNewWindowHelper(baseOptions, setupWindow, {
            url: internalURL,
      Severity: Major
      Found in app/src/helpers/windowEvents.test.ts and 1 other location - About 5 hrs to fix
      app/src/helpers/windowEvents.test.ts on lines 177..196

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

      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

      File menu.ts has 398 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import * as fs from 'fs';
      import path from 'path';
      
      import {
        BrowserWindow,
      Severity: Minor
      Found in app/src/components/menu.ts - About 5 hrs to fix

        Function getOptions has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function getOptions(rawOptions: RawOptions): Promise<AppOptions> {
          const options: AppOptions = {
            packager: {
              appCopyright: rawOptions.appCopyright,
              appVersion: rawOptions.appVersion,
        Severity: Minor
        Found in src/options/optionsMain.ts - About 5 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

        File main.ts has 366 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import 'source-map-support/register';
        
        import fs from 'fs';
        import * as path from 'path';
        
        
        Severity: Minor
        Found in app/src/main.ts - About 4 hrs to fix

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

          test('edge userAgent parameter is passed', async () => {
            (getChromeVersionForElectronVersion as jest.Mock).mockImplementationOnce(() =>
              Promise.resolve('99.0.0'),
            );
            const params = {
          Severity: Major
          Found in src/options/fields/userAgent.test.ts and 1 other location - About 4 hrs to fix
          src/options/fields/userAgent.test.ts on lines 41..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 130.

          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('firefox userAgent parameter is passed', async () => {
            (getLatestFirefoxVersion as jest.Mock).mockImplementationOnce(() =>
              Promise.resolve('100.0.0'),
            );
            const params = {
          Severity: Major
          Found in src/options/fields/userAgent.test.ts and 1 other location - About 4 hrs to fix
          src/options/fields/userAgent.test.ts on lines 26..39

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

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

          export function getOptionsFromExecutable(
            appResourcesDir: string,
            priorOptions: NativefierOptions,
          ): NativefierOptions {
            const newOptions: NativefierOptions = { ...priorOptions };
          Severity: Minor
          Found in src/helpers/upgrade/executableHelpers.ts - About 4 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 getOptionsFromExecutable has 111 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function getOptionsFromExecutable(
            appResourcesDir: string,
            priorOptions: NativefierOptions,
          ): NativefierOptions {
            const newOptions: NativefierOptions = { ...priorOptions };
          Severity: Major
          Found in src/helpers/upgrade/executableHelpers.ts - About 4 hrs to fix

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

              test('about:blank urls should be handled', () => {
                const result = onNewWindowHelper(baseOptions, setupWindow, {
                  url: 'about:blank',
                });
            
            
            Severity: Major
            Found in app/src/helpers/windowEvents.test.ts and 1 other location - About 4 hrs to fix
            app/src/helpers/windowEvents.test.ts on lines 210..220

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

            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('about:blank#blocked urls should be handled', () => {
                const result = onNewWindowHelper(baseOptions, setupWindow, {
                  url: 'about:blank#blocked',
                });
            
            
            Severity: Major
            Found in app/src/helpers/windowEvents.test.ts and 1 other location - About 4 hrs to fix
            app/src/helpers/windowEvents.test.ts on lines 198..208

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

            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.packager.platform === 'win32') {
                if (iconIsIco(options.packager.icon)) {
                  log.debug(
                    'Building for Windows and icon is already a .ico, no conversion needed',
                  );
            Severity: Major
            Found in src/build/buildIcon.ts and 1 other location - About 4 hrs to fix
            src/build/buildIcon.ts on lines 54..70

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

            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