midasplatform/Midas

View on GitHub
core/database/upgrade/3.4.2.php

Summary

Maintainability
F
4 days
Test Coverage

Method mysql has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function mysql()
    {
        $this->db->query('DROP TABLE IF EXISTS `errorlog`;');
        $this->db->query('ALTER TABLE `assetstore` ADD KEY `name` (`name`);');
        $this->db->query('
Severity: Major
Found in core/database/upgrade/3.4.2.php - About 2 hrs to fix

Method sqlite has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function sqlite()
    {
        $this->db->query('DROP TABLE IF EXISTS "errorlog";');
        $this->db->query('CREATE INDEX IF NOT EXISTS "assetstore_name_idx" ON "assetstore" ("name");');
        $this->db->query('CREATE INDEX IF NOT EXISTS "bitstream_assetstore_id_idx" ON "bitstream" ("assetstore_id");');
Severity: Minor
Found in core/database/upgrade/3.4.2.php - About 1 hr to fix

Method pgsql has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function pgsql()
    {
        $this->db->query('DROP TABLE IF EXISTS "errorlog";');
        $this->db->query('ALTER TABLE "communityinvitation" ADD UNIQUE ("user_id", "group_id");');
        $this->db->query('ALTER TABLE "feed2community" ADD UNIQUE ("community_id", "feed_id");');
Severity: Minor
Found in core/database/upgrade/3.4.2.php - About 1 hr to fix

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

    public function pgsql()
    {
        $this->db->query('DROP TABLE IF EXISTS "errorlog";');
        $this->db->query('ALTER TABLE "communityinvitation" ADD UNIQUE ("user_id", "group_id");');
        $this->db->query('ALTER TABLE "feed2community" ADD UNIQUE ("community_id", "feed_id");');
Severity: Major
Found in core/database/upgrade/3.4.2.php and 1 other location - About 2 days to fix
core/database/upgrade/3.4.2.php on lines 130..170

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

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 sqlite()
    {
        $this->db->query('DROP TABLE IF EXISTS "errorlog";');
        $this->db->query('CREATE INDEX IF NOT EXISTS "assetstore_name_idx" ON "assetstore" ("name");');
        $this->db->query('CREATE INDEX IF NOT EXISTS "bitstream_assetstore_id_idx" ON "bitstream" ("assetstore_id");');
Severity: Major
Found in core/database/upgrade/3.4.2.php and 1 other location - About 2 days to fix
core/database/upgrade/3.4.2.php on lines 87..127

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

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

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Upgrade_3_4_2 extends MIDASUpgrade

The class Upgrade_3_4_2 is not named in CamelCase.
Open

class Upgrade_3_4_2 extends MIDASUpgrade
{
    /** Upgrade a MySQL database. */
    public function mysql()
    {
Severity: Minor
Found in core/database/upgrade/3.4.2.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

Line exceeds 120 characters; contains 122 characters
Open

        $this->db->query('CREATE INDEX IF NOT EXISTS "user_lastname_firstname_idx" ON "user" ("lastname", "firstname");');

Line exceeds 120 characters; contains 121 characters
Open

        $this->db->query('CREATE UNIQUE INDEX IF NOT EXISTS "setting_name_module_idx" ON "setting" ("name", "module");');

Line exceeds 120 characters; contains 136 characters
Open

        $this->db->query('CREATE INDEX IF NOT EXISTS "pendinguser_lastname_firstname_idx" ON "pendinguser" ("lastname", "firstname");');

Line exceeds 120 characters; contains 138 characters
Open

        $this->db->query('CREATE UNIQUE INDEX IF NOT EXISTS "itemrevision_item_revision_idx" ON "itemrevision" ("item_id", "revision");');

Line exceeds 120 characters; contains 147 characters
Open

        $this->db->query('CREATE UNIQUE INDEX IF NOT EXISTS "userapi_user_id_application_name_idx" ON "userapi" ("user_id", "application_name");');

Line exceeds 120 characters; contains 134 characters
Open

        $this->db->query('CREATE UNIQUE INDEX IF NOT EXISTS "user2group_group_user_id_idx" ON "user2group" ("group_id", "user_id");');

Line exceeds 120 characters; contains 129 characters
Open

        $this->db->query('CREATE INDEX IF NOT EXISTS "newuserinvitation_inviter_id_idx" ON "newuserinvitation" ("inviter_id");');

Line exceeds 120 characters; contains 123 characters
Open

        $this->db->query('CREATE INDEX "communityinvitation_idx_community_id" ON "communityinvitation" ("community_id");');

Line exceeds 120 characters; contains 152 characters
Open

        $this->db->query('CREATE UNIQUE INDEX IF NOT EXISTS "communityinvitation_user_group_id_idx" ON "communityinvitation" ("user_id", "group_id");');

Line exceeds 120 characters; contains 150 characters
Open

        $this->db->query('CREATE UNIQUE INDEX IF NOT EXISTS "feed2community_community_feed_id_idx" ON "feed2community" ("community_id", "feed_id");');

Line exceeds 120 characters; contains 122 characters
Open

        $this->db->query('CREATE INDEX "pendinguser_idx_lastname_firstname" ON "pendinguser" ("lastname", "firstname");');

Line exceeds 120 characters; contains 125 characters
Open

        $this->db->query('CREATE INDEX IF NOT EXISTS "newuserinvitation_group_id_idx" ON "newuserinvitation" ("group_id");');

Line exceeds 120 characters; contains 125 characters
Open

        $this->db->query('ALTER TABLE `userapi` ADD UNIQUE KEY `user_id_application_name` (`user_id`, `application_name`);');

Line exceeds 120 characters; contains 121 characters
Open

        $this->db->query('CREATE INDEX IF NOT EXISTS "community_membergroup_id_idx" ON "community" ("membergroup_id");');

Line exceeds 120 characters; contains 131 characters
Open

        $this->db->query('CREATE INDEX IF NOT EXISTS "metadatavalue_itemrevision_id_idx" ON "metadatavalue" ("itemrevision_id");');

Line exceeds 120 characters; contains 123 characters
Open

        $this->db->query('CREATE INDEX IF NOT EXISTS "bitstream_itemrevision_id_idx" ON "bitstream" ("itemrevision_id");');

Line exceeds 120 characters; contains 127 characters
Open

        $this->db->query('CREATE INDEX IF NOT EXISTS "community_moderatorgroup_id_idx" ON "community" ("moderatorgroup_id");');

Line exceeds 120 characters; contains 144 characters
Open

        $this->db->query('CREATE UNIQUE INDEX IF NOT EXISTS "feedpolicygroup_feed_group_id_idx" ON "feedpolicygroup" ("feed_id", "group_id");');

Line exceeds 120 characters; contains 140 characters
Open

        $this->db->query('CREATE UNIQUE INDEX IF NOT EXISTS "feedpolicyuser_feed_user_id_idx" ON "feedpolicyuser" ("feed_id", "user_id");');

Line exceeds 120 characters; contains 137 characters
Open

        $this->db->query('CREATE INDEX IF NOT EXISTS "communityinvitation_community_id_idx" ON "communityinvitation" ("community_id");');

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

class Upgrade_3_4_2 extends MIDASUpgrade

There are no issues that match your filters.

Category
Status