jjmschofield/github-codeowners

View on GitHub

Showing 8 of 36 total issues

Function calcFileStats has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

export const calcFileStats = (files: File[]): Stats => {
  const total: Counters = {
    files: 0,
    lines: 0,
  };
Severity: Minor
Found in src/lib/stats/stats.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 calcFileStats has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Confirmed

export const calcFileStats = (files: File[]): Stats => {
  const total: Counters = {
    files: 0,
    lines: 0,
  };
Severity: Minor
Found in src/lib/stats/stats.ts - About 1 hr to fix

    Function walkDir has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    const walkDir = (root: string, dir: string, ignores: Ignore, files: string[] = []): string[] => {
      const newFiles = fs.readdirSync(path.resolve(root, dir));
    
      const newGitIgnore = newFiles.find(file => file === '.gitignore');
    
    
    Severity: Minor
    Found in src/lib/file/readDir.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 validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export const validate = async (options: { codeowners: string, dir: string, root?: string }): Promise<ValidationResults> => {
      const engine = OwnershipEngine.FromCodeownersFile(options.codeowners); // Validates code owner file
    
      const filePaths = await readDir(options.dir, ['.git']);
    
    
    Severity: Minor
    Found in src/lib/ownership/validate.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 validate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const validate = async (options: { codeowners: string, dir: string, root?: string }): Promise<ValidationResults> => {
      const engine = OwnershipEngine.FromCodeownersFile(options.codeowners); // Validates code owner file
    
      const filePaths = await readDir(options.dir, ['.git']);
    
    
    Severity: Minor
    Found in src/lib/ownership/validate.ts - About 1 hr to fix

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

      export const writer = (stats: Stats, options: { output: OUTPUT_FORMAT }, stream: any) => {
        const orderedOwners = [...stats.owners].sort((a, b) => {
          if (a.owner < b.owner) return -1;
          if (a.owner > b.owner) return 1;
          return 0;
      Severity: Minor
      Found in src/lib/stats/writer.ts - About 1 hr to fix

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

        export const audit = async (options: AuditOptions) => {
          const strategy = options.onlyGit ? FILE_DISCOVERY_STRATEGY.GIT_LS : FILE_DISCOVERY_STRATEGY.FILE_SYSTEM;
          const filePaths = await getFilePaths(options.dir, strategy, options.root);
        
          const files = await getOwnership(options.codeowners, filePaths);
        Severity: Minor
        Found in src/commands/audit.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

        Function createMatcherCodeownersRule has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const createMatcherCodeownersRule = (rule: string): FileOwnershipMatcher => {
          // Split apart on spaces
          const parts = rule.split(/\s+/);
        
          // The first part is expected to be the path
        Severity: Minor
        Found in src/lib/ownership/OwnershipEngine.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

        Severity
        Category
        Status
        Source
        Language