Skip to content
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
8 changes: 7 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: CI

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- '*'

jobs:
testsuite:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/phar-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.4'
extensions: json, fileinfo
tools: composer

- name: Install dependencies
run: composer install --no-dev --optimize-autoloader

- name: Inject version from tag
run: sed -i "s/public const VERSION = .*/public const VERSION = '\${{ github.ref_name }}';/" src/Application.php

- name: Build PHAR
run: composer build-phar

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
.env
infection.log
phive.phar
cognitive-analysis.phar
phpcca.phar
7 changes: 6 additions & 1 deletion box.json.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"main": "./bin/phpcca",
"main": "bin/phpcca",
"compression": "GZ",
"output": "phpcca.phar",
"force-autodiscovery": true,
"compactors": [
"KevinGH\\Box\\Compactor\\Json",
"KevinGH\\Box\\Compactor\\Php",
"KevinGH\\Box\\Compactor\\PhpScoper"
],
"files": [
"config.yml",
"composer.json",
Expand Down
10 changes: 10 additions & 0 deletions scripts/tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Get the latest tag reachable from the previous commit
TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null)

if [ -n "$TAG" ]; then
sed -i "s/public const VERSION = .*/public const VERSION = '$TAG';/" src/Application.php
git add src/Application.php
echo "Version set to $TAG"
else
echo "No previous tag found."
fi
6 changes: 6 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
*/
class Application
{
public const VERSION = '1.3.0';

private ContainerBuilder $containerBuilder;

public function __construct()
Expand Down Expand Up @@ -231,6 +233,10 @@ private function registerCommands(): void
private function configureApplication(): void
{
$this->containerBuilder->register(SymfonyApplication::class, SymfonyApplication::class)
->setArguments([
'Cognitive Code Analysis',
self::VERSION
])
->setPublic(true)
->addMethodCall('add', [new Reference(CognitiveMetricsCommand::class)])
->addMethodCall('add', [new Reference(ChurnCommand::class)]);
Expand Down
14 changes: 10 additions & 4 deletions src/Command/EventHandler/VerboseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function __construct(

public function __invoke(SourceFilesFound|FileProcessed $event): void
{
if (
$this->input->hasOption(CognitiveMetricsCommand::OPTION_DEBUG)
&& $this->input->getOption(CognitiveMetricsCommand::OPTION_DEBUG) === false
) {
if (!$this->isDebugEnabled()) {
return;
}

Expand Down Expand Up @@ -62,4 +59,13 @@ private function formatBytes(int $size): string

return round($size, 2) . ' ' . $units[$index];
}

/**
* @return bool
*/
public function isDebugEnabled(): bool
{
return $this->input->hasOption(CognitiveMetricsCommand::OPTION_DEBUG)
&& $this->input->getOption(CognitiveMetricsCommand::OPTION_DEBUG) === false;
}
}