koselig/library

View on GitHub

Showing 59 of 59 total issues

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

    public static function acf($page = null, $name = null, $format = true)
    {
        if (!function_exists('acf_format_value')) {
            throw new UnsatisfiedDependencyException('Advanced Custom Fields must be installed to use field');
        }
Severity: Minor
Found in src/Models/Meta.php - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function template($slug, $action)
        {
            $action = $this->formatAction($action);
    
            $route = (new TemplateRoute($action['method'], $slug, $action))
    Severity: Major
    Found in src/Routing/Routing.php and 1 other location - About 1 hr to fix
    src/Routing/Routing.php on lines 70..81

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 104.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function page($slug, $action)
        {
            $action = $this->formatAction($action);
    
            $route = (new PageRoute($action['method'], $slug, $action))
    Severity: Major
    Found in src/Routing/Routing.php and 1 other location - About 1 hr to fix
    src/Routing/Routing.php on lines 18..29

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 104.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function acf has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function acf($page = null, $name = null, $format = true)
        {
            if (!function_exists('acf_format_value')) {
                throw new UnsatisfiedDependencyException('Advanced Custom Fields must be installed to use field');
            }
    Severity: Minor
    Found in src/Models/Meta.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 __call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __call($name, $arguments)
        {
            $name = Str::snake($name);
            $name = str_replace('has', 'have', $name);
    
    
    Severity: Minor
    Found in src/Proxy/Query.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

    Method addPage has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public static function addPage($pageTitle, $menuTitle, $capability, $slug, $action, $iconUrl = '', $position = null)
    Severity: Major
    Found in src/Admin/Page.php - About 50 mins to fix

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

          private function _do_query($query)
          {
              if (defined('SAVEQUERIES') && SAVEQUERIES) {
                  $this->timer_start();
              }
      Severity: Minor
      Found in src/Proxy/WordpressDatabase.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

      Method addSubpage has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public static function addSubpage($parent, $pageTitle, $menuTitle, $capabilities, $slug, $action)
      Severity: Minor
      Found in src/Admin/Page.php - About 45 mins to fix

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

            public static function get($page = null, $name = null)
            {
                if (is_object($page) && (is_subclass_of($page, Post::class) || $page instanceof Post)) {
                    $page = $page->ID;
                }
        Severity: Minor
        Found in src/Models/Meta.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

        The class Post has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13.
        Open

        class Post extends Model
        {
            use Rememberable;
        
            public $timestamps = false;
        Severity: Minor
        Found in src/Models/Post.php by phpmd

        CouplingBetweenObjects

        Since: 1.1.0

        A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

        Example

        class Foo {
            /**
             * @var \foo\bar\X
             */
            private $x = null;
        
            /**
             * @var \foo\bar\Y
             */
            private $y = null;
        
            /**
             * @var \foo\bar\Z
             */
            private $z = null;
        
            public function setFoo(\Foo $foo) {}
            public function setBar(\Bar $bar) {}
            public function setBaz(\Baz $baz) {}
        
            /**
             * @return \SplObjectStorage
             * @throws \OutOfRangeException
             * @throws \InvalidArgumentException
             * @throws \ErrorException
             */
            public function process(\Iterator $it) {}
        
            // ...
        }

        Source https://phpmd.org/rules/design.html#couplingbetweenobjects

        Method wp_mail has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
        Severity: Minor
        Found in src/Mail/Mailer.php - About 35 mins to fix

          Method name "WordpressDatabase::_do_query" is not in camel caps format
          Open

              private function _do_query($query)

          Method name "WordpressDatabase::db_connect" is not in camel caps format
          Open

              public function db_connect($allowBail = true)

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

              function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
              {
                  list($to, $subject, $headers, $attachments) = array_values(
                      Action::filter('wp_mail', [$to, $subject, $message, $headers, $attachments])
                  );
          Severity: Minor
          Found in src/Mail/Mailer.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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function add($key, $value, $group = 'default', $expiration = 0)
              {
                  if (wp_suspend_cache_addition()) {
                      return false;
                  }
          Severity: Minor
          Found in src/Proxy/WordpressCache.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

          Method name "WordpressDatabase::has_cap" is not in camel caps format
          Open

              public function has_cap($capability)

          Method name "WordpressDatabase::check_connection" is not in camel caps format
          Open

              public function check_connection($allowBail = true)

          Method name "WordpressDatabase::_real_escape" is not in camel caps format
          Open

              public function _real_escape($string)

          Method name "WordpressDatabase::set_sql_mode" is not in camel caps format
          Open

              public function set_sql_mode($modes = [])

          Method name "WordpressDatabase::db_version" is not in camel caps format
          Open

              public function db_version()
          Severity
          Category
          Status
          Source
          Language