Skip to content

Commit

Permalink
Updated coding standards.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed May 29, 2024
1 parent a6cdf96 commit b400bcc
Show file tree
Hide file tree
Showing 26 changed files with 68 additions and 22 deletions.
2 changes: 0 additions & 2 deletions .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ commands:
lint-be:
usage: Lint back-end code.
cmd: |
ahoy cli "cd web/themes/contrib/${DRUPAL_THEME} && BUILD_DIR=/app DRUPAL_ROOT=/app/web .devtools/lint.sh"
ahoy cli vendor/bin/phpcs
ahoy cli vendor/bin/phpstan
ahoy cli vendor/bin/rector process --dry-run --clear-cache
Expand All @@ -182,7 +181,6 @@ commands:
lint-fix:
usage: Fix lint issues of back-end and front-end code.
cmd: |
ahoy cli "cd web/themes/contrib/${DRUPAL_THEME} && BUILD_DIR=/app DRUPAL_ROOT=/app/web .devtools/lint-fix.sh"
ahoy cli vendor/bin/rector --clear-cache
ahoy cli vendor/bin/phpcbf
Expand Down
26 changes: 17 additions & 9 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

use DrupalFinder\DrupalFinder;
use DrupalFinder\DrupalFinderComposerRuntime;
use DrupalRector\Set\Drupal10SetList;
use DrupalRector\Set\Drupal8SetList;
use DrupalRector\Set\Drupal9SetList;
Expand All @@ -26,10 +26,24 @@
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
use Rector\Set\ValueObject\SetList;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;

return static function (RectorConfig $rectorConfig): void {
$drupalFinder = new DrupalFinderComposerRuntime();
$drupalRoot = $drupalFinder->getDrupalRoot();
$rectorConfig->autoloadPaths([
$drupalRoot . '/core',
$drupalRoot . '/modules',
$drupalRoot . '/themes',
$drupalRoot . '/profiles',
]);

$rectorConfig->paths([
__DIR__,
$drupalRoot . '/modules/custom',
$drupalRoot . '/themes/custom',
$drupalRoot . '/sites/default/settings.php',
$drupalRoot . '/sites/default/includes',
__DIR__ . '/tests',
]);

$rectorConfig->sets([
Expand All @@ -48,13 +62,7 @@
Drupal10SetList::DRUPAL_10,
]);

$drupalRoot = realpath(__DIR__ . '/web');
$rectorConfig->autoloadPaths([
$drupalRoot . '/core',
$drupalRoot . '/modules',
$drupalRoot . '/themes',
$drupalRoot . '/profiles',
]);
$rectorConfig->rule(DeclareStrictTypesRector::class);

$rectorConfig->skip([
// Rules added by Rector's rule sets.
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/AddPhpcsExclusionsUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AddPhpcsExclusionsUnitTest extends ScriptUnitTestBase {
/**
* {@inheritdoc}
*/
protected $script = 'web/themes/contrib/civictheme/civictheme_starter_kit/scripts/add_phpcs_exclusions.php';
protected $script = 'themes/contrib/civictheme/civictheme_starter_kit/scripts/add_phpcs_exclusions.php';

/**
* @dataProvider dataProviderMain
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CivicthemeCreateSubthemeScriptUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class CivicthemeCreateSubthemeScriptUnitTest extends ScriptUnitTestBase {
/**
* {@inheritdoc}
*/
protected $script = 'web/themes/contrib/civictheme/civictheme_create_subtheme.php';
protected $script = 'themes/contrib/civictheme/civictheme_create_subtheme.php';

/**
* CivicTheme dir.
*
* @var string
*/
protected $civicthemeDir = 'web/themes/contrib/civictheme';
protected $civicthemeDir = 'themes/contrib/civictheme';

/**
* @dataProvider dataProviderMain
Expand Down
7 changes: 5 additions & 2 deletions tests/phpunit/Drupal/SettingsTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,16 @@ protected function unsetEnvVars(): void {
* Require settings file.
*/
protected function requireSettingsFile(): void {
$app_root = './web';
$app_root = getcwd();
if (empty($app_root)) {
throw new \RuntimeException('Could not determine application root.');
}
$site_path = 'sites/default';
$config = [];
$settings = [];
$databases = [];

require getcwd() . DIRECTORY_SEPARATOR . $app_root . '/' . $site_path . '/settings.php';
require $app_root . DIRECTORY_SEPARATOR . $site_path . DIRECTORY_SEPARATOR . 'settings.php';

$this->app_root = $app_root;
$this->site_path = $site_path;
Expand Down
5 changes: 3 additions & 2 deletions tests/phpunit/ScriptUnitTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ abstract class ScriptUnitTestBase extends TestCase {
protected function setUp(): void {
putenv('SCRIPT_RUN_SKIP=1');
putenv('SCRIPT_QUIET=1');
if (!is_readable($this->script)) {
$path = getcwd() . DIRECTORY_SEPARATOR . $this->script;
if (!is_readable($path)) {
throw new \RuntimeException(sprintf('Unable to include script file %s.', $this->script));
}
require_once $this->script;
require_once $path;

$this->tmpDir = $this->tempdir();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class CivicthemeGovcmsManager {
* The entity type manager.
*/
public function __construct(
protected EntityTypeManagerInterface $entityTypeManager
protected EntityTypeManagerInterface $entityTypeManager,
) {
$this->removalList = [
// Item name in CLI => callable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public function __construct(protected CivicthemeGovcmsManager $govcmsManager) {
* - menus
* - pathauto_patterns
*/
public function drushCivicthemeGovcmsRemoveConfig(array $options = [
'preserve' => '',
]): void {
public function drushCivicthemeGovcmsRemoveConfig(array $options = []): void {
$options += ['preserve' => ''];

// Removing configs will lead to showing warnings about missing bundles,
// which are only shown due to dependencies resolution concurrency issues.
// We are suppressing them as they do not have any valuable information
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Helpers for variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @file
* Variations for CivicTheme Page nodes.
Expand Down

0 comments on commit b400bcc

Please sign in to comment.