Skip to content

Commit

Permalink
tv bump (#38)
Browse files Browse the repository at this point in the history
* bump ECS

* bump dev deps

* int max

* [rector] Rector fixes

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
TomasVotruba and actions-user committed Jan 15, 2024
1 parent ec0c85d commit 1f3653a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
# see https://github.com/shivammathur/setup-php
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
coverage: none

# composer install cache - https://github.com/ramsey/composer-install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/downgraded_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
-
uses: "shivammathur/setup-php@v2"
with:
php-version: 8.1
php-version: 8.2
coverage: none

# invoke patches
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
-
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
coverage: none

- uses: "ramsey/composer-install@v2"
Expand Down
17 changes: 7 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,25 @@
"bin/lines.php"
],
"require": {
"php": "^8.1",
"ext-json": "*",
"php": "^8.2",
"symfony/console": "^6.3",
"symfony/finder": "^6.3",
"illuminate/container": "^10.16",
"illuminate/container": "^10.35",
"webmozart/assert": "^1.11",
"nikic/php-parser": "^4.17",
"sebastian/lines-of-code": "^2.0",
"nunomaduro/termwind": "^1.15"
},
"require-dev": {
"phpunit/phpunit": "^10.3",
"rector/rector": "^0.18.0",
"phpunit/phpunit": "^10.5",
"rector/rector": "^0.19",
"phpstan/phpstan": "^1.10.26",
"symplify/easy-coding-standard": "^12.0",
"symplify/easy-coding-standard": "^12.1",
"tracy/tracy": "^2.10",
"tomasvotruba/class-leak": "^0.1.1",
"tomasvotruba/unused-public": "^0.2",
"tomasvotruba/type-coverage": "^0.2",
"tomasvotruba/class-leak": "^0.2",
"phpstan/extension-installer": "^1.3",
"symplify/vendor-patches": "^11.2",
"symplify/phpstan-rules": "12.1.4.72"
"symplify/phpstan-rules": "^12.1"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 6 additions & 14 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@
declare(strict_types=1);

use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
return ECSConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$ecsConfig->skip([
])
->withSkip([
'*/Fixture/*'
]);

$ecsConfig->sets([
SetList::COMMON,
SetList::PSR_12,
SetList::SYMPLIFY,
]);
};
])
->withPreparedSets(psr12: true, common: true, strict: true, symplify: true);
6 changes: 5 additions & 1 deletion src/Analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace TomasVotruba\Lines;

use Throwable;
use PhpParser\NodeTraverser;
use PhpParser\Parser;
use SebastianBergmann\LinesOfCode\Counter;
Expand Down Expand Up @@ -52,7 +53,7 @@ private function measureFile(Measurements $measurements, string $filePath): void
try {
// avoid stop on invalid file contents
$stmts = $this->parser->parse($fileContents);
} catch (\Throwable) {
} catch (Throwable) {
return;
}

Expand All @@ -75,6 +76,9 @@ private function measureFile(Measurements $measurements, string $filePath): void
$measurements->incrementCommentLines($linesOfCode->commentLinesOfCode());
}

/**
* @return int<0, max>
*/
private function resolveInitLinesOfCode(string $fileContents): int
{
$linesOfCode = substr_count($fileContents, "\n");
Expand Down
8 changes: 4 additions & 4 deletions tests/AnalyserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public function test(): void
$this->assertSame(1, $measurements->getPrivateMethods());

// static and non-static
$this->assertSame(25.0, $measurements->getStaticMethodsRelative());
$this->assertEqualsWithDelta(25.0, $measurements->getStaticMethodsRelative(), PHP_FLOAT_EPSILON);
$this->assertSame(1, $measurements->getStaticMethods());
$this->assertSame(3, $measurements->getNonStaticMethods());
$this->assertSame(75.0, $measurements->getNonStaticMethodsRelative());
$this->assertEqualsWithDelta(75.0, $measurements->getNonStaticMethodsRelative(), PHP_FLOAT_EPSILON);

// relative
$this->assertSame(8.5, $measurements->getCommentLinesRelative());
$this->assertSame(91.5, $measurements->getNonCommentLinesRelative());
$this->assertEqualsWithDelta(8.5, $measurements->getCommentLinesRelative(), PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(91.5, $measurements->getNonCommentLinesRelative(), PHP_FLOAT_EPSILON);
}

public function testSkipAnonymousClass(): void
Expand Down

0 comments on commit 1f3653a

Please sign in to comment.