railpage/railpagecore

View on GitHub
lib/Template_Cache_Memcache.php

Summary

Maintainability
C
1 day
Test Coverage

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

                $rs = $this->memcache->set($k, $v, 0, $expire);
Severity: Minor
Found in lib/Template_Cache_Memcache.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

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

        protected function read(array $keys)
        {
            #echo "reading template from cache";
            #printArray($keys);
            $_keys = $lookup = array();
Severity: Major
Found in lib/Template_Cache_Memcache.php and 1 other location - About 4 hrs to fix
lib/Template_Cache_Redis.php on lines 59..75

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

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

        protected function write(array $keys, $expire=null)
        {
            #echo "writing template to cache";
            #printArray($keys);
            foreach ($keys as $k => $v) {
Severity: Major
Found in lib/Template_Cache_Memcache.php and 1 other location - About 2 hrs to fix
lib/Template_Cache_Memcached.php on lines 87..99

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

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

        protected function delete(array $keys)
        {
            #echo "deleting template from cache";
            #printArray($keys);
            foreach ($keys as $k) {
Severity: Major
Found in lib/Template_Cache_Memcache.php and 2 other locations - About 1 hr to fix
lib/Template_Cache_Memcached.php on lines 107..119
lib/Template_Cache_Redis.php on lines 102..111

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

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

    if (!defined("RP_MEMCACHE_HOST")) {
        define("RP_MEMCACHE_HOST", "cache.railpage.com.au");
    }
Severity: Major
Found in lib/Template_Cache_Memcache.php and 7 other locations - About 50 mins to fix
lib/Formatting/MultimediaUtility.php on lines 27..29
lib/Users/User.php on lines 1346..1348
lib/AppCore.php on lines 38..40
lib/AppCore.php on lines 42..44
lib/AppCore.php on lines 46..48
lib/Module.php on lines 18..20
lib/Session.php on lines 70..72

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

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 class Template_Cache_Memcache is not named in CamelCase.
Open

    class Template_Cache_Memcache extends Smarty_CacheResource_KeyValueStore {
        /**
         * memcache instance
         * @var Memcache
         */
Severity: Minor
Found in lib/Template_Cache_Memcache.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Incorrect spacing between default value and equals sign for argument "$expire"; expected 1 but found 0
Open

        protected function write(array $keys, $expire=null)

Incorrect spacing between argument "$expire" and equals sign; expected 1 but found 0
Open

        protected function write(array $keys, $expire=null)

There must be one blank line after the namespace declaration
Open

    namespace Railpage;

Line indented incorrectly; expected 0 spaces, found 4
Open

    class Template_Cache_Memcache extends Smarty_CacheResource_KeyValueStore {

Line indented incorrectly; expected 4 spaces, found 8
Open

        }

Line indented incorrectly; expected 4 spaces, found 8
Open

        protected function write(array $keys, $expire=null)

Line indented incorrectly; expected 4 spaces, found 8
Open

        }

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 8 spaces, found 12
Open

            foreach ($keys as $k) {

Line indented incorrectly; expected 8 spaces, found 12
Open

            if (!class_exists("Memcache")) {

Line indented incorrectly; expected 4 spaces, found 8
Open

        protected $Memcached = null;

Line indented incorrectly; expected 8 spaces, found 12
Open

            }

Class name "Template_Cache_Memcache" is not in camel caps format
Open

    class Template_Cache_Memcache extends Smarty_CacheResource_KeyValueStore {

Line indented incorrectly; expected 4 spaces, found 8
Open

        protected function purge()

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

            foreach ($keys as $k => $v) {

Line indented incorrectly; expected 8 spaces, found 12
Open

            }

Line indented incorrectly; expected 4 spaces, found 8
Open

        protected function delete(array $keys)

Line indented incorrectly; expected 4 spaces, found 8
Open

        public function __construct()

Line indented incorrectly; expected 8 spaces, found 12
Open

            }

Line indented incorrectly; expected 0 spaces, found 4
Open

    if (!defined("RP_MEMCACHE_HOST")) {

Line indented incorrectly; expected 8 spaces, found 12
Open

            }

Line indented incorrectly; expected 8 spaces, found 12
Open

            foreach ($keys as $k) {

Line indented incorrectly; expected 4 spaces, found 8
Open

        }

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

    if (!defined("RP_MEMCACHE_PORT")) {

Line indented incorrectly; expected 4 spaces, found 8
Open

        protected function read(array $keys)

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 8 spaces, found 12
Open

            foreach ($res as $k => $v) {

There are no issues that match your filters.

Category
Status