Conditions | 5 |
Paths | 4 |
Total Lines | 100 |
Code Lines | 55 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
39 | protected function execute(InputInterface $input, OutputInterface $output) |
||
40 | { |
||
41 | $packageName = $input->getArgument('name'); |
||
42 | $type = $input->getOption('type'); |
||
43 | |||
44 | $composerRuntime = $this->getComposer(); |
||
45 | |||
46 | $composerCtxFactory = new \Vaimo\ComposerChangelogs\Factories\ComposerContextFactory( |
||
47 | $composerRuntime |
||
48 | ); |
||
49 | |||
50 | $composerContext = $composerCtxFactory->create(); |
||
51 | |||
52 | $packageRepoFactory = new Factories\PackageResolverFactory($composerContext); |
||
53 | $packageResolver = $packageRepoFactory->create(); |
||
54 | |||
55 | $outputGenerator = new \Vaimo\ComposerChangelogs\Console\OutputGenerator($output); |
||
56 | |||
57 | try { |
||
58 | $package = $packageResolver->resolvePackage(is_string($packageName) ? $packageName : ''); |
||
59 | } catch (PackageResolverException $exception) { |
||
|
|||
60 | $outputGenerator->writeResolverException($exception); |
||
61 | |||
62 | return null; |
||
63 | } |
||
64 | |||
65 | $output->writeln( |
||
66 | sprintf('Bootstrapping changelogs for <info>%s</info>', $package->getName()) |
||
67 | ); |
||
68 | |||
69 | /** @var /Composer/Composer $composer */ |
||
70 | $composer = $composerContext->getLocalComposer(); |
||
71 | |||
72 | $packageInfoResolver = new \Vaimo\ComposerChangelogs\Resolvers\PackageInfoResolver( |
||
73 | $composer->getInstallationManager() |
||
74 | ); |
||
75 | |||
76 | $configExtractor = new \Vaimo\ComposerChangelogs\Extractors\VendorConfigExtractor($packageInfoResolver); |
||
77 | |||
78 | $config = $configExtractor->getConfig($package); |
||
79 | |||
80 | if (isset($config[PluginConfig::ROOT])) { |
||
81 | $rootPath = array(ComposerConfig::CONFIG_ROOT, PluginConfig::ROOT); |
||
82 | |||
83 | $message = sprintf( |
||
84 | 'Configuration root (<comment>%s</comment>) already present in package config', |
||
85 | implode('/', $rootPath) |
||
86 | ); |
||
87 | |||
88 | $output->writeln($message); |
||
89 | |||
90 | return 0; |
||
91 | } |
||
92 | |||
93 | $installPath = $packageInfoResolver->getInstallPath($package); |
||
94 | |||
95 | $config = $configExtractor->getPackageFullConfig($package); |
||
96 | |||
97 | $paths = [ |
||
98 | 'md' => 'CHANGELOG.md', |
||
99 | 'sphinx' => 'docs/changelog.rst' |
||
100 | ]; |
||
101 | |||
102 | $update = array( |
||
103 | ComposerConfig::CONFIG_ROOT => array( |
||
104 | PluginConfig::ROOT => array( |
||
105 | 'source' => 'changelog.json', |
||
106 | 'output' => array( |
||
107 | $type => $paths[$type] |
||
108 | ) |
||
109 | ) |
||
110 | ) |
||
111 | ); |
||
112 | |||
113 | $config = array_replace_recursive($config, $update); |
||
114 | |||
115 | $pathUtils = new \Vaimo\ComposerChangelogs\Utils\PathUtils(); |
||
116 | |||
117 | $encodedConfig = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
||
118 | |||
119 | $pkgConfigPath = $pathUtils->composePath($installPath, ComposerFiles::PACKAGE_CONFIG); |
||
120 | $chLogConfigPath = $pathUtils->composePath($installPath, 'changelog.json'); |
||
121 | |||
122 | file_put_contents($pkgConfigPath, $encodedConfig); |
||
123 | |||
124 | if (!file_exists($chLogConfigPath)) { |
||
125 | $changeLog = array( |
||
126 | '_readme' => array( |
||
127 | 'The contents of this file are used to generate CHANGELOG.md; It\'s kept in ' |
||
128 | . 'JSON/parsable format to make it', |
||
129 | 'possible to generate change-logs in other formats as well (when needed) and ' |
||
130 | . 'to do automatic releases based on', |
||
131 | 'added change-log records. More on how to use it: https://github.com/vaimo/composer-changelogs' |
||
132 | ) |
||
133 | ); |
||
134 | |||
135 | file_put_contents($chLogConfigPath, json_encode($changeLog, JSON_PRETTY_PRINT)); |
||
136 | } |
||
137 | |||
138 | $output->writeln('<info>Done</info>'); |
||
139 | } |
||
141 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths