meteor/meteor

View on GitHub
tools/fs/files.ts

Summary

Maintainability
F
5 days
Test Coverage

File files.ts has 1176 lines of code (exceeds 250 allowed). Consider refactoring.
Open

///
/// utility functions for files and directories. includes both generic
/// helper functions (such as rm_recursive), and meteor-specific ones
/// (such as testing whether an directory is a meteor app)
///
Severity: Major
Found in tools/fs/files.ts - About 3 days to fix

    Function treeHash has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    export function treeHash(root: string, optionsParams: {
      ignore?: (path: string) => boolean;
    }) {
      const options = {
        ignore() { return false; },
    Severity: Minor
    Found in tools/fs/files.ts - About 2 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 renameDirAlmostAtomically has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    Profile("files.renameDirAlmostAtomically", (fromDir: string, toDir: string) => {
      const garbageDir = pathJoin(
        pathDirname(toDir),
        // Begin the base filename with a '.' character so that it can be
        // ignored by other directory-scanning code.
    Severity: Minor
    Found in tools/fs/files.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 wrapFsFunc has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function wrapFsFunc<TArgs extends any[], TResult>(
      fnName: string,
      fn: (...args: TArgs) => TResult,
      pathArgIndices: number[],
      options?: wrapFsFuncOptions<TArgs, TResult>,
    Severity: Minor
    Found in tools/fs/files.ts - About 1 hr to fix

      Function treeHash has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function treeHash(root: string, optionsParams: {
        ignore?: (path: string) => boolean;
      }) {
        const options = {
          ignore() { return false; },
      Severity: Minor
      Found in tools/fs/files.ts - About 1 hr to fix

        Function cp_r has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function cp_r(from: string, to: string, options: {
          preserveSymlinks?: boolean;
          ignore?: RegExp[];
          transformFilename?: (f: string) => string;
          transformContents?: (
        Severity: Minor
        Found in tools/fs/files.ts - About 1 hr to fix

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

          Profile("files.renameDirAlmostAtomically", (fromDir: string, toDir: string) => {
            const garbageDir = pathJoin(
              pathDirname(toDir),
              // Begin the base filename with a '.' character so that it can be
              // ignored by other directory-scanning code.
          Severity: Minor
          Found in tools/fs/files.ts - About 1 hr to fix

            Function mkdtemp has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function mkdtemp(prefix: string): string {
              function make(): string {
                prefix = prefix || 'mt-';
                // find /tmp
                let tmpDir: string | undefined;
            Severity: Minor
            Found in tools/fs/files.ts - About 1 hr to fix

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

              export function mkdtemp(prefix: string): string {
                function make(): string {
                  prefix = prefix || 'mt-';
                  // find /tmp
                  let tmpDir: string | undefined;
              Severity: Minor
              Found in tools/fs/files.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 mkdir_p has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              export function mkdir_p(dir: string, mode: number | null = null) {
                const p = pathResolve(dir);
                const ps = pathNormalize(p).split(pathSep);
              
                const stat = statOrNull(p);
              Severity: Minor
              Found in tools/fs/files.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 make has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function make(): string {
                  prefix = prefix || 'mt-';
                  // find /tmp
                  let tmpDir: string | undefined;
                  ['TMPDIR', 'TMP', 'TEMP'].some(t => {
              Severity: Minor
              Found in tools/fs/files.ts - About 1 hr to fix

                Function rename has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const rename = isWindowsLikeFilesystem() ? function (from: string, to: string) {
                  // Retries are necessary only on Windows, because the rename call can
                  // fail with EBUSY, which means the file is in use.
                  const osTo = convertToOSPath(to);
                  const startTimeMs = Date.now();
                Severity: Minor
                Found in tools/fs/files.ts - About 1 hr to fix

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

                    function traverse(relativePath: string) {
                      if (options.ignore(relativePath)) {
                        return;
                      }
                  
                  
                  Severity: Minor
                  Found in tools/fs/files.ts - About 1 hr to fix

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

                    export function getPathsInDir(dir: string, options: {
                      cwd?: string;
                      output?: string[];
                    }) {
                      // Don't let this function yield so that the file system doesn't get changed
                    Severity: Minor
                    Found in tools/fs/files.ts - About 1 hr to fix

                      Function symlinkWithOverwrite has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                      Profile("files.symlinkWithOverwrite", function symlinkWithOverwrite(
                        source: string,
                        target: string,
                      ) {
                        const args: [string, string, "junction"?] = [source, target];
                      Severity: Minor
                      Found in tools/fs/files.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 addToGitignore has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function addToGitignore(dirPath: string, entry: string) {
                        const filePath = pathJoin(dirPath, ".gitignore");
                        if (exists(filePath)) {
                          let data = readFile(filePath, 'utf8') as string;
                          const lines = data.split(/\n/);
                      Severity: Minor
                      Found in tools/fs/files.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

                      Function cp_r has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function cp_r(from: string, to: string, options: {
                        preserveSymlinks?: boolean;
                        ignore?: RegExp[];
                        transformFilename?: (f: string) => string;
                        transformContents?: (
                      Severity: Minor
                      Found in tools/fs/files.ts - About 35 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

                      Function findUpwards has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function findUpwards(
                        predicate: (path: string) => boolean,
                        startPath: string = cwd(),
                      ): string | null {
                        let testDir: string | null = startPath;
                      Severity: Minor
                      Found in tools/fs/files.ts - About 35 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

                      Avoid too many return statements within this function.
                      Open

                        return pathIsDirectory(p);
                      Severity: Major
                      Found in tools/fs/files.ts - About 30 mins to fix

                        Function createTarGzStream has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function createTarGzStream(dirPath: string) {
                          const tar = require("tar-fs");
                          const zlib = require("zlib");
                          const basename = pathBasename(dirPath);
                        
                        
                        Severity: Minor
                        Found in tools/fs/files.ts - About 25 mins to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function getSettings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function getSettings(
                          filename: string,
                          watchSet: import("./watch").WatchSet,
                        ) {
                          buildmessage.assertInCapture();
                        Severity: Minor
                        Found in tools/fs/files.ts - About 25 mins to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        There are no issues that match your filters.

                        Category
                        Status