Skip to content

Commit

Permalink
chore: fixing static analysis tests (#1921)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwarajanand authored Sep 28, 2023
1 parent ffabbde commit 94d8280
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
staticanalysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 5
Expand Down
2 changes: 1 addition & 1 deletion analyticsdata/src/get_common_metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/**
* Retrieves dimensions and metrics available for all Google Analytics 4 properties.
*/
function get_common_metadata()
function get_common_metadata(): void
{
// Create an instance of the Google Analytics Data API client library.
$client = new BetaAnalyticsDataClient();
Expand Down
30 changes: 20 additions & 10 deletions asset/test/assetSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace Google\Cloud\Samples\Asset;

use Google\Cloud\BigQuery\BigQueryClient;
use Google\Cloud\TestUtils\EventuallyConsistentTestTrait;
use Google\Cloud\TestUtils\TestTrait;
use PHPUnit\Framework\TestCase;
use PHPUnitRetry\RetryTrait;
Expand All @@ -30,6 +31,7 @@
*/
class assetSearchTest extends TestCase
{
use EventuallyConsistentTestTrait;
use RetryTrait;
use TestTrait;

Expand All @@ -55,23 +57,31 @@ public function testSearchAllResources()
$scope = 'projects/' . self::$projectId;
$query = 'name:' . self::$datasetId;

$output = $this->runFunctionSnippet('search_all_resources', [
$scope,
$query
]);
$this->runEventuallyConsistentTest(
function () use ($scope, $query) {
$output = $this->runFunctionSnippet('search_all_resources', [
$scope,
$query
]);

$this->assertStringContainsString(self::$datasetId, $output);
$this->assertStringContainsString(self::$datasetId, $output);
}
);
}

public function testSearchAllIamPolicies()
{
$scope = 'projects/' . self::$projectId;
$query = 'policy:roles/owner';

$output = $this->runFunctionSnippet('search_all_iam_policies', [
$scope,
$query
]);
$this->assertStringContainsString(self::$projectId, $output);
$this->runEventuallyConsistentTest(
function () use ($scope, $query) {
$output = $this->runFunctionSnippet('search_all_iam_policies', [
$scope,
$query
]);
$this->assertStringContainsString(self::$projectId, $output);
}
);
}
}
2 changes: 1 addition & 1 deletion spanner/src/list_instance_config_operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* list_instance_config_operations();
* ```
*/
function list_instance_config_operations()
function list_instance_config_operations(): void
{
$spanner = new SpannerClient();

Expand Down
8 changes: 5 additions & 3 deletions spanner/src/list_instance_configs.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
* list_instance_configs();
* ```
*/
function list_instance_configs()
function list_instance_configs(): void
{
$spanner = new SpannerClient();
foreach ($spanner->instanceConfigurations() as $config) {
printf('Available leader options for instance config %s: %s' . PHP_EOL,
$config->info()['displayName'], $config->info()['leaderOptions']
printf(
'Available leader options for instance config %s: %s' . PHP_EOL,
$config->info()['displayName'],
$config->info()['leaderOptions']
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion storage/src/generate_encryption_key.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* Generate a base64 encoded encryption key for Google Cloud Storage.
*/
function generate_encryption_key()
function generate_encryption_key(): void
{
$key = random_bytes(32);
$encodedKey = base64_encode($key);
Expand Down
2 changes: 1 addition & 1 deletion storage/src/list_buckets.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/**
* List all Cloud Storage buckets for the current project.
*/
function list_buckets()
function list_buckets(): void
{
$storage = new StorageClient();
foreach ($storage->buckets() as $bucket) {
Expand Down
2 changes: 1 addition & 1 deletion testing/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"phpunit/phpunit": "^9.0",
"friendsofphp/php-cs-fixer": "^3,<3.9",
"composer/semver": "^3.2",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan": "^1.10",
"phpspec/prophecy-phpunit": "^2.0"
}
}
2 changes: 1 addition & 1 deletion testing/run_staticanalysis_check.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2022 Google Inc.
# Copyright 2023 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 94d8280

Please sign in to comment.