mb-tec/laminas-logger

View on GitHub

Showing 8 of 26 total issues

Function getLogger has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    private function getLogger(string $logfile): Logger
    {
        if (!isset($this->loggers[$logfile])) {
            $logger = new Logger();

Severity: Minor
Found in src/Service/LoggerService.php - About 3 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

Function getLogger has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private static function getLogger(string $logfile): Logger
    {
        if (!isset(static::$loggers[$logfile])) {
            $config = static::getConfig();
            $logger = new Logger();
Severity: Minor
Found in src/StaticLogger.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 getLogger has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getLogger(string $logfile): Logger
    {
        if (!isset($this->loggers[$logfile])) {
            $logger = new Logger();

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

    Method getLogger has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function getLogger(string $logfile): Logger
        {
            if (!isset(static::$loggers[$logfile])) {
                $config = static::getConfig();
                $logger = new Logger();
    Severity: Minor
    Found in src/StaticLogger.php - About 1 hr to fix

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

          private function getFieldsData(array $messageRawData, array $baseOutput): array
          {
              $fields = [];
      
              if (count($messageRawData) > 1) {
      Severity: Minor
      Found in src/Formatter/SlackFormatter.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 log has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function log(int $prio, $msg, $logfile = null): void
          {
              if (is_null($logfile)) {
                  $logfile = self::LOGFILE_DEFAULT;
              }
      Severity: Minor
      Found in src/Service/LoggerService.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 log has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function log(int $prio, $msg, $logfile = null): void
          {
              if (is_null($logfile)) {
                  $logfile = self::LOGFILE_DEFAULT;
              }
      Severity: Minor
      Found in src/StaticLogger.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 getConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function getConfig(): array
          {
              if (!is_array(static::$config)) {
                  $configFile = dirname(dirname(dirname(dirname(dirname(__DIR__))))) . '/config/autoload/mbtec.laminas-logger.local.php';
                  if (file_exists($configFile)) {
      Severity: Minor
      Found in src/StaticLogger.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