core/EntityWithDBProperties.php

Summary

Maintainability
C
7 hrs
Test Coverage

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

    public function getAttributes(string $optionName = NULL, string $omittedOptionName = NULL)
    {
        if ($optionName !== NULL) {
            if ($optionName === $omittedOptionName) {
                throw new Exception("The attibute to be shown has the same name as that to be omitted");
Severity: Minor
Found in core/EntityWithDBProperties.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 isDataRestricted has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function isDataRestricted($table, $row_id)
    {
        if ($table != "institution_option" && $table != "profile_option" && $table != "federation_option" && $table != "user_options") {
            return []; // better safe than sorry: that's an error, so assume nobody is authorised to act on that data
        }
Severity: Minor
Found in core/EntityWithDBProperties.php - About 1 hr to fix

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

        public static function isDataRestricted($table, $row_id)
        {
            if ($table != "institution_option" && $table != "profile_option" && $table != "federation_option" && $table != "user_options") {
                return []; // better safe than sorry: that's an error, so assume nobody is authorised to act on that data
            }
    Severity: Minor
    Found in core/EntityWithDBProperties.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 levelPrecedenceAttributeJoin has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function levelPrecedenceAttributeJoin($existing, $new, $newlevel)
        {
            foreach ($new as $attrib) {
                $ignore = "";
                foreach ($existing as $approvedAttrib) {
    Severity: Minor
    Found in core/EntityWithDBProperties.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 too many return statements within this method.
    Open

                    return FALSE;
    Severity: Major
    Found in core/EntityWithDBProperties.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return $inst->listOwners();
      Severity: Major
      Found in core/EntityWithDBProperties.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return []; // better safe than sorry: that's an error, so assume nobody is authorised to act on that data
        Severity: Major
        Found in core/EntityWithDBProperties.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return [];
          Severity: Major
          Found in core/EntityWithDBProperties.php - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status