jiahaog/nativefier

View on GitHub

Showing 148 of 148 total issues

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

function getExecutableArch(
  exeBytes: Uint8Array,
  platform: string,
): string | undefined {
  switch (platform) {
Severity: Minor
Found in src/helpers/upgrade/executableHelpers.ts - About 1 hr to fix

    Function findUpgradeApp has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function findUpgradeApp(upgradeFrom: string): UpgradeAppInfo | null {
      const searchDir = dirExists(upgradeFrom)
        ? upgradeFrom
        : path.dirname(upgradeFrom);
      log.debug(`Looking for old options file in ${searchDir}`);
    Severity: Minor
    Found in src/helpers/upgrade/upgrade.ts - About 1 hr to fix

      Function _logger has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      function _logger(
        logFunc: (...args: unknown[]) => void,
        level: loglevel.LogLevelNumbers,
        ...args: unknown[]
      ): void {
      Severity: Minor
      Found in app/src/helpers/loggingHelper.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 getLatestSafariVersion has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function getLatestSafariVersion(
        url = SAFARI_VERSIONS_HISTORY_URL,
      ): Promise<SafariVersion> {
        try {
          log.debug('Grabbing apple version data from', url);
      Severity: Minor
      Found in src/infer/browsers/inferSafariVersion.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 getDefaultWindowOptions has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function getDefaultWindowOptions(
        options: WindowOptions,
      ): BrowserWindowConstructorOptions {
        const browserwindowOptions: BrowserWindowConstructorOptions = {
          ...options.browserwindowOptions,
      Severity: Minor
      Found in app/src/helpers/windowHelpers.ts - About 1 hr to fix

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

            if (newOptions.appVersion === undefined) {
              // https://github.com/electron/electron-packager/blob/f1c159f4c844d807968078ea504fba40ca7d9c73/src/win32.js#L46-L48
              newOptions.appVersion = getVersionString(
                executablePath,
                'ProductVersion',
        Severity: Major
        Found in src/helpers/upgrade/executableHelpers.ts and 2 other locations - About 1 hr to fix
        src/helpers/upgrade/executableHelpers.ts on lines 158..169
        src/helpers/upgrade/upgrade.ts on lines 99..110

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

        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

            if (newOptions.appCopyright === undefined) {
              // https://github.com/electron/electron-packager/blob/f1c159f4c844d807968078ea504fba40ca7d9c73/src/win32.js#L54-L56
              newOptions.appCopyright = getVersionString(
                executablePath,
                'LegalCopyright',
        Severity: Major
        Found in src/helpers/upgrade/executableHelpers.ts and 2 other locations - About 1 hr to fix
        src/helpers/upgrade/executableHelpers.ts on lines 130..141
        src/helpers/upgrade/upgrade.ts on lines 99..110

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

        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

          if (newOptions.appCopyright === undefined) {
            // https://github.com/electron/electron-packager/blob/0d3f84374e9ab3741b171610735ebc6be3e5e75f/src/mac.js#L230-L232
            newOptions.appCopyright = extractString(
              infoPlistXML,
              'NSHumanReadableCopyright',
        Severity: Major
        Found in src/helpers/upgrade/upgrade.ts and 2 other locations - About 1 hr to fix
        src/helpers/upgrade/executableHelpers.ts on lines 130..141
        src/helpers/upgrade/executableHelpers.ts on lines 158..169

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

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

            prepend: (actions: contextMenu.Actions, params: ContextMenuParams) => {
              log.debug('contextMenu.prepend', { actions, params });
              const items = [];
              if (params.linkURL && window) {
                items.push({
        Severity: Minor
        Found in app/src/components/contextMenu.ts - About 1 hr to fix

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

            function getInfoPListOptions(
              appResourcesDir: string,
              priorOptions: NativefierOptions,
            ): NativefierOptions {
              if (!fileExists(path.join(appResourcesDir, '..', '..', 'Info.plist'))) {
            Severity: Minor
            Found in src/helpers/upgrade/upgrade.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 createMainWindow has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            export async function createMainWindow(
              nativefierOptions: OutputOptions,
              setDockBadge: (value: number | string, bounce?: boolean) => void,
            ): Promise<BrowserWindow> {
              const options = { ...nativefierOptions };
            Severity: Minor
            Found in app/src/components/mainWindow.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 prepareElectronApp has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function prepareElectronApp(
              src: string,
              dest: string,
              options: AppOptions,
            ): Promise<void> {
            Severity: Minor
            Found in src/build/prepareElectronApp.ts - About 1 hr to fix

              Function submenu has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    bookmarksMenuConfig.bookmarks.map((bookmark) => {
                      switch (bookmark.type) {
                        case 'link':
                          if (!('title' in bookmark && 'url' in bookmark)) {
                            throw new Error(
              Severity: Minor
              Found in app/src/components/menu.ts - About 1 hr to fix

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

                export function fileExists(fileName: string): boolean {
                  try {
                    const fileStat = fs.statSync(fileName);
                    return fileStat.isFile();
                  } catch {
                Severity: Major
                Found in src/helpers/fsHelpers.ts and 1 other location - About 1 hr to fix
                src/helpers/fsHelpers.ts on lines 3..10

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

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

                function injectCSSIntoResponse(
                  details: OnResponseStartedListenerDetails,
                  cssToInject: string,
                ): Promise<string | undefined> {
                  const contentType =
                Severity: Minor
                Found in app/src/helpers/windowHelpers.ts - About 1 hr to fix

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

                  export function dirExists(dirName: string): boolean {
                    try {
                      const dirStat = fs.statSync(dirName);
                      return dirStat.isDirectory();
                    } catch {
                  Severity: Major
                  Found in src/helpers/fsHelpers.ts and 1 other location - About 1 hr to fix
                  src/helpers/fsHelpers.ts on lines 12..19

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

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

                  export async function getChromeVersionForElectronVersion(
                    electronVersion: string,
                    url = ELECTRON_VERSIONS_URL,
                  ): Promise<string> {
                    if (!electronVersion || electronVersion === DEFAULT_ELECTRON_VERSION) {
                  Severity: Minor
                  Found in src/infer/browsers/inferChromeVersion.ts - About 1 hr to fix

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

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

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

                      export function linkIsInternal(
                        currentUrl: string,
                        newUrl: string,
                        internalUrlRegex: string | RegExp | undefined,
                        isStrictInternalUrlsEnabled: boolean | undefined,
                      Severity: Minor
                      Found in app/src/helpers/helpers.ts - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language