jkroepke/featurebook-js

View on GitHub

Showing 52 of 52 total issues

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

describe('featurebook-html', () => {
  describe('$imageRenderer', () => {
    let imageRenderer;

    beforeEach(() => {
Severity: Major
Found in packages/featurebook-html/test/featurebook-html.test.js and 1 other location - About 2 days to fix
packages/featurebook-serve/test/featurebook-serve.test.js on lines 6..54

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

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

describe('featurebook-serve', () => {
  describe('$imageRenderer', () => {
    let imageRenderer;

    beforeEach(() => {
Severity: Major
Found in packages/featurebook-serve/test/featurebook-serve.test.js and 1 other location - About 2 days to fix
packages/featurebook-html/test/featurebook-html.test.js on lines 7..55

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

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 (markdownOptions && markdownOptions.linkRenderer) {
    const defaultLinkRenderer = md.renderer.rules.link_open
      || ((tokens, idx, options, env, self) => self.renderToken(tokens, idx, options));

    md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
Severity: Major
Found in packages/featurebook-markdown/lib/featurebook-markdown.js and 1 other location - About 6 hrs to fix
packages/featurebook-markdown/lib/featurebook-markdown.js on lines 28..42

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

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 (markdownOptions && markdownOptions.imageRenderer) {
    const defaultImageRenderer = md.renderer.rules.image
      || ((tokens, idx, options, env, self) => self.renderToken(tokens, idx, options));

    md.renderer.rules.image = (tokens, idx, options, env, self) => {
Severity: Major
Found in packages/featurebook-markdown/lib/featurebook-markdown.js and 1 other location - About 6 hrs to fix
packages/featurebook-markdown/lib/featurebook-markdown.js on lines 12..26

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

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

    it('should configure route for `/viewer/my.feature`', function () {
        spyOn(featureBookService, 'getFeature').and.returnValue({name: 'Test feature'});
        $location.path('/viewer/my.feature');
        $rootScope.$digest();

packages/featurebook-serve/test/public/featurebook.routes.spec.js on lines 40..49

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

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

    it('should configure route for `/viewer/a/sub/folder/for/my.feature`', function () {
        spyOn(featureBookService, 'getFeature').and.returnValue({name: 'Test feature'});
        $location.path('/viewer/a/sub/folder/for/my.feature');
        $rootScope.$digest();

packages/featurebook-serve/test/public/featurebook.routes.spec.js on lines 29..38

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

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

const linkRenderer = (attrs) => {
  const addFeaturePrefix = (url) => `/#/viewer${url.startsWith('/') ? '' : '/'}${url.substring(markdown.FEATURE_URL_SCHEMA.length)}`;

  let { href } = attrs;

Severity: Major
Found in packages/featurebook-serve/lib/helper.js and 1 other location - About 4 hrs to fix
packages/featurebook-serve/lib/helper.js on lines 3..16

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

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

const imageRenderer = (attrs) => {
  const addAssetPrefix = (url) => `api/rest/raw${url.startsWith('/') ? '' : '/'}${url.substring(markdown.ASSET_URL_SCHEMA.length)}`;

  let { src } = attrs;

Severity: Major
Found in packages/featurebook-serve/lib/helper.js and 1 other location - About 4 hrs to fix
packages/featurebook-serve/lib/helper.js on lines 18..31

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

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

exports.handler = async (argv) => {
  if (!require.resolve('@jkroepke/featurebook-pdf')) {
    console.error("Can't load module '@jkroepke/featurebook-pdf'. Did you run 'npm i -S @jkroepke/featurebook-pdf'?");
    process.exit(1);
  }
Severity: Major
Found in packages/featurebook/cmds/pdf.js and 1 other location - About 3 hrs to fix
packages/featurebook/cmds/html.js on lines 19..31

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

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

exports.handler = async (argv) => {
  if (!require.resolve('@jkroepke/featurebook-html')) {
    console.error("Can't load module '@jkroepke/featurebook-html'. Did you run 'npm i -S @jkroepke/featurebook-html'?");
    process.exit(1);
  }
Severity: Major
Found in packages/featurebook/cmds/html.js and 1 other location - About 3 hrs to fix
packages/featurebook/cmds/pdf.js on lines 19..31

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

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

    this.docDefinition.content.push({
      text: [
        { text: `${scenario.keyword.trim()}:`, color: 'red', fontSize: 14 },
        { text: ` ${scenario.name}`, fontSize: 14 },
      ],
Severity: Major
Found in packages/featurebook-pdf/lib/featurebook-pdf-generator.js and 2 other locations - About 3 hrs to fix
packages/featurebook-pdf/lib/featurebook-pdf-generator.js on lines 267..273
packages/featurebook-pdf/lib/featurebook-pdf-generator.js on lines 285..291

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

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

    this.docDefinition.content.push({
      text: [
        { text: `${background.keyword.trim()}:`, color: 'red', fontSize: 14 },
        { text: ` ${background.name}`, fontSize: 14 },
      ],
Severity: Major
Found in packages/featurebook-pdf/lib/featurebook-pdf-generator.js and 2 other locations - About 3 hrs to fix
packages/featurebook-pdf/lib/featurebook-pdf-generator.js on lines 137..143
packages/featurebook-pdf/lib/featurebook-pdf-generator.js on lines 285..291

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

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

    this.docDefinition.content.push({
      text: [
        { text: `${example.keyword.trim()}:`, color: 'red', fontSize: 14 },
        { text: ` ${example.name}`, fontSize: 14 },
      ],
Severity: Major
Found in packages/featurebook-pdf/lib/featurebook-pdf-generator.js and 2 other locations - About 3 hrs to fix
packages/featurebook-pdf/lib/featurebook-pdf-generator.js on lines 137..143
packages/featurebook-pdf/lib/featurebook-pdf-generator.js on lines 267..273

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

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

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

                it('should propagate null given a specification directory without the metadata descriptor', (done) => {
                  featurebook.readMetadata('test/resources/features', (err, metadata) => {
                    expect(err).to.be.null;
                    expect(metadata).to.be.null;
                    done();
            Severity: Major
            Found in packages/featurebook-api/test/featurebook-api.test.js and 1 other location - About 2 hrs to fix
            packages/featurebook-api/test/featurebook-api.test.js on lines 159..165

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

            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

            Severity
            Category
            Status
            Source
            Language