scriptotek/php-marc

View on GitHub

Showing 8 of 8 total issues

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

    public function jsonSerialize(): array|string
    {
        $o = [];
        foreach ($this->properties as $prop) {
            $value = $this->$prop;
Severity: Minor
Found in src/Record.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 getRecordType has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getRecordType(File_MARC_Record $record): string
    {
        $leader = $record->getLeader();
        $recordType = substr($leader, 6, 1);

Severity: Minor
Found in src/Collection.php - About 1 hr to fix

    Function mapSubFields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function mapSubFields(array $map, bool $includeNullValues = false): array
        {
            $o = [];
            foreach ($map as $code => $prop) {
                $value = $this->sf($code);
    Severity: Minor
    Found in src/Fields/Field.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

    Function get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function get(Record $record): array
        {
            $subjects = [];
    
            foreach (static::makeFieldObjects($record, '6..', true) as $subject) {
    Severity: Minor
    Found in src/Fields/Subject.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 getToc has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getToc(): ?array
        {
            $field = $this->getField('505');
            if ($field) {
                if ($field->getIndicator(2) === '0') {
    Severity: Minor
    Found in src/BibliographicRecord.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 jsonSerialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function jsonSerialize(): array|string
        {
            if (count($this->properties)) {
                $o = [];
                foreach ($this->properties as $prop) {
    Severity: Minor
    Found in src/Fields/SerializableField.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

    Avoid too many return statements within this method.
    Open

            return [];
    Severity: Major
    Found in src/Importers/XmlImporter.php - About 30 mins to fix

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

          public function __toString(): string
          {
              // $a is not repeated
              $a = $this->field->getSubfield('a');
              $title = $a ? trim($a->getData()) : '';
      Severity: Minor
      Found in src/Fields/Title.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