NightlyUpdatesCron   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 18.75 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 6
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSchedule() 0 4 1
A process() 6 14 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * These nightly updates can clean up anything that might have been missed by the other tasks
5
 */
6
class NightlyUpdatesCron implements CronTask
7
{
8
9
    /**
10
     * Run at 1am every morning
11
     *
12
     * @return string
13
     */
14
    public function getSchedule()
15
    {
16
        return "0 1 * * *";
17
    }
18
19
    /**
20
     * Run the build task CacheHelpfulRobotDataTask
21
     * @return void
22
     */
23
    public function process()
24
    {
25
        $taskClasses = [
26
            [BuildAddonsTask::class, null], // rebuild all addons
27
            [CacheHelpfulRobotDataTask::class, null], // fetch helpful robot data
28
        ];
29
30 View Code Duplication
        foreach ($taskClasses as $taskInfo) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
            list($taskClass, $taskQuerystring) = $taskInfo;
32
            $job = new RunBuildTaskJob($taskClass, $taskQuerystring);
33
            $jobID = Injector::inst()->get(QueuedJobService::class)->queueJob($job);
34
            echo 'Added ' . $taskClass . ' to job queue (job ID ' . $jobID . ")\n";
35
        }
36
    }
37
}
38