jkroepke/featurebook-js

View on GitHub

Showing 18 of 52 total issues

Function html has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const html = async (specDir, outputDir) => {
  const metadata = await api.readMetadata(specDir) || {};
  const specTree = await api.readSpecTree(specDir);

  const assetsDir = path.join(specDir, 'assets');
Severity: Major
Found in packages/featurebook-html/lib/featurebook-html.js - About 3 hrs to fix

    Function expectTinySpecTree has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function expectTinySpecTree(specTree) {
      expect(specTree).to.deep.equal({
        path: '.',
        name: 'tiny',
        displayName: 'Tiny',
    Severity: Major
    Found in packages/featurebook-api/test/featurebook-api.test.js - About 2 hrs to fix

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

      const html = async (specDir, outputDir) => {
        const metadata = await api.readMetadata(specDir) || {};
        const specTree = await api.readSpecTree(specDir);
      
        const assetsDir = path.join(specDir, 'assets');
      Severity: Minor
      Found in packages/featurebook-html/lib/featurebook-html.js - 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 serve has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const serve = async (specDir, port) => {
        const app = express();
      
        const markdownOptions = {
          imageRenderer,
      Severity: Major
      Found in packages/featurebook-serve/lib/featurebook-serve.js - About 2 hrs to fix

        File featurebook-pdf-generator.js has 257 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        const color = require('colors/safe');
        const fs = require('fs');
        const path = require('path');
        const api = require('@jkroepke/featurebook-api');
        const PdfPrinter = require('pdfmake');
        Severity: Minor
        Found in packages/featurebook-pdf/lib/featurebook-pdf-generator.js - About 2 hrs to fix

          Function print has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            const print = async (node, pathPrefix) => {
              if (node.type === 'file') {
                const featurePath = path.join(specDir, node.path);
                const nextPathPrefix = pathPrefix || './';
                try {
          Severity: Major
          Found in packages/featurebook-html/lib/featurebook-html.js - About 2 hrs to fix

            Function exports has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = (config) => {
              config.set({
                basePath: './../',
                frameworks: ['jasmine'],
                reporters: ['progress', 'coverage'],
            Severity: Minor
            Found in packages/featurebook-serve/test/karma.conf.js - About 1 hr to fix

              Function setDocumentDefinition has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                setDocumentDefinition(styles = {}) {
                  this.docDefinition = {
                    defaultStyle: {
                      font: 'Anaheim',
                      fontSize: 12,
              Severity: Minor
              Found in packages/featurebook-pdf/lib/featurebook-pdf-generator.js - About 1 hr to fix

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

                const findInDir = async (startDir, filter) => {
                  const search = async (file) => {
                    const node = {
                      path: path.normalize(path.relative(startDir, file)).replace(/\\/g, '/'),
                      name: path.basename(file),
                Severity: Minor
                Found in packages/featurebook-api/lib/helpers.js - 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 processSpecTree has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                const processSpecTree = async (specDir, specTree) => {
                  const traverse = async (file) => {
                    const node = {
                      ...file,
                      displayName: helpers.getDisplayName(file.name),
                Severity: Minor
                Found in packages/featurebook-api/lib/featurebook-api.js - 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 featureBookServiceFactory has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function featureBookServiceFactory($http) {
                    return {
                      getMetadata: getMetadata,
                      getSummary: getSummary,
                      getSpecTree: getSpecTree,
                Severity: Minor
                Found in packages/featurebook-serve/public/scripts/featurebook.service.js - About 1 hr to fix

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

                  const findInDir = async (startDir, filter) => {
                    const search = async (file) => {
                      const node = {
                        path: path.normalize(path.relative(startDir, file)).replace(/\\/g, '/'),
                        name: path.basename(file),
                  Severity: Minor
                  Found in packages/featurebook-api/lib/helpers.js - About 1 hr to fix

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

                    const processSpecTree = async (specDir, specTree) => {
                      const traverse = async (file) => {
                        const node = {
                          ...file,
                          displayName: helpers.getDisplayName(file.name),
                    Severity: Minor
                    Found in packages/featurebook-api/lib/featurebook-api.js - About 1 hr to fix

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

                        const search = async (file) => {
                          const node = {
                            path: path.normalize(path.relative(startDir, file)).replace(/\\/g, '/'),
                            name: path.basename(file),
                          };
                      Severity: Minor
                      Found in packages/featurebook-api/lib/helpers.js - About 1 hr to fix

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

                          async printFeature(node) {
                            try {
                              const features = await api.readFeatures(path.join(this.specDir, node.path));
                        
                              for (const feature of features) {
                        Severity: Minor
                        Found in packages/featurebook-pdf/lib/featurebook-pdf-generator.js - 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 routesConfig has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          function routesConfig($routeProvider) {
                            $routeProvider
                              .when('/viewer/:path*', {
                                templateUrl: 'views/feature-viewer.html',
                                controller: 'FeatureViewerController',
                        Severity: Minor
                        Found in packages/featurebook-serve/public/scripts/featurebook.routes.js - About 1 hr to fix

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

                          const descriptionMarkdownToHTML = async (features, options) => {
                            const searchAndRender = (spec) => {
                              const fn = (value, key) => {
                                if (key === 'description') {
                                  return render(value, options);
                          Severity: Minor
                          Found in packages/featurebook-markdown/lib/featurebook-markdown.js - 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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const render = (text, markdownOptions) => {
                            if (markdownOptions && markdownOptions.linkRenderer) {
                              const defaultLinkRenderer = md.renderer.rules.link_open
                                || ((tokens, idx, options, env, self) => self.renderToken(tokens, idx, options));
                          
                          
                          Severity: Minor
                          Found in packages/featurebook-markdown/lib/featurebook-markdown.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

                          Severity
                          Category
                          Status
                          Source
                          Language