Skip to content

Commit

Permalink
Add InlineComment sniff
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Mar 4, 2024
1 parent babf3ba commit ea6c782
Show file tree
Hide file tree
Showing 54 changed files with 125 additions and 163 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ drupal
cx-api-spec
gardener

// Artifacts from mutation testing
*.cache
1 change: 1 addition & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<rule ref="AcquiaPHP" />

<rule ref="Drupal.Commenting.InlineComment"/>
<rule ref="SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys" />
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
Expand Down
10 changes: 5 additions & 5 deletions src/Command/Api/ApiCommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private function getParameterSchemaFromSpec(string $paramKey, array $acquiaCloud
return $acquiaCloudSpec['components']['schemas'][$paramKey];
}

/** @infection-ignore-all */
// @infection-ignore-all
private function isApiSpecChecksumCacheValid(\Symfony\Component\Cache\CacheItem $cacheItem, string $acquiaCloudSpecFileChecksum): bool {
// If the spec file doesn't exist, assume cache is valid.
if (!$acquiaCloudSpecFileChecksum && $cacheItem->isHit()) {
Expand All @@ -296,7 +296,7 @@ private function isApiSpecChecksumCacheValid(\Symfony\Component\Cache\CacheItem
private function getCloudApiSpec(string $specFilePath): array {
$cacheKey = basename($specFilePath);
$cache = new PhpArrayAdapter(__DIR__ . '/../../../var/cache/' . $cacheKey . '.cache', new NullAdapter());
/** @infection-ignore-all */
// @infection-ignore-all
$cacheItemChecksum = $cache->getItem($cacheKey . '.checksum');
$cacheItemSpec = $cache->getItem($cacheKey);

Expand All @@ -307,7 +307,7 @@ private function getCloudApiSpec(string $specFilePath): array {

// Otherwise, only use cache when it is valid.
$checksum = md5_file($specFilePath);
/** @infection-ignore-all */
// @infection-ignore-all
if ($this->useCloudApiSpecCache()
&& $this->isApiSpecChecksumCacheValid($cacheItemChecksum, $checksum) && $cacheItemSpec->isHit()
) {
Expand All @@ -333,7 +333,7 @@ private function generateApiCommandsFromSpec(array $acquiaCloudSpec, string $com
$apiCommands = [];
foreach ($acquiaCloudSpec['paths'] as $path => $endpoint) {
// Skip internal endpoints. These shouldn't actually be in the spec.
/** @infection-ignore-all */
// @infection-ignore-all
if (array_key_exists('x-internal', $endpoint) && $endpoint['x-internal']) {
continue;
}
Expand All @@ -348,7 +348,7 @@ private function generateApiCommandsFromSpec(array $acquiaCloudSpec, string $com
}

// Skip deprecated endpoints.
/** @infection-ignore-all */
// @infection-ignore-all
if (array_key_exists('deprecated', $schema) && $schema['deprecated']) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/CodeStudio/CodeStudioCiCdVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CodeStudioCiCdVariables {
* @return array<mixed>
*/
public static function getList(): array {
//getlist is being utilised in pipeline-migrate command. By default command is supporting drupal project but going forward need to support both drupal and nodejs project.
// Getlist is being utilised in pipeline-migrate command. By default command is supporting drupal project but going forward need to support both drupal and nodejs project.
return array_column(self::getDefaultsForPhp(), 'key');
}

Expand Down
2 changes: 0 additions & 2 deletions src/Command/CodeStudio/CodeStudioCommandTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ private function determineGitLabProject(ApplicationResponse $cloudApplication):
);
}
// Prompt to create project.

$this->io->writeln([
"",
"Could not find any existing Code Studio project for Acquia Cloud Platform application <comment>{$cloudApplication->name}</comment>.",
Expand All @@ -189,7 +188,6 @@ private function determineGitLabProject(ApplicationResponse $cloudApplication):
return $this->createGitLabProject($cloudApplication);
}
// Prompt to choose from full list, regardless of description.

return $this->promptChooseFromObjectsOrArrays(
$this->gitLabClient->projects()->all(),
'id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$cloudApplication = $this->getCloudApplication($cloudApplicationUuid);
$project = $this->determineGitLabProject($cloudApplication);

// Migrate acquia-pipeline file
// Migrate acquia-pipeline file.
$this->checkGitLabCiCdVariables($project);
$this->validateCwdIsValidDrupalProject();
$acquiaPipelinesFileDetails = $this->getAcquiaPipelinesFileContents($project);
Expand Down
12 changes: 6 additions & 6 deletions src/Command/CodeStudio/CodeStudioWizardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$account,
[
"deploy to non-prod",
# Add SSH key to git repository
// Add SSH key to git repository.
"add ssh key to git",
# Add SSH key to non-production environments
// Add SSH key to non-production environments.
"add ssh key to non-prod",
# Add a CD environment
// Add a CD environment.
"add an environment",
# Delete a CD environment
// Delete a CD environment.
"delete an environment",
# Manage environment variables on a non-production environment
// Manage environment variables on a non-production environment.
"administer environment variables on non-prod",
]
);
Expand Down Expand Up @@ -255,7 +255,7 @@ private function createScheduledPipeline(array $project): void {
if (!$this->getGitLabScheduleByDescription($project, $scheduledPipelineDescription)) {
$this->checklist->addItem("Creating scheduled pipeline <comment>$scheduledPipelineDescription</comment>");
$pipeline = $this->gitLabClient->schedules()->create($project['id'], [
# Every Thursday at midnight.
// Every Thursday at midnight.
'cron' => '0 0 * * 4',
'description' => $scheduledPipelineDescription,
'ref' => $project['default_branch'],
Expand Down
4 changes: 2 additions & 2 deletions src/Command/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ protected function determineEnvironment(InputInterface $input, OutputInterface $
return $chosenEnvironment;
}

// Todo: obviously combine this with promptChooseEnvironment
// Todo: obviously combine this with promptChooseEnvironment.
private function promptChooseEnvironmentConsiderProd(Client $acquiaCloudClient, string $applicationUuid, bool $allowProduction = FALSE): EnvironmentResponse {
$environmentResource = new Environments($acquiaCloudClient);
$applicationEnvironments = iterator_to_array($environmentResource->getAll($applicationUuid));
Expand Down Expand Up @@ -1749,7 +1749,7 @@ protected function waitForNotificationToComplete(Client $acquiaCloudClient, stri
$notification = NULL;
$checkNotificationStatus = static function () use ($notificationsResource, &$notification, $uuid): bool {
$notification = $notificationsResource->get($uuid);
/** @infection-ignore-all */
// @infection-ignore-all
return $notification->status !== 'in-progress';
};
if ($success === NULL) {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DocsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($acquiaProductName = $input->getArgument('product')) {
$productUrl = NULL;
foreach ($acquiaProducts as $acquiaProduct) {
// If product provided by the user exists in the alias
// If product provided by the user exists in the alias.
if (in_array(strtolower($acquiaProductName), $acquiaProduct['alias'], TRUE)) {
$productUrl = $acquiaProduct['url'];
break;
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Email/ConfigurePlatformEmailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private function checkIfDomainVerified(
return TRUE;
}

/** @infection-ignore-all */
// @infection-ignore-all
if (isset($response->health) && str_starts_with($response->health->code, "4")) {
$this->io->error($response->health->details);
if ($this->io->confirm('Would you like to refresh?')) {
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Email/EmailInfoForSubscriptionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
*/
private function writeDomainsToTables(OutputInterface $output, SubscriptionResponse $subscription, array $domainList): void {

// initialize tables to be displayed in console
// Initialize tables to be displayed in console.
$allDomainsTable = $this->createTotalDomainTable($output, "Subscription $subscription->name - All Domains");
$verifiedDomainsTable = $this->createDomainStatusTable($output, "Subscription $subscription->name - Verified Domains");
$pendingDomainsTable = $this->createDomainStatusTable($output, "Subscription $subscription->name - Pending Domains");
$failedDomainsTable = $this->createDomainStatusTable($output, "Subscription $subscription->name - Failed Domains");

// initialize csv writers for each file
// Initialize csv writers for each file.
$writerAllDomains = Writer::createFromPath("./subscription-$subscription->uuid-domains/all-domains-summary.csv", 'w+');
$writerVerifiedDomains = Writer::createFromPath("./subscription-$subscription->uuid-domains/verified-domains-summary.csv", 'w+');
$writerPendingDomains = Writer::createFromPath("./subscription-$subscription->uuid-domains/pending-domains-summary.csv", 'w+');
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Ide/IdeCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private function waitForDnsPropagation(string $ideUrl): int {
// @see https://stackoverflow.com/questions/28277889/guzzlehttp-client-change-base-url-dynamically
$response = $this->httpClient->request('GET', "$ideUrl/health");
// Mutating this will result in an infinite loop and timeout.
/** @infection-ignore-all */
// @infection-ignore-all
if ($response->getStatusCode() === 200) {
$ideCreated = TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Ide/Wizard/IdeWizardCreateSshKeyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
self::getThisCloudIdeCloudAppUuid(),
$account,
[
# Add SSH key to git repository
// Add SSH key to git repository.
"add ssh key to git",
# Add SSH key to non-production environments
// Add SSH key to non-production environments.
"add ssh key to non-prod",
]
);
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Remote/DrushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
$alias = self::getEnvironmentAlias($environment);
$acliArguments = $input->getArguments();
$drushArguments = (array) $acliArguments['drush_command'];
// When available, provide the default domain to drush
// When available, provide the default domain to drush.
if (!empty($environment->default_domain)) {
// Insert at the beginning so a user-supplied --uri arg will override
// Insert at the beginning so a user-supplied --uri arg will override.
array_unshift($drushArguments, "--uri=http://{$environment->default_domain}");
}
$drushCommandArguments = [
Expand Down
4 changes: 2 additions & 2 deletions src/Helpers/LoopHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public static function getLoopy(OutputInterface $output, SymfonyStyle $io, Logge
$spinner->start();

$cancelTimers = static function () use (&$timers, $spinner): void {
/** @infection-ignore-all */
// @infection-ignore-all
array_map('\React\EventLoop\Loop::cancelTimer', $timers);
$timers = [];
$spinner->finish();
};
$periodicCallback = static function () use ($logger, $statusCallback, $doneCallback, $cancelTimers): void {
try {
/** @infection-ignore-all */
// @infection-ignore-all
if ($statusCallback()) {
$cancelTimers();
$doneCallback();
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/TelemetryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function initializeBugsnag(): void {
if (str_contains($context, 'acli ')) {
$context = substr($context, strpos($context, 'acli ') + 5);
}
// Strip sensitive parameters from context
// Strip sensitive parameters from context.
if (str_contains($context, "--password")) {
$context = substr($context, 0, strpos($context, "--password") + 10) . 'REDACTED';
}
Expand Down
8 changes: 2 additions & 6 deletions tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ public function testAcsfCommandExecutionForHttpPostWithMultipleDataTypes(): void
$this->executeCommand([
'uids' => '1,2,3',
], [
// group_id
// group_id.
'1',
]);

// Assert.

$output = $this->getDisplay();
}

Expand All @@ -58,12 +57,11 @@ public function testAcsfCommandExecutionBool(): void {
$this->clientProphecy->addOption('json', ["pause" => TRUE])->shouldBeCalled();
$this->command = $this->getApiCommandByName('acsf:updates:pause');
$this->executeCommand([], [
// pause
// Pause.
'1',
]);

// Assert.

}

public function testAcsfCommandExecutionForHttpGet(): void {
Expand All @@ -76,7 +74,6 @@ public function testAcsfCommandExecutionForHttpGet(): void {
$this->executeCommand(['--limit' => '1']);

// Assert.

$output = $this->getDisplay();
$this->assertNotNull($output);
$this->assertJson($output);
Expand Down Expand Up @@ -111,7 +108,6 @@ public function testAcsfCommandExecutionForHttpGetMultiple(string $method, strin
$this->executeCommand($arguments);

// Assert.

$output = $this->getDisplay();
$this->assertNotNull($output);
$this->assertJson($output);
Expand Down
14 changes: 7 additions & 7 deletions tests/phpunit/src/Commands/Acsf/AcsfAuthLoginCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public function providerTestAuthLoginCommand(): array {
FALSE,
// $inputs
[
// Would you like to share anonymous performance usage and data? (yes/no) [yes]
// Would you like to share anonymous performance usage and data? (yes/no) [yes].
'yes',
// Enter the full URL of the factory
// Enter the full URL of the factory.
$this->acsfCurrentFactoryUrl,
// Enter a value for username
// Enter a value for username.
$this->acsfUsername,
// Enter a value for key
// Enter a value for key.
$this->acsfKey,
],
// No arguments, all interactive.
Expand All @@ -53,11 +53,11 @@ public function providerTestAuthLoginCommand(): array {
[],
// Arguments.
[
// Enter the full URL of the factory
// Enter the full URL of the factory.
'--factory-url' => $this->acsfCurrentFactoryUrl,
// Enter a value for key
// Enter a value for key.
'--key' => $this->acsfKey,
// Enter a value for username
// Enter a value for username.
'--username' => $this->acsfUsername,
],
// Output to assert.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function providerTestAuthLogoutCommand(): array {
TRUE,
// $inputs
[
// Choose a Factory to logout of
// Choose a Factory to logout of.
0,
],
// $config.
Expand Down
7 changes: 0 additions & 7 deletions tests/phpunit/src/Commands/Api/ApiCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public function testApiCommandErrorResponse(): void {
]);

// Assert.

$output = $this->getDisplay();
$this->assertJson($output);
$this->assertStringContainsString($mockBody->message, $output);
Expand All @@ -114,7 +113,6 @@ public function testApiCommandExecutionForHttpGet(): void {
$this->executeCommand(['--limit' => '1']);

// Assert.

$output = $this->getDisplay();
$this->assertNotNull($output);
$this->assertJson($output);
Expand Down Expand Up @@ -151,7 +149,6 @@ public function testInferApplicationUuidArgument(): void {
]);

// Assert.

$output = $this->getDisplay();
$this->assertStringContainsString('Inferring Cloud Application UUID for this command since none was provided...', $output);
$this->assertStringContainsString('Set application uuid to ' . $application->uuid, $output);
Expand Down Expand Up @@ -201,7 +198,6 @@ public function testConvertApplicationAliasToUuidArgument(bool $support): void {
]);

// Assert.

$this->getDisplay();
$this->assertEquals(0, $this->getStatusCode());
}
Expand Down Expand Up @@ -273,7 +269,6 @@ public function testConvertEnvironmentAliasToUuidArgument(): void {
]);

// Assert.

$this->getDisplay();
$this->assertEquals(0, $this->getStatusCode());
}
Expand Down Expand Up @@ -306,7 +301,6 @@ public function testApiCommandExecutionForHttpPost(): void {
$this->executeCommand($mockRequestArgs);

// Assert.

$output = $this->getDisplay();
$this->assertNotNull($output);
$this->assertJson($output);
Expand Down Expand Up @@ -334,7 +328,6 @@ public function testApiCommandExecutionForHttpPut(): void {
$this->executeCommand($args);

// Assert.

$output = $this->getDisplay();
$this->assertNotNull($output);
$this->assertJson($output);
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/src/Commands/App/AppVcsInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function testNoDeployedVcs(): void {
$application = $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid);
$environments = $this->mockRequest('getApplicationEnvironments', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid);
foreach ($environments as $environment) {
// Empty the VCS
// Empty the VCS.
$environment->vcs = new \stdClass();
}

Expand Down
Loading

0 comments on commit ea6c782

Please sign in to comment.