GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Xcloner_Activator::activate()   F
last analyzed

Complexity

Conditions 17
Paths > 20000

Size

Total Lines 97
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 2 Features 0
Metric Value
cc 17
eloc 42
c 4
b 2
f 0
nc 65536
nop 0
dl 0
loc 97
rs 1.0499

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * XCloner - Backup and Restore backup plugin for Wordpress
4
 *
5
 * class-xcloner-activator.php
6
 * @author Liuta Ovidiu <[email protected]>
7
 *
8
 *        This program is free software; you can redistribute it and/or modify
9
 *        it under the terms of the GNU General Public License as published by
10
 *        the Free Software Foundation; either version 2 of the License, or
11
 *        (at your option) any later version.
12
 *
13
 *        This program is distributed in the hope that it will be useful,
14
 *        but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *        GNU General Public License for more details.
17
 *
18
 *        You should have received a copy of the GNU General Public License
19
 *        along with this program; if not, write to the Free Software
20
 *        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
 *        MA 02110-1301, USA.
22
 *
23
 * @link https://github.com/ovidiul/XCloner-Wordpress
24
 *
25
 * @modified 7/31/18 3:28 PM
26
 *
27
 */
28
29
/**
30
 * Fired during plugin activation.
31
 *
32
 * This class defines all code necessary to run during the plugin's activation.
33
 *
34
 * @since      1.0.0
35
 * @package    Xcloner
36
 * @subpackage Xcloner/includes
37
 * @author     Liuta Ovidiu <[email protected]>
38
 * @link       http://www.thinkovi.com
39
 */
40
class Xcloner_Activator {
41
42
	/**
43
	 * XCloner Database Version
44
	 * @var string
45
	 */
46
	const xcloner_db_version = '1.1.7';
47
	/**
48
	 * Minimum required PHP version to run this plugin.
49
	 * @var string
50
	 */
51
	const xcloner_minimum_version = '5.6.0';
52
53
	/**
54
	 * Triggered when XCloner is activated.
55
	 *
56
	 * This method will get trigger once XCloner plugin is activated.
57
	 *
58
	 * @since    1.0.0
59
	 */
60
	public static function activate() {
61
62
		global $wpdb;
63
64
		if (version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<')) {
65
			wp_die('<p>'.sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"), Xcloner_Activator::xcloner_minimum_version, phpversion()).'</p>', __("XCloner Activation Error"), array('response'  => 500,
66
																																																																   'back_link' => true
67
			));
68
		}
69
70
		$charset_collate = $wpdb->get_charset_collate();
71
72
		$installed_ver = get_option("xcloner_db_version");
73
74
		$xcloner_db_version = Xcloner_Activator::xcloner_db_version;
75
76
		$xcloner_scheduler_table = $wpdb->prefix."xcloner_scheduler";
77
78
		if ($installed_ver != $xcloner_db_version) {
79
			$xcloner_schedule_sql = "CREATE TABLE `".$xcloner_scheduler_table."` (
80
				  `id` int(11) NOT NULL AUTO_INCREMENT,
81
				  `name` varchar(255) NOT NULL,
82
				  `recurrence` varchar(25) NOT NULL,
83
				  `params` text NOT NULL,
84
				  `start_at` datetime,
85
				  `remote_storage` varchar(10) DEFAULT NULL,
86
				  `hash` varchar(10) DEFAULT NULL,
87
				  `status` int(1) NOT NULL,
88
				  `last_backup` varchar(100) DEFAULT NULL,
89
				  PRIMARY KEY  (`id`)
90
				) " . $charset_collate.";
91
				";
92
93
			require_once(ABSPATH.'wp-admin/includes/upgrade.php');
94
			dbDelta($xcloner_schedule_sql);
95
96
			update_option("xcloner_db_version", $xcloner_db_version);
97
		}
98
99
		if (get_option('xcloner_backup_compression_level') === false) {
100
			update_option('xcloner_backup_compression_level', 0);
101
		}
102
103
		if (get_option('xcloner_enable_log') === false) {
104
			update_option('xcloner_enable_log', 1);
105
		}
106
107
		if (get_option('xcloner_enable_mysql_backup') === false) {
108
			update_option('xcloner_enable_mysql_backup', 1);
109
		}
110
111
		if (get_option('xcloner_system_settings_page') === false) {
112
			update_option('xcloner_system_settings_page', 100);
113
		}
114
115
		if (get_option('xcloner_files_to_process_per_request') === false) {
116
			update_option('xcloner_files_to_process_per_request', 250);
117
		}
118
119
		if (get_option('xcloner_database_records_per_request') === false) {
120
			update_option('xcloner_database_records_per_request', 10000);
121
		}
122
123
		if (get_option('xcloner_exclude_files_larger_than_mb') === false) {
124
			update_option('xcloner_exclude_files_larger_than_mb', 0);
125
		}
126
127
		if (get_option('xcloner_split_backup_limit') === false) {
128
			update_option('xcloner_split_backup_limit', 2048);
129
		}
130
131
		if (get_option('xcloner_size_limit_per_request') === false) {
132
			update_option('xcloner_size_limit_per_request', 50);
133
		}
134
135
		if (get_option('xcloner_cleanup_retention_limit_days') === false) {
136
			update_option('xcloner_cleanup_retention_limit_days', 60);
137
		}
138
139
		if (get_option('xcloner_cleanup_retention_limit_archives') === false) {
140
			update_option('xcloner_cleanup_retention_limit_archives', 100);
141
		}
142
143
		if (get_option('xcloner_directories_to_scan_per_request') === false) {
144
			update_option('xcloner_directories_to_scan_per_request', 25);
145
		}
146
147
		/*if(!get_option('xcloner_diff_backup_recreate_period'))
148
			update_option('xcloner_diff_backup_recreate_period', 10);
149
			* */
150
151
		if (!get_option('xcloner_regex_exclude')) {
152
			update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$");
153
		}
154
155
		if (!get_option('xcloner_regex_exclude')) {
156
			update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$");
157
		}
158
159
	}
160
161
}
162