Issues (18)

src/console/BumpController.php (3 issues)

1
<?php
2
/**
3
 * Changelog keeper
4
 *
5
 * @link      https://github.com/hiqdev/chkipper
6
 * @package   chkipper
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\chkipper\console;
12
13
use Exception;
14
use hiqdev\chkipper\helpers\File;
15
use hiqdev\chkipper\lib\modifiers\Normalization;
16
use hiqdev\chkipper\lib\parsers\GitLogParser;
17
use hiqdev\chkipper\lib\parsers\MarkdownParser;
18
use hiqdev\chkipper\lib\renderers\MarkdownRenderer;
19
use Yii;
20
21
/**
22
 * Bump Controller.
23
 *
24
 * @author Andrii Vasyliev <[email protected]>
25
 */
26
class BumpController extends \yii\console\Controller
27
{
28
    public function actionIndex($version = null)
29
    {
30
        $config = Yii::$app->config;
31
        $historyFile = $config->historyFile;
32
        $changelogFile = $config->getChangelogFile();
0 ignored issues
show
The method getChangelogFile() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        /** @scrutinizer ignore-call */ 
33
        $changelogFile = $config->getChangelogFile();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
        $parser = Yii::createObject(MarkdownParser::class);
34
        $history = $parser->parsePath($historyFile);
35
        $gitlog = Yii::createObject(GitLogParser::class);
36
        $gitlog->parseGitLog();
37
        $history->merge($gitlog->getHistory(), true);
38
39
        if ($version) {
40
            if ($version === 'dev') {
41
                $version = $history->lastTag;
42
            }
43
            $history->setFirstTag($version);
44
        }
45
46
        Normalization::create()->run($history);
47
48
        $historyRenderer = Yii::createObject(MarkdownRenderer::class);
49
        $changelogRenderer = $config->createChangelogRenderer();
50
        File::write($historyFile,  $historyRenderer->render($history));
51
        File::write($changelogFile,  $changelogRenderer->render($history));
52
    }
53
54
    public function actionParse($path)
55
    {
56
        if (!file_exists($path)) {
57
            throw new Exception('wrong path: ' . $path);
58
        }
59
        $parser = new MarkdownParser();
0 ignored issues
show
The call to hiqdev\chkipper\lib\pars...wnParser::__construct() has too few arguments starting with config. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

59
        $parser = /** @scrutinizer ignore-call */ new MarkdownParser();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
60
        $history = $parser->parsePath($path);
61
        var_dump($history->getTags());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($history->getTags()) looks like debug code. Are you sure you do not want to remove it?
Loading history...
62
    }
63
}
64