Skip to content

Commit d659af0

Browse files
committed
Initial codestyle setup
1 parent a59226a commit d659af0

File tree

13 files changed

+188
-167
lines changed

13 files changed

+188
-167
lines changed

ci/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/

ci/composer.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "builder/ci",
3+
"require": {},
4+
"require-dev": {
5+
"squizlabs/php_codesniffer": "^3.7",
6+
"phpcompatibility/php-compatibility": "^9.3",
7+
"wp-coding-standards/wpcs": "^2.3"
8+
},
9+
"authors": [
10+
{
11+
"name": "Pavel I",
12+
"email": "[email protected]"
13+
}
14+
]
15+
}

ci/ruleset.xml

+20-6
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
except in this file, so it can contain information for
88
developers who may change this file in the future.
99
-->
10+
<config name="installed_paths" value="vendor/wp-coding-standards/wpcs,vendor/phpcompatibility/php-compatibility"/>
11+
1012
<description>A custom coding standard</description>
1113

1214
<rule ref="PSR12">
1315
<exclude name="Generic.Files.LineLength.TooLong"/>
16+
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
1417
</rule>
1518
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
1619
<rule ref="Generic.Files.EndFileNewline"/>
@@ -32,17 +35,22 @@
3235
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
3336
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
3437
<rule ref="Generic.Functions.CallTimePassByReference"/>
35-
<rule ref="Generic.Metrics.CyclomaticComplexity"/>
38+
<rule ref="Generic.Metrics.CyclomaticComplexity">
39+
<properties>
40+
<property name="complexity" value="18"/>
41+
<property name="absoluteComplexity" value="19"/>
42+
</properties>
43+
</rule>
3644
<rule ref="Generic.Metrics.NestingLevel"/>
3745
<rule ref="Generic.NamingConventions.ConstructorName"/>
3846
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
39-
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
47+
<!-- <rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>-->
4048
<rule ref="Generic.PHP.DeprecatedFunctions"/>
4149
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
4250
<rule ref="Generic.PHP.LowerCaseConstant"/>
4351
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
4452
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
45-
<rule ref="Generic.PHP.NoSilencedErrors"/>
53+
<!-- <rule ref="Generic.PHP.NoSilencedErrors"/>-->
4654
<rule ref="Generic.PHP.ForbiddenFunctions"/>
4755
<rule ref="MySource.PHP.EvalObjectFactory"/>
4856
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
@@ -58,9 +66,9 @@
5866
<rule ref="Squiz.PHP.Eval"/>
5967
<rule ref="Zend.Files.ClosingTag"/>
6068
<rule ref="Squiz.PHP.NonExecutableCode"/>
61-
<rule ref="Zend.NamingConventions.ValidVariableName">
62-
<exclude name="Zend.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
63-
</rule>
69+
<!-- <rule ref="Zend.NamingConventions.ValidVariableName">-->
70+
<!-- <exclude name="Zend.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>-->
71+
<!-- </rule>-->
6472
<rule ref="Squiz.Classes.ValidClassName">
6573
<exclude-pattern>./visualcomposer/Requirements.php</exclude-pattern>
6674
<exclude-pattern>./visualcomposer/Env.php</exclude-pattern>
@@ -81,5 +89,11 @@
8189
<exclude-pattern type="relative">tests/*</exclude-pattern>
8290
<exclude-pattern type="relative">vendor/*</exclude-pattern>
8391

92+
<!-- Show sniff codes in all reports -->
93+
<arg value="s"/>
94+
<!-- ignore all phpcs annotations -->
95+
<arg value="-ignore-annotations"/>
96+
<!-- Up the Memory limit for large plugins -->
97+
<ini name="memory_limit" value="512M"/>
8498
<arg name="extensions" value="php"/>
8599
</ruleset>

visualcomposer/Helpers/WpMedia.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public function getImageBySize($params = [])
4141
$thumb_class = (isset($params['class']) && '' !== $params['class']) ? $params['class'] . ' ' : '';
4242
global $_wp_additional_image_sizes;
4343
$thumbnail = '';
44-
if (is_string($thumb_size)
44+
if (
45+
is_string($thumb_size)
4546
&& ((!empty($_wp_additional_image_sizes[ $thumb_size ])
4647
&& is_array(
4748
$_wp_additional_image_sizes[ $thumb_size ]

visualcomposer/Modules/Assets/EnqueueController.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,16 @@ protected function callNonWordpressActionCallbacks($action)
159159
foreach ($callbacks as $callback) {
160160
$closureInfo = $this->getCallReflector($callback['function']);
161161
// This filter can be used to prevent callback() call in Header/Footer or other parts like global templates
162-
if (vcfilter(
163-
'vcv:assets:enqueue:callback:skip',
164-
false,
165-
[
162+
if (
163+
vcfilter(
164+
'vcv:assets:enqueue:callback:skip',
165+
false,
166+
[
166167
'closureInfo' => $closureInfo,
167168
'callback' => $callback,
168-
]
169-
)) {
169+
]
170+
)
171+
) {
170172
continue;
171173
}
172174
$fileName = $closureInfo->getFileName();

visualcomposer/Modules/Editors/DataAjax/Controller.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,11 @@ protected function updatePostData($post, $sourceId, $response)
251251
} elseif ($isPreview) {
252252
$previewPost = $previewHelper->generatePreview($post, $sourceId);
253253
} else {
254-
if ($currentUserAccessHelper->wpAll(
255-
[get_post_type_object($post->post_type)->cap->publish_posts, $sourceId]
256-
)->get()) {
254+
if (
255+
$currentUserAccessHelper->wpAll(
256+
[get_post_type_object($post->post_type)->cap->publish_posts, $sourceId]
257+
)->get()
258+
) {
257259
if ($post->post_status !== 'private' && $post->post_status !== 'future') {
258260
$post->post_status = 'publish';
259261
}

visualcomposer/Modules/Editors/Settings/WordPressSettings/AuthorController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ protected function outputAuthorList(
103103
$currentUserAccessHelper->wpAll(
104104
// @codingStandardsIgnoreLine
105105
[get_post_type_object($currentPost->post_type)->cap->publish_posts, $currentPost->ID]
106-
// @codingStandardsIgnoreLine
107-
)->get() && post_type_supports( $currentPost->post_type, 'author' )
106+
// @codingStandardsIgnoreLine
107+
)->get() && post_type_supports($currentPost->post_type, 'author')
108108
) {
109109
$response = array_merge(
110110
$response,

visualcomposer/Modules/Editors/Settings/WordPressSettings/DiscussionController.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ protected function outputDiscussion(
5151
$currentPostType = $currentPost->post_type;
5252
$pingStatus = $currentPost->ping_status;
5353
$commentStatus = $currentPost->comment_status;
54-
if ($currentPostType && $currentUserAccessHelper->wpAll(
54+
if (
55+
$currentPostType && $currentUserAccessHelper->wpAll(
5556
[get_post_type_object($currentPost->post_type)->cap->publish_posts, $currentPost->ID]
56-
)->get()) {
57+
)->get()
58+
) {
5759
// @codingStandardsIgnoreEnd
5860
$discussionVariables = [];
5961
if (

visualcomposer/Modules/Editors/Settings/WordPressSettings/ParentPageController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ protected function outputPageList(
110110
) {
111111
$currentPost = $postTypeHelper->get();
112112
// @codingStandardsIgnoreLine
113-
if (isset($currentPost->post_type) && post_type_supports( $currentPost->post_type, 'page-attributes' )) {
113+
if (isset($currentPost->post_type) && post_type_supports($currentPost->post_type, 'page-attributes')) {
114114
$response = array_merge(
115115
$response,
116116
[

visualcomposer/Modules/Elements/AjaxShortcode/Controller.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ function ($list) {
100100
}
101101
// @codingStandardsIgnoreStart
102102
global $wp_embed;
103-
$content = $wp_embed->run_shortcode( $content );
104-
$content = $wp_embed->autoembed( $content ); // Render embed shortcodes
103+
$content = $wp_embed->run_shortcode($content);
104+
$content = $wp_embed->autoembed($content); // Render embed shortcodes
105105
// @codingStandardsIgnoreEnd
106106
$content = do_shortcode($content);
107107
$content = convert_smilies($content);

visualcomposer/Modules/Vendors/Themes/GeneratePressController.php

+21-20
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,27 @@ public function __construct()
4343
*/
4444
protected function integrateThemeHeader()
4545
{
46-
// @codingStandardsIgnoreStart
47-
?>
48-
<div <?php generate_do_attr('page'); ?>>
49-
<?php
50-
/**
51-
* generate_inside_site_container hook.
52-
*
53-
* @since 2.4
54-
*/
55-
do_action('generate_inside_site_container');
56-
?>
57-
<div <?php generate_do_attr('site-content'); ?>>
58-
<?php
59-
// @codingStandardsIgnoreEnd
60-
/**
61-
* generate_inside_container hook.
62-
*
63-
* @since 0.1
64-
*/
65-
do_action('generate_inside_container');
46+
ob_start();
47+
echo '<div ';
48+
generate_do_attr('page');
49+
echo ' >';
50+
/**
51+
* generate_inside_site_container hook.
52+
*
53+
* @since 2.4
54+
*/
55+
do_action('generate_inside_site_container');
56+
57+
echo '<div ';
58+
generate_do_attr('site-content');
59+
echo '>';
60+
/**
61+
* generate_inside_container hook.
62+
*
63+
* @since 0.1
64+
*/
65+
do_action('generate_inside_container');
66+
echo ob_get_clean();
6667
}
6768

6869
/**

visualcomposer/Modules/Vendors/WpmlController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ protected function completeTranslationJobSaving($fields, $job)
217217
strpos($field->field_type, 'field-vcv-pageContentField--') !== false;
218218

219219
// @codingStandardsIgnoreLine
220-
if ( !$field->field_finished || !$isFieldPostContent) {
220+
if (!$field->field_finished || !$isFieldPostContent) {
221221
continue;
222222
}
223223
// @codingStandardsIgnoreLine

0 commit comments

Comments
 (0)