wadmiraal/rtfm

View on GitHub

Showing 24 of 24 total issues

Function register has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    register: function( string ) {
        var parts = [],
            stride = '',
            open = false,
            part;
Severity: Minor
Found in lib/rtfm-code.js - About 5 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

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

var imageMarkdown = image.extend({
    
    output: function( string ) {
        var parts = string.split( '::::ALT::::' );
        if ( parts[ 0 ].length ) {
Severity: Major
Found in lib/md/rtfm-image-md.js and 1 other location - About 3 hrs to fix
lib/md/rtfm-link-md.js on lines 4..15

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

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

var linkMarkdown = link.extend({
    
    output: function( string ) {
        var parts = string.split( '::::ALT::::' );
        if ( parts[ 0 ].length ) {
Severity: Major
Found in lib/md/rtfm-link-md.js and 1 other location - About 3 hrs to fix
lib/md/rtfm-image-md.js on lines 4..15

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

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 ( newSplit.length > 1 ) {
                var registered = false,
                    elements = [];
                for ( var i = 0, len = newSplit.length; i < len; ++i ) {
                    elements.push({
Severity: Major
Found in lib/rtfm.js and 1 other location - About 3 hrs to fix
lib/rtfm-image.js on lines 48..59

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

            if ( split.length > 1 ) {
                var registered = false,
                    elements = [];
                for ( var i = 0, len = split.length; i < len; ++i ) {
                    elements.push({
Severity: Major
Found in lib/rtfm-image.js and 1 other location - About 3 hrs to fix
lib/rtfm.js on lines 404..415

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 register has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    register: function( string ) {
        var parts = [],
            stride = '',
            open = false,
            part;
Severity: Major
Found in lib/rtfm-code.js - About 2 hrs to fix

    Function register has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        register: function( string ) {
            if ( this.pattern === undefined ) {
                return false;
            }
    
    
    Severity: Minor
    Found in lib/rtfm.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

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

    rtfm.registerInlinePlugin = function( name, plugin ) {
        if ( this.inlinePlugins === undefined ) {
            this.inlinePlugins = {};
        }
    
    
    Severity: Major
    Found in lib/rtfm.js and 1 other location - About 1 hr to fix
    lib/rtfm.js on lines 58..66

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

    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 register has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        register: function( string ) {
            if ( this.regEx === undefined ) {
                this.regEx = new RegExp( /\[([^:]*)?:?([^\]]*)\]/g );
            }
            
    Severity: Minor
    Found in lib/rtfm-image.js - About 1 hr to fix

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

      rtfm.registerBlockPlugin = function( name, plugin ) {
          if ( this.blockPlugins === undefined ) {
              this.blockPlugins = {};
          }
      
      
      Severity: Major
      Found in lib/rtfm.js and 1 other location - About 1 hr to fix
      lib/rtfm.js on lines 106..114

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

      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 findInlinePlugins has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      rtfm.findInlinePlugins = function( string ) {
          var parts = [],
              result, merge;
      
          // Iterate through all registered inline plugins.
      Severity: Minor
      Found in lib/rtfm.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

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

      var strikeThrough = rtfm.InlinePlugin.extend({
      
          register: function( string ) {
              this.pattern = '--';
              return rtfm.InlinePlugin.prototype.register.call( this, string );
      Severity: Major
      Found in lib/rtfm-strikethrough.js and 3 other locations - About 1 hr to fix
      lib/rtfm-bold.js on lines 4..11
      lib/rtfm-italic.js on lines 4..11
      lib/rtfm-underline.js on lines 4..11

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

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

      var italic = rtfm.InlinePlugin.extend({
      
          register: function( string ) {
              this.pattern = '//';
              return rtfm.InlinePlugin.prototype.register.call( this, string );
      Severity: Major
      Found in lib/rtfm-italic.js and 3 other locations - About 1 hr to fix
      lib/rtfm-bold.js on lines 4..11
      lib/rtfm-strikethrough.js on lines 4..11
      lib/rtfm-underline.js on lines 4..11

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

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

      var bold = rtfm.InlinePlugin.extend({
      
          register: function( string ) {
              this.pattern = '**';
              return rtfm.InlinePlugin.prototype.register.call( this, string );
      Severity: Major
      Found in lib/rtfm-bold.js and 3 other locations - About 1 hr to fix
      lib/rtfm-italic.js on lines 4..11
      lib/rtfm-strikethrough.js on lines 4..11
      lib/rtfm-underline.js on lines 4..11

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

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

      var underline = rtfm.InlinePlugin.extend({
      
          register: function( string ) {
              this.pattern = '__';
              return rtfm.InlinePlugin.prototype.register.call( this, string );
      Severity: Major
      Found in lib/rtfm-underline.js and 3 other locations - About 1 hr to fix
      lib/rtfm-bold.js on lines 4..11
      lib/rtfm-italic.js on lines 4..11
      lib/rtfm-strikethrough.js on lines 4..11

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

      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

      var headings = rtfm.BlockPlugin.extend({
      
          register: function( string ) {
              if ( /^\s*\!+/.test( string ) ) {
                  return [{
      Severity: Major
      Found in lib/rtfm-headings.js and 1 other location - About 1 hr to fix
      lib/rtfm-codeblock.js on lines 4..17

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

      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

      var codeBlock = rtfm.BlockPlugin.extend({
      
          register: function( string ) {
              if ( /^\s*(\{\{\{|\}\}\}$)/.test( string ) ) {
                  return [{
      Severity: Major
      Found in lib/rtfm-codeblock.js and 1 other location - About 1 hr to fix
      lib/rtfm-headings.js on lines 4..17

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

      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 register has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          register: function( string ) {
              if ( this.pattern === undefined ) {
                  return false;
              }
      
      
      Severity: Minor
      Found in lib/rtfm.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                            switch ( type ) {
                                case 'inline':
                                    rtfm.registerInlinePlugin( plugins[ type ][ i ], definition );
                                    break;
        
        
        Severity: Major
        Found in bin/cli.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if ( /^\}\}/.test( part ) ) {
                                  // Skip 1 character ahead, because the tag was at the
                                  // start of the string.
                                  i += 1;
                                  continue;
          Severity: Major
          Found in lib/rtfm-code.js - About 45 mins to fix
            Severity
            Category
            Status
            Source
            Language