Skip to content

Commit 936d92e

Browse files
authored
[Bug] Credentials are required to be filled (#14)
* Credentials are required to be filled * Up version
1 parent 9b0f99a commit 936d92e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

bin/mr-linter

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if ($loaded === false) {
3838
exit(1);
3939
}
4040

41-
$application = new Application('Merge Request Linter', '0.3.0');
41+
$application = new Application('Merge Request Linter', '0.5.1');
4242

4343
$filesystem = new LocalFileSystem();
4444
$environment = new LocalEnvironment();

src/Configuration/Loader/AbstractArrayConfigLoader.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ public function load(string $path): Config
3535
throw new ConfigInvalidException('HTTP Client unavailable');
3636
}
3737

38-
return new Config($rules, $this->credentialMapper->map($data['credentials']), new HttpClientConfig(
38+
$credentials = $this->credentialMapper->map($data['credentials']);
39+
40+
if ($credentials->isEmpty()) {
41+
throw new ConfigInvalidException('Credentials must be filled');
42+
}
43+
44+
return new Config($rules, $credentials, new HttpClientConfig(
3945
$data['http_client']['type'] ?? HttpClientConfig::TYPE_DEFAULT,
4046
$data['http_client']['params'] ?? [],
4147
));

src/Configuration/Loader/PhpConfigLoader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ protected function createFromArray(array $config): Config
5151
throw ConfigInvalidException::fromKey('rules');
5252
}
5353

54-
if (! isset($config['credentials']) || ! is_array($config['credentials'])) {
55-
throw ConfigInvalidException::fromKey('credentials');
54+
if (empty($config['credentials']) || ! is_array($config['credentials'])) {
55+
throw new ConfigInvalidException('Credentials must be filled');
5656
}
5757

5858
return new Config(

0 commit comments

Comments
 (0)