Microsoft/fast-dna

View on GitHub
sites/website/src/generate-docs.js

Summary

Maintainability
F
3 days
Test Coverage

Function copyArticleMarkdown has 137 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function copyArticleMarkdown() {
    const mergeDocs = [
        {
            src: path.resolve(root, "CODE_OF_CONDUCT.md"),
            dest: path.resolve(outputDir, "community/CODE_OF_CONDUCT.md"),
Severity: Major
Found in sites/website/src/generate-docs.js - About 5 hrs to fix

    File generate-docs.js has 324 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const path = require("path");
    const { createInterface } = require("readline");
    const { exec } = require("child_process");
    const fs = require("fs-extra");
    const { getPackageJsonDir } = require("../../../build/get-package-json");
    Severity: Minor
    Found in sites/website/src/generate-docs.js - About 3 hrs to fix

      Function convertDocFiles has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function convertDocFiles(dir, docFiles, package, exportPath) {
          for (const docFile of docFiles) {
              try {
                  const { name: id, ext } = path.parse(docFile);
                  if (ext !== ".md") {
      Severity: Major
      Found in sites/website/src/generate-docs.js - About 2 hrs to fix

        Function buildAPIMarkdown has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function buildAPIMarkdown() {
            await copyAPI();
        
            await new Promise((resolve, reject) =>
                exec(
        Severity: Minor
        Found in sites/website/src/generate-docs.js - About 1 hr to fix

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

          async function buildAPIMarkdown() {
              await copyAPI();
          
              await new Promise((resolve, reject) =>
                  exec(
          Severity: Minor
          Found in sites/website/src/generate-docs.js - 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 copyAPI has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          async function copyAPI() {
              for (const pkg of packages) {
                  await safeCopy(
                      path.resolve(
                          getPackageJsonDir(`@microsoft/${pkg.main}`),
          Severity: Minor
          Found in sites/website/src/generate-docs.js - 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 findFiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function findFiles(startPath, filter, paths = []) {
              if (!fs.existsSync(startPath)) {
                  console.log("no dir ", startPath);
                  return;
              }
          Severity: Minor
          Found in sites/website/src/generate-docs.js - 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

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

              if (fs.existsSync(dest)) {
                  await fs.writeFile(dest, content);
              } else {
                  await fs.mkdir(path.dirname(dest), { recursive: true });
                  await fs.writeFile(dest, content);
          Severity: Major
          Found in sites/website/src/generate-docs.js and 1 other location - About 2 hrs to fix
          sites/website/src/generate-docs.js on lines 55..60

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

          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 (fs.existsSync(dest)) {
                  await fs.copyFile(source, dest);
              } else {
                  await fs.mkdir(path.dirname(dest), { recursive: true });
                  await fs.copyFile(source, dest);
          Severity: Major
          Found in sites/website/src/generate-docs.js and 1 other location - About 2 hrs to fix
          sites/website/src/generate-docs.js on lines 64..69

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

          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 5 locations. Consider refactoring.
          Open

                  {
                      src: path.resolve(root, "CONTRIBUTING.md"),
                      dest: path.resolve(outputDir, "community/CONTRIBUTING.md"),
                      metadata: {
                          id: "contributor-guide",
          Severity: Major
          Found in sites/website/src/generate-docs.js and 4 other locations - About 1 hr to fix
          sites/website/src/generate-docs.js on lines 74..87
          sites/website/src/generate-docs.js on lines 101..113
          sites/website/src/generate-docs.js on lines 114..125
          sites/website/src/generate-docs.js on lines 126..139

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

          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 5 locations. Consider refactoring.
          Open

                  {
                      src: path.resolve(root, "LICENSE"),
                      dest: path.resolve(outputDir, "resources/LICENSE.md"),
                      metadata: {
                          id: "license",
          Severity: Major
          Found in sites/website/src/generate-docs.js and 4 other locations - About 1 hr to fix
          sites/website/src/generate-docs.js on lines 74..87
          sites/website/src/generate-docs.js on lines 88..100
          sites/website/src/generate-docs.js on lines 101..113
          sites/website/src/generate-docs.js on lines 126..139

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

          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 5 locations. Consider refactoring.
          Open

                  {
                      src: path.resolve(root, "SECURITY.md"),
                      dest: path.resolve(outputDir, "resources/SECURITY.md"),
                      metadata: {
                          id: "security",
          Severity: Major
          Found in sites/website/src/generate-docs.js and 4 other locations - About 1 hr to fix
          sites/website/src/generate-docs.js on lines 74..87
          sites/website/src/generate-docs.js on lines 88..100
          sites/website/src/generate-docs.js on lines 101..113
          sites/website/src/generate-docs.js on lines 114..125

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

          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 5 locations. Consider refactoring.
          Open

                  {
                      src: path.resolve(root, "CODE_OF_CONDUCT.md"),
                      dest: path.resolve(outputDir, "community/CODE_OF_CONDUCT.md"),
                      metadata: {
                          id: "code-of-conduct",
          Severity: Major
          Found in sites/website/src/generate-docs.js and 4 other locations - About 1 hr to fix
          sites/website/src/generate-docs.js on lines 88..100
          sites/website/src/generate-docs.js on lines 101..113
          sites/website/src/generate-docs.js on lines 114..125
          sites/website/src/generate-docs.js on lines 126..139

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

          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 5 locations. Consider refactoring.
          Open

                  {
                      src: path.resolve(root, "BRANCH_GUIDE.md"),
                      dest: path.resolve(outputDir, "community/BRANCH_GUIDE.md"),
                      metadata: {
                          id: "branch-guide",
          Severity: Major
          Found in sites/website/src/generate-docs.js and 4 other locations - About 1 hr to fix
          sites/website/src/generate-docs.js on lines 74..87
          sites/website/src/generate-docs.js on lines 88..100
          sites/website/src/generate-docs.js on lines 114..125
          sites/website/src/generate-docs.js on lines 126..139

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

          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

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

                              (err, stdout, stderr) => {
                                  console.log(stdout);
                                  console.error(stderr);
                                  if (err) {
                                      return reject(err);
          Severity: Minor
          Found in sites/website/src/generate-docs.js and 1 other location - About 50 mins to fix
          sites/website/src/generate-docs.js on lines 326..334

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

          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

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

                      (err, stdout, stderr) => {
                          console.log(stdout);
                          console.error(stderr);
                          if (err) {
                              return reject(err);
          Severity: Minor
          Found in sites/website/src/generate-docs.js and 1 other location - About 50 mins to fix
          sites/website/src/generate-docs.js on lines 343..351

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

          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

          There are no issues that match your filters.

          Category
          Status