wikimedia/mediawiki-core

View on GitHub
includes/Revision/SlotRecord.php

Summary

Maintainability
C
1 day
Test Coverage

SlotRecord has 30 functions (exceeds 20 allowed). Consider refactoring.
Open

class SlotRecord {
    use NonSerializableTrait;

    public const MAIN = 'main';

Severity: Minor
Found in includes/Revision/SlotRecord.php - About 3 hrs to fix

    File SlotRecord.php has 293 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Value object representing a content slot associated with a page revision.
     *
     * This program is free software; you can redistribute it and/or modify
    Severity: Minor
    Found in includes/Revision/SlotRecord.php - About 3 hrs to fix

      Method newSaved has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function newSaved(
              int $revisionId,
              ?int $contentId,
              string $contentAddress,
              SlotRecord $protoSlot
      Severity: Minor
      Found in includes/Revision/SlotRecord.php - About 1 hr to fix

        Method __construct has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __construct( \stdClass $row, $content, bool $derived = false ) {
                Assert::parameterType( [ 'Content', 'callable' ], $content, '$content' );
        
                Assert::parameter(
                    property_exists( $row, 'slot_revision_id' ),
        Severity: Minor
        Found in includes/Revision/SlotRecord.php - About 1 hr to fix

          Function newSaved has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function newSaved(
                  int $revisionId,
                  ?int $contentId,
                  string $contentAddress,
                  SlotRecord $protoSlot
          Severity: Minor
          Found in includes/Revision/SlotRecord.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

          Avoid too many return statements within this method.
          Open

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

            Avoid too many return statements within this method.
            Open

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

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

                  private function getField( $name ) {
                      if ( !isset( $this->row->$name ) ) {
                          // distinguish between unknown and uninitialized fields
                          if ( property_exists( $this->row, $name ) ) {
                              throw new IncompleteRevisionException(
              Severity: Minor
              Found in includes/Revision/SlotRecord.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

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

                  public function hasSameContent( SlotRecord $other ) {
                      if ( $other === $this ) {
                          return true;
                      }
              
              
              Severity: Minor
              Found in includes/Revision/SlotRecord.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