MPOS/php-mpos

View on GitHub
include/lib/Michelf/Markdown.php

Summary

Maintainability
F
2 wks
Test Coverage

File Markdown.php has 2647 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
#
# Markdown  -  A text-to-HTML conversion tool for web writers
#
# PHP Markdown  
Severity: Major
Found in include/lib/Michelf/Markdown.php - About 1 wk to fix

    Function _hashHTMLBlocks_inMarkdown has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0,
                                            $enclosing_tag_re = '', $span = false)
        {
        #
        # Parse markdown text, calling _HashHTMLBlocks_InHTML for block tags.
    Severity: Minor
    Found in include/lib/Michelf/Markdown.php - About 1 day 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 doItalicsAndBold has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function doItalicsAndBold($text) {
            $token_stack = array('');
            $text_stack = array('');
            $em = '';
            $strong = '';
    Severity: Minor
    Found in include/lib/Michelf/Markdown.php - About 1 day 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

    Method _hashHTMLBlocks_inMarkdown has 194 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0,
                                            $enclosing_tag_re = '', $span = false)
        {
        #
        # Parse markdown text, calling _HashHTMLBlocks_InHTML for block tags.
    Severity: Major
    Found in include/lib/Michelf/Markdown.php - About 7 hrs to fix

      Markdown has 53 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Markdown {
      
          ### Version ###
      
          const  MARKDOWNLIB_VERSION  =  "1.3";
      Severity: Major
      Found in include/lib/Michelf/Markdown.php - About 7 hrs to fix

        Method _hashHTMLBlocks_inHTML has 140 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
            #
            # Parse HTML, calling _HashHTMLBlocks_InMarkdown for block tags.
            #
            # *   Calls $hash_method to convert any blocks.
        Severity: Major
        Found in include/lib/Michelf/Markdown.php - About 5 hrs to fix

          _MarkdownExtra_TmpImpl has 41 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
          
              ### Configuration Variables ###
          
              # Prefix for footnote ids.
          Severity: Minor
          Found in include/lib/Michelf/Markdown.php - About 5 hrs to fix

            Function _hashHTMLBlocks_inHTML has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
                #
                # Parse HTML, calling _HashHTMLBlocks_InMarkdown for block tags.
                #
                # *   Calls $hash_method to convert any blocks.
            Severity: Minor
            Found in include/lib/Michelf/Markdown.php - About 4 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

            Method hashHTMLBlocks has 121 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function hashHTMLBlocks($text) {
                    if ($this->no_markup)  return $text;
            
                    $less_than_tab = $this->tab_width - 1;
            
            
            Severity: Major
            Found in include/lib/Michelf/Markdown.php - About 4 hrs to fix

              Method doItalicsAndBold has 115 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function doItalicsAndBold($text) {
                      $token_stack = array('');
                      $text_stack = array('');
                      $em = '';
                      $strong = '';
              Severity: Major
              Found in include/lib/Michelf/Markdown.php - About 4 hrs to fix

                Method doAnchors has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function doAnchors($text) {
                    #
                    # Turn Markdown link shortcuts into XHTML <a> tags.
                    #
                        if ($this->in_anchor) return $text;
                Severity: Major
                Found in include/lib/Michelf/Markdown.php - About 2 hrs to fix

                  Method doAnchors has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function doAnchors($text) {
                      #
                      # Turn Markdown link shortcuts into XHTML <a> tags.
                      #
                          if ($this->in_anchor) return $text;
                  Severity: Major
                  Found in include/lib/Michelf/Markdown.php - About 2 hrs to fix

                    Function _doTable_callback has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function _doTable_callback($matches) {
                            $head        = $matches[1];
                            $underline    = $matches[2];
                            $content    = $matches[3];
                    
                    
                    Severity: Minor
                    Found in include/lib/Michelf/Markdown.php - 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

                    Method doLists has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function doLists($text) {
                        #
                        # Form HTML ordered (numbered) and unordered (bulleted) lists.
                        #
                            $less_than_tab = $this->tab_width - 1;
                    Severity: Major
                    Found in include/lib/Michelf/Markdown.php - About 2 hrs to fix

                      Method appendFootnotes has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function appendFootnotes($text) {
                          #
                          # Append footnote list to text.
                          #
                              $text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}', 
                      Severity: Major
                      Found in include/lib/Michelf/Markdown.php - About 2 hrs to fix

                        Method doTables has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function doTables($text) {
                            #
                            # Form HTML tables.
                            #
                                $less_than_tab = $this->tab_width - 1;
                        Severity: Minor
                        Found in include/lib/Michelf/Markdown.php - About 2 hrs to fix

                          Method _doTable_callback has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function _doTable_callback($matches) {
                                  $head        = $matches[1];
                                  $underline    = $matches[2];
                                  $content    = $matches[3];
                          
                          
                          Severity: Minor
                          Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

                            Method parseSpan has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function parseSpan($str) {
                                #
                                # Take the string $str and parse it into tokens, hashing embeded HTML,
                                # escaped characters and handling code spans.
                                #
                            Severity: Minor
                            Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

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

                                  protected function appendFootnotes($text) {
                                  #
                                  # Append footnote list to text.
                                  #
                                      $text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}', 
                              Severity: Minor
                              Found in include/lib/Michelf/Markdown.php - 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 doExtraAttributes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  protected function doExtraAttributes($tag_name, $attr) {
                                  #
                                  # Parse attributes caught by the $this->id_class_attr_catch_re expression
                                  # and return the HTML-formatted list of attributes.
                                  #
                              Severity: Minor
                              Found in include/lib/Michelf/Markdown.php - 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

                              Method doImages has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function doImages($text) {
                                  #
                                  # Turn Markdown image shortcuts into <img> tags.
                                  #
                                      #
                              Severity: Minor
                              Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

                                Method doImages has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected function doImages($text) {
                                    #
                                    # Turn Markdown image shortcuts into <img> tags.
                                    #
                                        #
                                Severity: Minor
                                Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

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

                                      protected function encodeEmailAddress($addr) {
                                      #
                                      #    Input: an email address, e.g. "foo@example.com"
                                      #
                                      #    Output: the email address as a mailto link, with each character
                                  Severity: Minor
                                  Found in include/lib/Michelf/Markdown.php - 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

                                  Method _appendFootnotes_callback has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      protected function _appendFootnotes_callback($matches) {
                                          $node_id = $this->fn_id_prefix . $matches[1];
                                          
                                          # Create footnote marker only if it has a corresponding footnote *and*
                                          # the footnote hasn't been used by another marker.
                                  Severity: Minor
                                  Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

                                    Method doDefLists has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        protected function doDefLists($text) {
                                        #
                                        # Form HTML definition lists.
                                        #
                                            $less_than_tab = $this->tab_width - 1;
                                    Severity: Minor
                                    Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

                                      Method processDefListItems has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          protected function processDefListItems($list_str) {
                                          #
                                          #    Process the contents of a single definition list, splitting it
                                          #    into individual term and definition list items.
                                          #
                                      Severity: Minor
                                      Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

                                        Method _doAnchors_reference_callback has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            protected function _doAnchors_reference_callback($matches) {
                                                $whole_match =  $matches[1];
                                                $link_text   =  $matches[2];
                                                $link_id     =& $matches[3];
                                        
                                        
                                        Severity: Minor
                                        Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

                                          Method stripLinkDefinitions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              protected function stripLinkDefinitions($text) {
                                              #
                                              # Strips link definitions from text, stores the URLs and titles in
                                              # hash references.
                                              #
                                          Severity: Minor
                                          Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

                                            Method stripLinkDefinitions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                protected function stripLinkDefinitions($text) {
                                                #
                                                # Strips link definitions from text, stores the URLs and titles in
                                                # hash references.
                                                #
                                            Severity: Minor
                                            Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

                                              Method _doAnchors_reference_callback has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                                  protected function _doAnchors_reference_callback($matches) {
                                                      $whole_match =  $matches[1];
                                                      $link_text   =  $matches[2];
                                                      $link_id     =& $matches[3];
                                              
                                              
                                              Severity: Minor
                                              Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

                                                Method doHeaders has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                    protected function doHeaders($text) {
                                                    #
                                                    # Redefined to add id and class attribute support.
                                                    #
                                                        # Setext-style headers:
                                                Severity: Minor
                                                Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

                                                  Method doFencedCodeBlocks has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                      protected function doFencedCodeBlocks($text) {
                                                      #
                                                      # Adding the fenced code block syntax to regular Markdown:
                                                      #
                                                      # ~~~
                                                  Severity: Minor
                                                  Found in include/lib/Michelf/Markdown.php - About 1 hr to fix

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

                                                        protected function _appendFootnotes_callback($matches) {
                                                            $node_id = $this->fn_id_prefix . $matches[1];
                                                            
                                                            # Create footnote marker only if it has a corresponding footnote *and*
                                                            # the footnote hasn't been used by another marker.
                                                    Severity: Minor
                                                    Found in include/lib/Michelf/Markdown.php - 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 _doImages_reference_callback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        protected function _doImages_reference_callback($matches) {
                                                            $whole_match = $matches[1];
                                                            $alt_text    = $matches[2];
                                                            $link_id     = strtolower($matches[3]);
                                                    
                                                    
                                                    Severity: Minor
                                                    Found in include/lib/Michelf/Markdown.php - About 35 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 _doAnchors_reference_callback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        protected function _doAnchors_reference_callback($matches) {
                                                            $whole_match =  $matches[1];
                                                            $link_text   =  $matches[2];
                                                            $link_id     =& $matches[3];
                                                    
                                                    
                                                    Severity: Minor
                                                    Found in include/lib/Michelf/Markdown.php - About 35 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 parseSpan has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        protected function parseSpan($str) {
                                                        #
                                                        # Take the string $str and parse it into tokens, hashing embeded HTML,
                                                        # escaped characters and handling code spans.
                                                        #
                                                    Severity: Minor
                                                    Found in include/lib/Michelf/Markdown.php - About 35 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 prepareItalicsAndBold has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        protected function prepareItalicsAndBold() {
                                                        #
                                                        # Prepare regular expressions for searching emphasis tokens in any
                                                        # context.
                                                        #
                                                    Severity: Minor
                                                    Found in include/lib/Michelf/Markdown.php - 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

                                                    There are no issues that match your filters.

                                                    Category
                                                    Status