keboola/syrup-component-bundle

View on GitHub
Monolog/Formatter/SyrupJsonFormatter.php

Summary

Maintainability
B
6 hrs
Test Coverage

Method format has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function format(array $record)
    {
        if ($this->storageApi == null) {
            try {
                $this->storageApi = $this->storageApiService->getClient();
Severity: Major
Found in Monolog/Formatter/SyrupJsonFormatter.php - About 2 hrs to fix

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

        public function format(array $record)
        {
            if ($this->storageApi == null) {
                try {
                    $this->storageApi = $this->storageApiService->getClient();
    Severity: Minor
    Found in Monolog/Formatter/SyrupJsonFormatter.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 logToSapi has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function logToSapi($record)
        {
            $sapiEvent = new Event();
            $sapiEvent->setComponent($this->appName);
            $sapiEvent->setMessage($record['message']);
    Severity: Minor
    Found in Monolog/Formatter/SyrupJsonFormatter.php - About 1 hr to fix

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

          protected function logToSapi($record)
          {
              $sapiEvent = new Event();
              $sapiEvent->setComponent($this->appName);
              $sapiEvent->setMessage($record['message']);
      Severity: Minor
      Found in Monolog/Formatter/SyrupJsonFormatter.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

      Consider simplifying this complex logical expression.
      Open

              if ($this->storageApi != null && $this->appName != null && $record['level'] != Logger::DEBUG
                  && $record['channel'] != 'event' && $record['channel'] != 'request' && $record['channel'] != 'doctrine') {
                  $this->logToSapi($record);
              }
      Severity: Major
      Found in Monolog/Formatter/SyrupJsonFormatter.php - About 40 mins to fix

        There are no issues that match your filters.

        Category
        Status