railpage/railpagecore

View on GitHub
lib/Organisations/Organisation.php

Summary

Maintainability
D
1 day
Test Coverage

The class Organisation has 16 fields. Consider redesigning Organisation to keep the number of fields under 15.
Open

    class Organisation extends Base {
        
        /**
         * Registry key
         * @since Version 3.9.1
Severity: Minor
Found in lib/Organisations/Organisation.php by phpmd

TooManyFields

Since: 0.1

Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

Example

class Person {
   protected $one;
   private $two;
   private $three;
   [... many more fields ...]
}

Source https://phpmd.org/rules/codesize.html#toomanyfields

Method populate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private function populate() {
            
            $timer = Debug::getTimer(); 
            
            $this->mckey = sprintf("railpage:organisations.organisation=%d", $this->id); 
Severity: Minor
Found in lib/Organisations/Organisation.php - About 1 hr to fix

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

            private function validate() {
                if (empty($this->slug)) {
                    $this->slug = parent::createSlug();
                }
                
    Severity: Minor
    Found in lib/Organisations/Organisation.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

    The method __construct has a boolean flag argument $id, which is a certain sign of a Single Responsibility Principle violation.
    Open

            public function __construct($id = false) {
    Severity: Minor
    Found in lib/Organisations/Organisation.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    The method yieldJobs has a boolean flag argument $DateTo, which is a certain sign of a Single Responsibility Principle violation.
    Open

            public function yieldJobs($DateFrom = false, $DateTo = false) {
    Severity: Minor
    Found in lib/Organisations/Organisation.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    The method yieldJobs has a boolean flag argument $DateFrom, which is a certain sign of a Single Responsibility Principle violation.
    Open

            public function yieldJobs($DateFrom = false, $DateTo = false) {
    Severity: Minor
    Found in lib/Organisations/Organisation.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    Avoid assigning values to variables in if clauses and the like (line '215', column '18').
    Open

            private function populate() {
                
                $timer = Debug::getTimer(); 
                
                $this->mckey = sprintf("railpage:organisations.organisation=%d", $this->id); 
    Severity: Minor
    Found in lib/Organisations/Organisation.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

    The method commit uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    // Insert
                    
                    $this->db->insert("organisation", $data); 
                    $this->id = intval($this->db->lastInsertId());
    Severity: Minor
    Found in lib/Organisations/Organisation.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

    Source https://phpmd.org/rules/cleancode.html#elseexpression

    The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $this->id = $this->db->fetchOne("SELECT organisation_id FROM organisation WHERE organisation_slug = ?", $id); 
                }
    Severity: Minor
    Found in lib/Organisations/Organisation.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

    Source https://phpmd.org/rules/cleancode.html#elseexpression

    Avoid assigning values to variables in if clauses and the like (line '279', column '17').
    Open

            private function loadRoles() {
                
                // Get the roles for this organisation
                $query = "SELECT * FROM organisation_roles WHERE organisation_id = ?";
                
    Severity: Minor
    Found in lib/Organisations/Organisation.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

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

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

                if (!$row = $this->Memcached->fetch($this->mckey)) {
                    $query = "SELECT o.* FROM organisation AS o WHERE organisation_id = ?";
                    $row = $this->db->fetchRow($query, $this->id);
                    
                    $this->Memcached->save($this->mckey, $row);
    Severity: Major
    Found in lib/Organisations/Organisation.php and 4 other locations - About 2 hrs to fix
    lib/Glossary/Entry.php on lines 152..158
    lib/News/Article.php on lines 375..384
    lib/PrivateMessages/Message.php on lines 250..261
    lib/Timetables/Train.php on lines 164..169

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

    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 4 locations. Consider refactoring.
    Open

                foreach ($nulls as $var) {
                    if (is_null($this->$var)) {
                        $this->$var = "";
                    }
                }
    Severity: Major
    Found in lib/Organisations/Organisation.php and 3 other locations - About 1 hr to fix
    lib/Locations/Location.php on lines 434..438
    lib/Locos/Liveries/Livery.php on lines 298..302
    lib/Locos/Locomotive.php on lines 648..652

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

    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

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

                    "url" => $this->url instanceof Url ? $this->url->getURLs() : array("url" => $this->url)
    Severity: Major
    Found in lib/Organisations/Organisation.php and 2 other locations - About 1 hr to fix
    lib/Locations/Location.php on lines 963..963
    lib/Place.php on lines 366..366

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

    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

                $nulls = [ "contact_website", "contact_phone", "contact_fax", "contact_email", "logo", "flickr_photo_id" ];
    Severity: Minor
    Found in lib/Organisations/Organisation.php and 1 other location - About 45 mins to fix
    lib/Locations/Location.php on lines 432..432

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

    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 setOwner(User $User) {
                $this->owner = $User->id;
                return $this;
            }
    Severity: Minor
    Found in lib/Organisations/Organisation.php and 1 other location - About 45 mins to fix
    lib/Forums/Thread.php on lines 609..613

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

    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 ($this->db->fetchAll($query, array($this->id, $DateFrom->format("Y-m-d"), $DateTo->format("Y-m-d"))) as $row) {
    Severity: Minor
    Found in lib/Organisations/Organisation.php and 1 other location - About 45 mins to fix
    lib/Module.php on lines 279..283

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

    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 5 locations. Consider refactoring.
    Open

                if (!$DateFrom instanceof DateTime) {
                    $DateFrom = new DateTime;
                }
    Severity: Major
    Found in lib/Organisations/Organisation.php and 4 other locations - About 40 mins to fix
    lib/Chronicle/Chronicle.php on lines 79..81
    lib/Events/EventCategory.php on lines 182..184
    lib/Events/Events.php on lines 76..78
    lib/Users/Base.php on lines 149..151

    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

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

                if (filter_var($id, FILTER_VALIDATE_INT)) {
                    $this->id = filter_var($id, FILTER_VALIDATE_INT);
                } else {
                    $this->id = $this->db->fetchOne("SELECT organisation_id FROM organisation WHERE organisation_slug = ?", $id); 
                }
    Severity: Minor
    Found in lib/Organisations/Organisation.php and 1 other location - About 40 mins to fix
    lib/Locos/Locomotive.php on lines 340..344

    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

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

                foreach ($Events->getUpcomingEventsForOrganisation($this) as $date) {
                    foreach ($date as $row) {
                        yield new EventDate($row['event_date']);
                    }
                }
    Severity: Minor
    Found in lib/Organisations/Organisation.php and 1 other location - About 40 mins to fix
    lib/Ideas/Category.php on lines 107..113

    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

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

                foreach ($lookup as $var => $val) {
                    $this->$var = $row[$val];
                }
    Severity: Minor
    Found in lib/Organisations/Organisation.php and 1 other location - About 40 mins to fix
    lib/Users/User.php on lines 1092..1094

    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

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

                if (empty($this->slug)) {
                    $this->slug = parent::createSlug();
                }
    Severity: Minor
    Found in lib/Organisations/Organisation.php and 1 other location - About 35 mins to fix
    lib/Organisations/Organisation.php on lines 309..311

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

    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

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

                if (empty($this->slug)) {
                    $this->slug = parent::createSlug();
                }
    Severity: Minor
    Found in lib/Organisations/Organisation.php and 1 other location - About 35 mins to fix
    lib/Organisations/Organisation.php on lines 256..258

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

    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 (empty($this->created)) {
                    $this->created = time(); 
                }
    Severity: Minor
    Found in lib/Organisations/Organisation.php and 1 other location - About 35 mins to fix
    lib/Forums/Thread.php on lines 300..302

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

    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 ($result as $row) {
                        $this->roles[$row['role_id']] = $row['role_name'];
                    }
    Severity: Minor
    Found in lib/Organisations/Organisation.php and 1 other location - About 35 mins to fix
    lib/Forums/Category.php on lines 102..104

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

    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

                    $this->id = $this->db->fetchOne("SELECT organisation_id FROM organisation WHERE organisation_slug = ?", $id); 
    Severity: Minor
    Found in lib/Organisations/Organisation.php and 1 other location - About 30 mins to fix
    lib/Locations/Location.php on lines 294..294

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

    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

    The parameter $DateTo is not named in camelCase.
    Open

            public function yieldJobs($DateFrom = false, $DateTo = false) {
                if (!$DateFrom instanceof DateTime) {
                    $DateFrom = new DateTime;
                }
                
    Severity: Minor
    Found in lib/Organisations/Organisation.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $User is not named in camelCase.
    Open

            public function setOwner(User $User) {
                $this->owner = $User->id;
                return $this;
            }
    Severity: Minor
    Found in lib/Organisations/Organisation.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $DateFrom is not named in camelCase.
    Open

            public function yieldJobs($DateFrom = false, $DateTo = false) {
                if (!$DateFrom instanceof DateTime) {
                    $DateFrom = new DateTime;
                }
                
    Severity: Minor
    Found in lib/Organisations/Organisation.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    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

            }

    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

                    

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $created;

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $desc;

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $roles;

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        class Organisation extends Base {

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $url;

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                } else {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->slug)) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$DateFrom instanceof DateTime) {

    Line indented incorrectly; expected 0 spaces, found 4
    Open

        }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $id;

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $contact_website;

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (filter_var($this->id, FILTER_VALIDATE_INT)) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function __construct($id = false) {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $contact_fax;

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $flickr_photo_id;

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                foreach ($lookup as $var => $val) {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $contact_phone;

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            private function loadRoles() {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $name;

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $owner;

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $contact_email;

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $members;

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->slug)) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->name)) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->created)) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function commit() {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$this->id) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$DateTo instanceof DateTime) {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $logo;

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $mckey;

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                } else {

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                foreach ($Events->getUpcomingEventsForOrganisation($this) as $date) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function setOwner(User $User) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function operator_id() {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function yieldJobs($DateFrom = false, $DateTo = false) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                foreach ($this->db->fetchAll($query, array($this->id, $DateFrom->format("Y-m-d"), $DateTo->format("Y-m-d"))) as $row) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (filter_var($id, FILTER_VALIDATE_INT)) {

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    foreach ($result as $row) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if ($result = $this->db->fetchAll($query, $this->id)) {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            private function validate() {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (empty($this->desc)) {

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    if (is_null($this->$var)) {

    Line indented incorrectly; expected 4 spaces, found 8
    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

            }

    Line indented incorrectly; expected 12 spaces, found 16
    Open

                    foreach ($date as $row) {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public $slug;

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            private function populate() {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function getArray() {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                foreach ($nulls as $var) {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            public function yieldUpcomingEvents() {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (!$row = $this->Memcached->fetch($this->mckey)) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                }

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                if (filter_var($this->id, FILTER_VALIDATE_INT)) {

    Line indented incorrectly; expected 4 spaces, found 8
    Open

            }

    There are no issues that match your filters.

    Category
    Status