lokal-profil/mediawiki-extensions-Wikispeech

View on GitHub

Showing 13 of 21 total issues

Function isValidRemoveTags has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function isValidRemoveTags( $removeTags ) {
        if ( !is_array( $removeTags ) ) {
            return false;
        }
        foreach ( $removeTags as $tagName => $rule ) {
Severity: Minor
Found in includes/ApiWikispeech.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 addContent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function addContent( $node ) {
        if ( !$node instanceof DOMComment && !$this->matchesRemove( $node ) ) {
            foreach ( $node->childNodes as $child ) {
                if (
                    !self::lastElement( $this->cleanedContent )
Severity: Minor
Found in includes/Cleaner.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 processPageContent has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function processPageContent(
        $displayTitle,
        $pageContent,
        $outputFormats,
        $removeTags,
Severity: Minor
Found in includes/ApiWikispeech.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 matchesRemove has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function matchesRemove( $node ) {
        if ( !array_key_exists( $node->nodeName, $this->removeTags ) ) {
            // The node name isn't found in the removal list.
            return false;
        }
Severity: Minor
Found in includes/Cleaner.php - About 55 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

Avoid deeply nested control flow statements.
Open

                        if ( offset <= maxOffset ) {
                            // For the last node, check if position is
                            // before end of utterance.
                            return true;
                        }
Severity: Major
Found in modules/ext.wikispeech.storage.js - About 45 mins to fix

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

        private function addSegment( $text, $startOffset=0 ) {
            if ( $this->currentSegment['startOffset'] === null ) {
                // Move the start offset ahead by the number of leading
                // whitespaces. This means that whitespaces before or
                // between segments aren't included.
    Severity: Minor
    Found in includes/Segmenter.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

    Method processPageContent has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            $displayTitle,
            $pageContent,
            $outputFormats,
            $removeTags,
            $segmentBreakingTags
    Severity: Minor
    Found in includes/ApiWikispeech.php - About 35 mins to fix

      Function isPointInItems has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                  node,
                  items,
                  offset,
                  minOffset,
                  maxOffset
      Severity: Minor
      Found in modules/ext.wikispeech.storage.js - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

                    return false;
        Severity: Major
        Found in modules/ext.wikispeech.storage.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return false;
          Severity: Major
          Found in modules/ext.wikispeech.ui.js - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return false;
            Severity: Major
            Found in includes/Cleaner.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return true;
              Severity: Major
              Found in includes/ApiWikispeech.php - About 30 mins to fix

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

                    private static function isSentenceFinal( $string, $index ) {
                        $character = mb_substr( $string, $index, 1 );
                        $nextCharacter = null;
                        if ( mb_strlen( $string ) > $index + 1 ) {
                            $nextCharacter = mb_substr( $string, $index + 1, 1 );
                Severity: Minor
                Found in includes/Segmenter.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

                Severity
                Category
                Status
                Source
                Language