Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[default]
extend-ignore-re = [
"avail_post_stati",
"ba",
"MAGPIE_INITALIZED",
"setted_site_transient",
"setted_transient",
]

[files]
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"automattic/vipwpcs": "^3.0.0",
"composer/installers": "^2.2",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"nikic/php-parser": "^4",
"plugin-check/phpcs-sniffs": "@dev",
"wp-coding-standards/wpcs": "^3.2.0"
},
Expand Down Expand Up @@ -58,7 +59,8 @@
},
"platform": {
"php": "7.4"
}
},
"sort-packages": true
},
"scripts": {
"behat": "BEHAT_FEATURES_FOLDER=tests/behat/features run-behat-tests",
Expand Down
116 changes: 57 additions & 59 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 92 additions & 0 deletions includes/Checker/Checks/Plugin_Repo/Prefixing_Check.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
/**
* Class Prefixing_Check.
*
* @package plugin-check
*/

namespace WordPress\Plugin_Check\Checker\Checks\Plugin_Repo;

use WordPress\Plugin_Check\Checker\Check_Categories;
use WordPress\Plugin_Check\Checker\Check_Result;
use WordPress\Plugin_Check\Checker\Checks\Abstract_PHP_CodeSniffer_Check;
use WordPress\Plugin_Check\Traits\Amend_Check_Result;
use WordPress\Plugin_Check\Traits\Prefix_Utils;
use WordPress\Plugin_Check\Traits\Stable_Check;

/**
* Check for prefixing.
*
* @since 1.7.0
*/
class Prefixing_Check extends Abstract_PHP_CodeSniffer_Check {

use Amend_Check_Result;
use Prefix_Utils;
use Stable_Check;

/**
* Gets the categories for the check.
*
* Every check must have at least one category.
*
* @since 1.7.0
*
* @return array The categories for the check.
*/
public function get_categories() {
return array( Check_Categories::CATEGORY_PLUGIN_REPO );
}

/**
* Returns an associative array of arguments to pass to PHPCS.
*
* @since 1.7.0
*
* @param Check_Result $result The check result to amend, including the plugin context to check.
* @return array An associative array of PHPCS CLI arguments.
*/
protected function get_args( Check_Result $result ) {
$args = array(
'extensions' => 'php',
'standard' => 'WordPress',
'sniffs' => 'WordPress.NamingConventions.PrefixAllGlobals',
);

$prefixes = $this->get_potential_prefixes( $result );

if ( ! empty( $prefixes ) ) {
$args['runtime-set'] = array(
'prefixes' => implode( ',', $prefixes ),
);
}

return $args;
}

/**
* Gets the description for the check.
*
* Every check must have a short description explaining what the check does.
*
* @since 1.7.0
*
* @return string Description.
*/
public function get_description(): string {
return __( 'Checks plugin for unique prefixing for everything the plugin defines in the public namespace.', 'plugin-check' );
}

/**
* Gets the documentation URL for the check.
*
* Every check must have a URL with further information about the check.
*
* @since 1.7.0
*
* @return string The documentation URL.
*/
public function get_documentation_url(): string {
return __( 'https://make.wordpress.org/plugins/handbook/performing-reviews/review-checklist/#code', 'plugin-check' );
}
}
1 change: 1 addition & 0 deletions includes/Checker/Default_Check_Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private function register_default_checks() {
'non_blocking_scripts' => new Checks\Performance\Non_Blocking_Scripts_Check(),
'offloading_files' => new Checks\Plugin_Repo\Offloading_Files_Check(),
'setting_sanitization' => new Checks\Plugin_Repo\Setting_Sanitization_Check(),
'prefixing' => new Checks\Plugin_Repo\Prefixing_Check(),
)
);

Expand Down
Loading
Loading