Skip to content

Commit

Permalink
Configure default baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgsowa committed Feb 11, 2024
1 parent 346f2d8 commit f566167
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
class Config
{
private const DEFAULT_FILE_NAME = 'psalm.xml';
private const DEFAULT_BASELINE_NAME = 'psalm-baseline.xml';
public const DEFAULT_BASELINE_NAME = 'psalm-baseline.xml';
public const CONFIG_NAMESPACE = 'https://getpsalm.org/schema/config';
public const REPORT_INFO = 'info';
public const REPORT_ERROR = 'error';
Expand Down Expand Up @@ -549,8 +549,8 @@ class Config
*/
public $hash = '';

/** @var string */
public $error_baseline = self::DEFAULT_BASELINE_NAME;
/** @var null|string */
public $error_baseline = null;

/**
* @var bool
Expand Down
5 changes: 2 additions & 3 deletions src/Psalm/Internal/Cli/Psalm.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ private static function generateBaseline(
): array {
fwrite(STDERR, 'Writing error baseline to file...' . PHP_EOL);

$errorBaseline = ((string) $options['set-baseline']) ?: $config->error_baseline;
$errorBaseline = ((string) $options['set-baseline']) ?: $config->error_baseline ?: Config::DEFAULT_BASELINE_NAME;

Check failure on line 652 in src/Psalm/Internal/Cli/Psalm.php

View workflow job for this annotation

GitHub Actions / build

RiskyTruthyFalsyComparison

src/Psalm/Internal/Cli/Psalm.php:652:26: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)

try {
$issue_baseline = ErrorBaseline::read(
Expand All @@ -660,7 +660,6 @@ private static function generateBaseline(
$issue_baseline = [];
}

echo $errorBaseline;
ErrorBaseline::create(
new FileProvider,
$errorBaseline,
Expand All @@ -670,7 +669,7 @@ private static function generateBaseline(

fwrite(STDERR, "Baseline saved to $errorBaseline.");

if ($options['set-baseline'] && $options['set-baseline'] !== $config->error_baseline) {
if ($errorBaseline !== $config->error_baseline) {
CliUtils::updateConfigFile(
$config,
$path_to_config ?? $current_dir,
Expand Down

0 comments on commit f566167

Please sign in to comment.