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.
Passed
Push — master ( 70bbd7...41de00 )
by Christian
02:53
created

Setup::activation()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
c 0
b 0
f 0
nc 3
nop 1
dl 0
loc 14
rs 9.9332
1
<?php
0 ignored issues
show
introduced by
Filenames should be all lowercase with hyphens as word separators. Expected setup.php, but found Setup.php.
Loading history...
introduced by
Class file names should be based on the class name with "class-" prepended. Expected class-setup.php, but found Setup.php.
Loading history...
2
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
3
 * @author    Podlove <[email protected]>
4
 * @copyright Copyright (c) 2014-2018, Podlove
5
 * @license   https://github.com/podlove/podlove-subscribe-button-wp-plugin/blob/master/LICENSE MIT
6
 * @package   Podlove\PodloveSubscribeButton
7
 */
8
9
namespace PodloveSubscribeButton;
10
11
class Setup {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for class Setup
Loading history...
12
13
	public static function activation( $network_wide ) {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function activation()
Loading history...
14
15
		global $wpdb;
16
17
		if ( $network_wide ) {
18
			Model\NetworkButton::build();
19
			set_time_limit(0); // may take a while, depending on network size
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
20
			$blogids = $wpdb->get_col( "SELECT blog_id FROM " . $wpdb->blogs );
0 ignored issues
show
introduced by
Usage of a direct database call is discouraged.
Loading history...
introduced by
Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().
Loading history...
Coding Style Comprehensibility introduced by
The string literal SELECT blog_id FROM does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
21
			foreach ( $blogids as $blog_id ) {
22
				switch_to_blog( $blog_id );
23
				self::activate_for_current_blog();
24
			}
25
		} else {
26
			self::activate_for_current_blog();
27
		}
28
29
	}
30
31
	public static function activate_for_current_blog() {
0 ignored issues
show
Coding Style introduced by
Method name "Setup::activate_for_current_blog" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function activate_for_current_blog()
Loading history...
32
33
		// Build Databases
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
34
		Model\Button::build();
35
36
		$default_values = Defaults::options();
37
38
//		add_option( 'podlove_psb_defaults', $default_values );
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
Coding Style introduced by
Expected 1 space before comment text but found 6; use block comment if you need indentation
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
Coding Style introduced by
There should be no blank line after an inline comment.
Loading history...
39
40
		foreach ( $default_values as $option => $default_value ) {
41
			if ( ! get_option( 'podlove_subscribe_button_default_' . $option ) ) {
42
				update_option( 'podlove_subscribe_button_default_' . $option, $default_value );
43
			}
44
		}
45
46
	}
47
48
	public static function deactivation( $network_wide ) {
0 ignored issues
show
Unused Code introduced by
The parameter $network_wide is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

48
	public static function deactivation( /** @scrutinizer ignore-unused */ $network_wide ) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style Documentation introduced by
Missing doc comment for function deactivation()
Loading history...
49
50
	}
51
52
	public static function uninstall() {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function uninstall()
Loading history...
53
		if ( is_multisite() ) {
54
			self::uninstall_for_network();
55
		} else {
56
			self::uninstall_for_current_blog();
57
		}
58
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
59
60
	public static function uninstall_for_network() {
0 ignored issues
show
Coding Style introduced by
Method name "Setup::uninstall_for_network" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function uninstall_for_network()
Loading history...
61
62
		global $wpdb;
63
64
		Model\NetworkButton::destroy();
65
66
		$current_blog = $wpdb->blogid;
67
		$blogids      = $wpdb->get_col( "SELECT blog_id FROM " . $wpdb->blogs );
0 ignored issues
show
introduced by
Usage of a direct database call is discouraged.
Loading history...
introduced by
Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().
Loading history...
Coding Style Comprehensibility introduced by
The string literal SELECT blog_id FROM does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
68
69
		foreach ( $blogids as $blog_id ) {
70
			switch_to_blog( $blog_id );
71
			self::uninstall_for_current_blog();
72
		}
73
74
		switch_to_blog( $current_blog );
75
76
//		$options = array(
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 6; use block comment if you need indentation
Loading history...
77
//			/** 1.4+ */
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 10; use block comment if you need indentation
Loading history...
78
//			'podlove_subscribe_button_defaults',
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 10; use block comment if you need indentation
Loading history...
79
//		);
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 6; use block comment if you need indentation
Loading history...
80
//
81
//		foreach ( $options as $option ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 6; use block comment if you need indentation
Loading history...
82
//			delete_site_option( $option );
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 10; use block comment if you need indentation
Loading history...
83
//		}
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 6; use block comment if you need indentation
Loading history...
Coding Style introduced by
There must be no blank line following an inline comment
Loading history...
84
85
	}
86
87
	public static function uninstall_for_current_blog() {
0 ignored issues
show
Coding Style introduced by
Method name "Setup::uninstall_for_current_blog" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function uninstall_for_current_blog()
Loading history...
88
89
		// remove DB tables
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
90
		Model\Button::destroy();
91
92
		$options = array(
93
			/** 1.4+ */
94
			'podlove_subscribe_button_defaults',
95
			'widget_podlove_subscribe_button_wp_plugin_widget',
96
			/** 1.3.x */
97
			'podlove_subscribe_button_default_size',
98
			'podlove_subscribe_button_default_autowidth',
99
			'podlove_subscribe_button_default_color',
100
			'podlove_subscribe_button_default_style',
101
			'podlove_subscribe_button_default_format',
102
			'podlove_subscribe_button_default_language',
103
			'podlove_subscribe_button_plugin_database_version',
104
		);
105
106
		foreach ( $options as $option ) {
107
			delete_option( $option );
108
		}
109
110
	}
111
112
} // END class
113