-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add improved codesniffer support. #151
base: main
Are you sure you want to change the base?
Changes from all commits
78c1fd7
05d5a4b
d3c2d4a
e58c519
8ddc8c9
8b90f63
fdad5fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,16 @@ if [ -z "$1" ]; then | |
exit 1 | ||
fi | ||
|
||
ddev exec -d /var/www/html/"$(echo "$PWD" | cut -d'/' -f4-)" "$@" | ||
if [ "${GITPOD_NORMALIZE_EXEC_ARGUMENTS:-1}" = 1 ] && [ -n "${GITPOD_REPO_ROOT}" ]; then | ||
# Replace all references to the absolute path to the repo root. | ||
# This will ensure IDEs like PHPStorm can pass files into it without issue. | ||
arguments=() | ||
for arg in "$@"; do | ||
new_arg="${arg//${GITPOD_REPO_ROOT}//var/www/html}" | ||
arguments+=("$new_arg") | ||
done | ||
Comment on lines
+16
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification The path replacement logic in the loop does not handle edge cases where the substring appears multiple times in the path. This can lead to incorrect replacements, as demonstrated by the script output.
Analysis chainCheck the path replacement logic for potential edge cases. Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the path replacement logic handles all edge cases.
# Test: Simulate a scenario where the path might not be replaced correctly.
# Example: When the path contains similar substrings or nested paths.
echo "/path/to/repo/path/to/repo/file" | sed "s|/path/to/repo|/new/path|g"
Length of output: 98 |
||
else | ||
arguments=("$@") | ||
fi | ||
|
||
ddev exec -d /var/www/html/"$(echo "$PWD" | cut -d'/' -f4-)" "${arguments[@]}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
## Description: Run PHP_CodeSniffer's code beautifier | ||
## Usage: phpcbf [flags] [args] | ||
## Example: "ddev phpcbf --standard=core/phpcs.xml.dist index.php" or "ddev phpcbf index.php" | ||
## HostWorkingDir: true | ||
## ExecRaw: true | ||
|
||
if ! command -v phpcbf >/dev/null; then | ||
echo "phpcbf is not available. You may need to 'ddev composer require squizlabs/php_codesniffer'" | ||
exit 1 | ||
fi | ||
phpcbf "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
## Description: Run PHP_CodeSniffer's codesniffer | ||
## Usage: phpcs [flags] [args] | ||
## Example: "ddev phpcs --standard=core/phpcs.xml.dist index.php" or "ddev phpcs index.php" | ||
## HostWorkingDir: true | ||
## ExecRaw: true | ||
|
||
if ! command -v phpcs >/dev/null; then | ||
echo "phpcs is not available. You may need to 'ddev composer require squizlabs/php_codesniffer'" | ||
exit 1 | ||
fi | ||
phpcs "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ src/**/package-lock.json | |
src/**/out/ | ||
src/**/*.vsix | ||
src/**/.vscode-test/ | ||
drush/ | ||
.ddev/config.gitpod.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -eu -o pipefail | ||
|
||
# Remove site that was installed before (for debugging) | ||
rm -rf "${GITPOD_REPO_ROOT}"/web | ||
rm -rf "${GITPOD_REPO_ROOT}"/vendor | ||
rm -f "${GITPOD_REPO_ROOT}"/composer.json | ||
rm -f "${GITPOD_REPO_ROOT}"/composer.lock |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
set -eu -o pipefail | ||
|
||
# set PHP version, based on https://www.drupal.org/docs/getting-started/system-requirements/php-requirements#versions | ||
major_version=$(echo "$DP_CORE_VERSION" | cut -d '.' -f 1) | ||
minor_version=$(echo "$DP_CORE_VERSION" | cut -d '.' -f 2) | ||
|
||
# Before Drupal 10.2, we should use php 8.2, otherwise use php 8.3 | ||
if (( major_version < 10 )) || { (( major_version == 10 )) && (( minor_version < 2 )); }; then | ||
php_version="8.2" | ||
else | ||
php_version="8.3" | ||
fi | ||
|
||
cat <<CONFIGEND > "${GITPOD_REPO_ROOT}"/.ddev/config.gitpod.yaml | ||
#ddev-gitpod-generated | ||
php_version: "$php_version" | ||
CONFIGEND | ||
|
||
time ddev start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
The environment variable
GITPOD_REPO_ROOT
is set in the.gitpod.yml
file, but there is no evidence ofGITPOD_NORMALIZE_EXEC_ARGUMENTS
being set anywhere in the codebase or configuration files. This could lead to the condition in the script not being met.GITPOD_NORMALIZE_EXEC_ARGUMENTS
is set appropriately in the environment or configuration files.Analysis chain
Ensure
GITPOD_NORMALIZE_EXEC_ARGUMENTS
is properly set in the environment.Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 7
Script:
Length of output: 7
Script:
Length of output: 58
Script:
Length of output: 414