fenos/Notifynder

View on GitHub

Showing 27 of 27 total issues

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

<?php

namespace Fenos\Notifynder\Traits;

use Fenos\Notifynder\Models\Notification;
Severity: Major
Found in src/Notifynder/Traits/Notifable.php and 1 other location - About 5 hrs to fix
src/Notifynder/Traits/NotifableLaravel53.php on lines 1..60

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 150.

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

<?php

namespace Fenos\Notifynder\Traits;

use Fenos\Notifynder\Models\Notification;
Severity: Major
Found in src/Notifynder/Traits/NotifableLaravel53.php and 1 other location - About 5 hrs to fix
src/Notifynder/Traits/Notifable.php on lines 1..60

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 150.

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

Builder has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class Builder implements ArrayAccess
{
    /**
     * @var Notification
     */
Severity: Minor
Found in src/Notifynder/Builder/Builder.php - About 2 hrs to fix

    Function mixedGet has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function mixedGet($object, $key, $default = null)
        {
            if (is_null($key) || trim($key) == '') {
                return '';
            }
    Severity: Minor
    Found in src/Notifynder/Parsers/NotificationParser.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

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

                if (is_object($object) && method_exists($object, 'getAttribute') && ! is_null($object->getAttribute($segment))) {
                    $object = $object->getAttribute($segment);
                    continue;
                }
    Severity: Major
    Found in src/Notifynder/Parsers/NotificationParser.php and 1 other location - About 1 hr to fix
    src/Notifynder/Parsers/NotificationParser.php on lines 100..103

    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 59.

    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

                if (is_object($object) && method_exists($object, '__get') && ! is_null($object->__get($segment))) {
                    $object = $object->__get($segment);
                    continue;
                }
    Severity: Major
    Found in src/Notifynder/Parsers/NotificationParser.php and 1 other location - About 1 hr to fix
    src/Notifynder/Parsers/NotificationParser.php on lines 104..107

    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 59.

    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 static function isString($value, $strict = true)
        {
            if (! is_string($value)) {
                if ($strict) {
                    throw new InvalidArgumentException('The value passed must be a string');
    Severity: Major
    Found in src/Notifynder/Helpers/TypeChecker.php and 1 other location - About 1 hr to fix
    src/Notifynder/Helpers/TypeChecker.php on lines 41..52

    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 58.

    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 static function isNumeric($value, $strict = true)
        {
            if (! is_numeric($value)) {
                if ($strict) {
                    throw new InvalidArgumentException('The value passed must be a number');
    Severity: Major
    Found in src/Notifynder/Helpers/TypeChecker.php and 1 other location - About 1 hr to fix
    src/Notifynder/Helpers/TypeChecker.php on lines 22..33

    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 58.

    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

    Avoid using short method names like Notification::to(). The configured minimum method name length is 3.
    Open

        public function to()
        {
            if (notifynder_config()->isPolymorphic()) {
                return $this->morphTo('to');
            }

    ShortMethodName

    Since: 0.2

    Detects when very short method names are used.

    Example

    class ShortMethod {
        public function a( $index ) { // Violation
        }
    }

    Source https://phpmd.org/rules/naming.html#shortmethodname

    Avoid using short method names like Builder::to(). The configured minimum method name length is 3.
    Open

        public function to()
        {
            $args = func_get_args();
            $this->setEntityData($args, 'to');
    
    
    Severity: Minor
    Found in src/Notifynder/Builder/Builder.php by phpmd

    ShortMethodName

    Since: 0.2

    Detects when very short method names are used.

    Example

    class ShortMethod {
        public function a( $index ) { // Violation
        }
    }

    Source https://phpmd.org/rules/naming.html#shortmethodname

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null);
    Severity: Minor
    Found in src/Notifynder/Traits/Notifable.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null);

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

                $id = $entity[1];
    Severity: Minor
    Found in src/Notifynder/Builder/Builder.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

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

        public function parse($notification)
        {
            $category = $notification->category;
            if (is_null($category)) {
                throw (new ModelNotFoundException)->setModel(
    Severity: Minor
    Found in src/Notifynder/Parsers/NotificationParser.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

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

        public function from()
        {
            if (notifynder_config()->isPolymorphic()) {
                return $this->morphTo('from');
            }
    Severity: Minor
    Found in src/Notifynder/Models/Notification.php and 1 other location - About 40 mins to fix
    src/Notifynder/Models/Notification.php on lines 100..107

    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 44.

    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 to()
        {
            if (notifynder_config()->isPolymorphic()) {
                return $this->morphTo('to');
            }
    Severity: Minor
    Found in src/Notifynder/Models/Notification.php and 1 other location - About 40 mins to fix
    src/Notifynder/Models/Notification.php on lines 88..95

    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 44.

    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

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

        abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null);
    Severity: Minor
    Found in src/Notifynder/Traits/Notifable.php - About 35 mins to fix

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

          abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null);
      Severity: Minor
      Found in src/Notifynder/Traits/NotifableLaravel53.php - About 35 mins to fix

        Missing class import via use statement (line '44', column '23').
        Open

                    throw new \ReflectionException("Class {$model} does not exist");

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Missing class import via use statement (line '14', column '23').
        Open

                    throw new \UnexpectedValueException("The callback isn't callable.");

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Severity
        Category
        Status
        Source
        Language