src/includes/Functionalities/InstallationFunctionality.php
Method install_or_update
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function install_or_update(): ?InstallFailureException {
if ( ! Users::has_capabilities( 'activate_plugins' ) ) {
return new InstallFailureException( 'User does not have enough permissions to run the installation routine' );
}
Method output_installation_js
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function output_installation_js() {
if ( false === $this->has_notice_output ) {
return; // The installation/upgrade notice has not been outputted.
}
Function get_installable_versions
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function get_installable_versions(): array {
$installable_versions = array();
foreach ( \get_declared_classes() as $declared_class ) {
if ( ! \is_a( $declared_class, InstallableInterface::class, true ) ) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method register_admin_notices
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function register_admin_notices( AdminNoticesService $notices_service ): void {
if ( \doing_action( 'activate_' . $this->get_plugin()->get_plugin_file_path() ) ) {
return;
}
Function uninstall
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
public function uninstall(): ?UninstallFailureException {
if ( ! Users::has_capabilities( (array) 'delete_plugins' ) ) {
return new UninstallFailureException( 'User does not have enough permissions to run the uninstallation routine' );
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"