Completed
Push — master ( f2f236...86f141 )
by Julius
08:20 queued 10s
created

Version030702Date20200626072306   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 83
Duplicated Lines 21.69 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 10
lcom 0
cbo 2
dl 18
loc 83
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A preSchemaChange() 0 2 1
B changeSchema() 18 58 8
A postSchemaChange() 0 2 1

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
declare(strict_types=1);
4
5
namespace OCA\Richdocuments\Migration;
6
7
use Closure;
8
use OCP\DB\ISchemaWrapper;
9
use OCP\Migration\SimpleMigrationStep;
10
use OCP\Migration\IOutput;
11
12
/**
13
 * Auto-generated migration step: Please modify to your needs!
14
 */
15
class Version030702Date20200626072306 extends SimpleMigrationStep {
16
17
	/**
18
	 * @param IOutput $output
19
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
20
	 * @param array $options
21
	 */
22
	public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
23
	}
24
25
	/**
26
	 * @param IOutput $output
27
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
28
	 * @param array $options
29
	 * @return null|ISchemaWrapper
30
	 */
31
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
32
		/** @var ISchemaWrapper $schema */
33
		$schema = $schemaClosure();
34
35
		$table = $schema->getTable('richdocuments_wopi');
36
37
		if (!$table->hasColumn('template_id')) {
38
			$table->addColumn('template_id', 'integer', [
39
				'notnull' => false,
40
				'length' => 4,
41
			]);
42
		}
43
44 View Code Duplication
		if (!$table->hasColumn('hide_download')) {
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...
45
			$table->addColumn('hide_download', 'boolean', [
46
				'notnull' => true,
47
				'default' => false,
48
			]);
49
		}
50
51
		if (!$table->hasColumn('share')) {
52
			$table->addColumn('share', 'string', [
53
				'notnull' => false,
54
				'length' => 64
55
			]);
56
		}
57
58 View Code Duplication
		if (!$table->hasColumn('direct')) {
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...
59
			$table->addColumn('direct', 'boolean', [
60
				'notnull' => true,
61
				'default' => false,
62
			]);
63
		}
64 View Code Duplication
		if (!$table->hasColumn('is_remote_token')) {
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...
65
			$table->addColumn('is_remote_token', 'boolean', [
66
				'notnull' => true,
67
				'default' => false,
68
			]);
69
		}
70
71
		if (!$table->hasColumn('remote_server')) {
72
			$table->addColumn('remote_server', 'string', [
73
				'notnull' => true,
74
				'default' => '',
75
			]);
76
77
		}
78
		if (!$table->hasColumn('remote_server_token')) {
79
			$table->addColumn('remote_server_token', 'string', [
80
				'notnull' => true,
81
				'length' => 32,
82
				'default' => '',
83
			]);
84
		}
85
86
87
		return $schema;
88
	}
89
90
	/**
91
	 * @param IOutput $output
92
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
93
	 * @param array $options
94
	 */
95
	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
96
	}
97
}
98