railpage/railpagecore

View on GitHub
lib/Notifications/Transport/Push.php

Summary

Maintainability
A
3 hrs
Test Coverage

Method send has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function send() {
            
            $Client = new Client;
            
            $failures = array();
Severity: Minor
Found in lib/Notifications/Transport/Push.php - About 1 hr to fix

    Avoid unused local variables such as '$failures'.
    Open

                $failures = array();
    Severity: Minor
    Found in lib/Notifications/Transport/Push.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid unused local variables such as '$userdata'.
    Open

                foreach ($this->data['recipients'] as $user_id => $userdata) {
    Severity: Minor
    Found in lib/Notifications/Transport/Push.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid unused local variables such as '$unsub'.
    Open

                $unsub = [];
    Severity: Minor
    Found in lib/Notifications/Transport/Push.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

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

            public function setData($data) {
                
                if (!is_array($data)) {
                    throw new InvalidArgumentException("No or invalid message data was sent");
                }
    Severity: Major
    Found in lib/Notifications/Transport/Push.php and 1 other location - About 1 hr to fix
    lib/Notifications/Transport/Email.php on lines 47..53

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

    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

                    foreach ($subscriptions as $sub) {
                        $data['registration_ids'][] = $sub['registration_id'];
                    }
    Severity: Minor
    Found in lib/Notifications/Transport/Push.php and 1 other location - About 40 mins to fix
    lib/Sightings/Sightings.php on lines 49..51

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

    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

    Blank line found at end of control structure
    Open

                    

    Function closing brace must go on the next line following the body; found 1 blank lines before brace
    Open

            }

    Blank line found at end of control structure
    Open

                    

    Blank line found at start of control structure
    Open

                } catch (RequestException $e) {

    Function closing brace must go on the next line following the body; found 3 blank lines before brace
    Open

            }

    Blank line found at end of control structure
    Open

                     

    Function closing brace must go on the next line following the body; found 1 blank lines before brace
    Open

            }

    Function closing brace must go on the next line following the body; found 1 blank lines before brace
    Open

            }

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    foreach ($subscriptions as $sub) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($data['registration_ids'])) {

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        class Push extends AppCore implements TransportInterface {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!is_array($data)) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            private function removeStaleSubscriptions($result, $subscriptions) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                foreach ($result['results'] as $key => $val) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                foreach ($this->data['recipients'] as $user_id => $userdata) {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function send() {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                try {

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if (!isset($val['error'])) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function validate() {

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                } catch (RequestException $e) {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function setData($data) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    There are no issues that match your filters.

    Category
    Status