Skip to content
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

Copy phpstan config into tool dir #1482

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions qlty-check/src/executor/invocation_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn compute_invocation_script(plan: &InvocationPlan) -> Result<String> {

// Autoload script first in case it has variables that need to be interpolated
base_script = replace_autoload_script(plan, base_script);
base_script = replace_config_script(plan, base_script);
base_script = plan.tool.interpolate_variables(&base_script);
base_script = replace_target_variable(plan, base_script);
base_script = replace_tmpfile_variable(plan, base_script);
Expand All @@ -39,6 +40,19 @@ fn replace_autoload_script(plan: &InvocationPlan, script: String) -> String {
}
}

fn replace_config_script(plan: &InvocationPlan, script: String) -> String {
if script.contains("${config_script}") {
qltysh[bot] marked this conversation as resolved.
Show resolved Hide resolved
if !plan.plugin_configs.is_empty() {
let config_script = plan.driver.config_script.as_deref().unwrap_or("");
script.replace("${config_script}", config_script)
} else {
script.replace("${config_script}", "")
}
} else {
script
}
}

fn replace_target_variable(plan: &InvocationPlan, script: String) -> String {
if script.contains("${target}") {
let targets_list = plan_target_list(plan);
Expand Down
3 changes: 3 additions & 0 deletions qlty-config/src/config/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ pub struct DriverDef {

#[serde(default)]
pub autoload_script: Option<String>,

#[serde(default)]
pub config_script: Option<String>,
}

fn default_driver_timeout() -> u64 {
Expand Down
4 changes: 3 additions & 1 deletion qlty-plugins/plugins/linters/phpstan/plugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ description = "PHP code linter"
suggested = "targets"

[plugins.definitions.phpstan.drivers.lint]
script = "php -d memory_limit=-1 ${linter}/phpstan analyze ${target} --error-format=json --level=9 ${autoload_script}"
script = "php -d memory_limit=-1 ${linter}/phpstan analyze ${target} --error-format=json --level=9 ${autoload_script} ${config_script}"
autoload_script = "--autoload-file=${linter}/vendor/autoload.php"
config_script = "--configuration=${config_file}"
success_codes = [0, 1]
output = "stdout"
output_format = "phpstan"
cache_results = true
batch = true
suggested = "targets"
output_missing = "parse"
copy_configs_into_tool_install = true
Loading