Skip to content

Commit 1692158

Browse files
Get the static code analysis back (#49)
A misconfiguration stopped the code analysis, and the PHP8 version broke the tests because the test code didn't respect the typehint. So, the Scrutinizer and Codacy are established and working. Now is possible to get metrics about the project
1 parent 90ebac5 commit 1692158

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+121
-131
lines changed

.scrutinizer.yml

+20-11
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,34 @@ tools:
2424

2525
build:
2626
dependencies:
27-
before:
28-
- "sudo composer self-update"
2927
override:
3028
- "composer install --no-interaction --prefer-dist"
31-
tests:
32-
override:
33-
-
34-
command: './vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=clover.xml'
35-
coverage:
36-
file: 'clover.xml'
37-
format: 'php-clover'
29+
nodes:
30+
analysis:
31+
tests:
32+
override:
33+
- php-scrutinizer-run
34+
35+
coverage:
36+
environment:
37+
php:
38+
ini:
39+
"xdebug.mode": coverage
40+
tests:
41+
override:
42+
-
43+
command: './vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=clover.xml'
44+
coverage:
45+
file: 'clover.xml'
46+
format: 'php-clover'
3847
environment:
3948
php:
40-
version: 7.0.8
49+
version: 8
4150
mysql: false
4251
postgresql: false
4352
redis: false
4453
elasticsearch: false
4554
rabbitmq: false
4655
mongodb: false
4756
neo4j: false
48-
memcached: false
57+
memcached: false

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Brazanation Documents
22
=====================
33

4-
[![Build Status](https://travis-ci.org/brazanation/php-documents.svg?branch=master)](https://travis-ci.org/brazanation/php-documents)
5-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0bdf934bc4224a9fb9d51dc9162fb000)](https://www.codacy.com/app/tonicospinelli/php-documents?utm_source=github.com&utm_medium=referral&utm_content=brazanation/php-documents&utm_campaign=Badge_Grade)
6-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/brazanation/php-documents/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/brazanation/php-documents/?branch=master)
7-
[![Code Coverage](https://scrutinizer-ci.com/g/brazanation/php-documents/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/brazanation/php-documents/?branch=master)
8-
[![StyleCI](https://styleci.io/repos/66179431/shield)](https://styleci.io/repos/66179431)
4+
[![Build Status](https://scrutinizer-ci.com/g/brazanation/php-documents/badges/build.png?b=main)](https://scrutinizer-ci.com/g/brazanation/php-documents/build-status/main)
5+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f8c31359fca64c0c9c8375182fbceefd)](https://www.codacy.com/gh/brazanation/php-documents/dashboard?utm_source=github.com&utm_medium=referral&utm_content=brazanation/php-documents&utm_campaign=Badge_Grade)
6+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/brazanation/php-documents/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/brazanation/php-documents/?branch=main)
7+
[![Code Coverage](https://scrutinizer-ci.com/g/brazanation/php-documents/badges/coverage.png?b=main)](https://scrutinizer-ci.com/g/brazanation/php-documents/?branch=main)
8+
[![StyleCI](https://github.styleci.io/repos/66179431/shield?branch=main)](https://github.styleci.io/repos/66179431?branch=main)
99

1010
A PHP library to provide Brazilian Documents safer, easier and fun!
1111

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"php": ">=7.0"
77
},
88
"require-dev": {
9-
"phpunit/phpunit": "^6.4",
9+
"phpunit/phpunit": "^9.5",
1010
"codacy/coverage": "^1.0"
1111
},
1212
"license": "MIT",

src/DigitCalculator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private function calculateAdditionalDigit(string $digit) : int
273273
private function calculateSingleSum(int $total) : int
274274
{
275275
if ($this->singleSum) {
276-
return intval(($total / 10) + ($total % 10));
276+
return (int) (($total / 10) + ($total % 10));
277277
}
278278

279279
return $total;

src/JudiciaryProcess.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ protected function extractBaseNumber(string $number) : string
118118
*/
119119
public function calculateDigit(string $input) : string
120120
{
121-
$remainderNumber = intval($this->sequentialNumber) % 97;
121+
$remainderNumber = (int) $this->sequentialNumber % 97;
122122

123123
$judiciaryNumber = "{$remainderNumber}{$this->year}{$this->judiciary}{$this->court}";
124124

125-
$remainderJudiciary = intval($judiciaryNumber) % 97;
125+
$remainderJudiciary = (int) $judiciaryNumber % 97;
126126
$originNumber = "{$remainderJudiciary}{$this->origin}00";
127127

128128
$remainder = (float) $originNumber % 97;

src/StateRegistration/Amapa.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct()
3030
*/
3131
public function calculateDigit(string $baseNumber) : string
3232
{
33-
$number = intval($baseNumber);
33+
$number = (int) $baseNumber;
3434
$lastDigit = $this->discoverLastDigit($number);
3535
$digitToReplace = $this->discoverDigitToReplace($number);
3636

src/StateRegistration/Goias.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private function setCurrentDigit(string $digit)
4848
*/
4949
public function calculateDigit(string $baseNumber) : string
5050
{
51-
$digitToReplace = $this->discoverDigitToReplace(intval($baseNumber));
51+
$digitToReplace = $this->discoverDigitToReplace((int) $baseNumber);
5252

5353
$calculator = new DigitCalculator($baseNumber);
5454
$calculator->useComplementaryInsteadOfModule();

tests/CnhTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@ public function provideEmptyData() : array
3636
{
3737
return [
3838
[Cnh::LABEL, ''],
39-
[Cnh::LABEL, null],
40-
[Cnh::LABEL, 0],
4139
];
4240
}
4341

4442
public function provideInvalidNumber() : array
4543
{
4644
return [
47-
[Cnh::LABEL, 1],
4845
[Cnh::LABEL, '11111111111'],
4946
[Cnh::LABEL, '06843273172'],
5047
];

tests/CnpjTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ public function provideEmptyData() : array
3737
{
3838
return [
3939
[Cnpj::LABEL, ''],
40-
[Cnpj::LABEL, null],
41-
[Cnpj::LABEL, 0],
4240
];
4341
}
4442

4543
public function provideInvalidNumber() : array
4644
{
4745
return [
48-
[Cnpj::LABEL, 1],
4946
[Cnpj::LABEL, '11111111111111'],
5047
[Cnpj::LABEL, '00111222100099'],
5148
[Cnpj::LABEL, '00.111.222/1000-99'],

tests/CnsTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,12 @@ public function provideEmptyData() : array
4242
{
4343
return [
4444
[Cns::LABEL, ''],
45-
[Cns::LABEL, null],
46-
[Cns::LABEL, 0],
4745
];
4846
}
4947

5048
public function provideInvalidNumber() : array
5149
{
5250
return [
53-
[Cns::LABEL, 1],
5451
[Cns::LABEL, '123123232323'],
5552
[Cns::LABEL, '861238979874'],
5653
];

tests/CpfTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ public function provideEmptyData() : array
3737
{
3838
return [
3939
[Cpf::LABEL, ''],
40-
[Cpf::LABEL, null],
41-
[Cpf::LABEL, 0],
4240
];
4341
}
4442

4543
public function provideInvalidNumber() : array
4644
{
4745
return [
48-
[Cpf::LABEL, 1],
4946
[Cpf::LABEL, '11111111111'],
5047
[Cpf::LABEL, '06843273172'],
5148
[Cpf::LABEL, '068.432.731-72'],

tests/JudiciaryProcessTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ public function provideEmptyData() : array
3737
{
3838
return [
3939
[JudiciaryProcess::LABEL, ''],
40-
[JudiciaryProcess::LABEL, null],
41-
[JudiciaryProcess::LABEL, 0],
4240
];
4341
}
4442

4543
public function provideInvalidNumber() : array
4644
{
4745
return [
48-
[JudiciaryProcess::LABEL, 1],
4946
[JudiciaryProcess::LABEL, '11111111111111'],
5047
[JudiciaryProcess::LABEL, '00111222100099'],
5148
[JudiciaryProcess::LABEL, '00.111.222/1000-99'],

tests/PisPasepTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ public function provideEmptyData() : array
3737
{
3838
return [
3939
[PisPasep::LABEL, ''],
40-
[PisPasep::LABEL, null],
41-
[PisPasep::LABEL, 0],
4240
];
4341
}
4442

4543
public function provideInvalidNumber() : array
4644
{
4745
return [
48-
[PisPasep::LABEL, 1],
4946
[PisPasep::LABEL, '11111111111'],
5047
[PisPasep::LABEL, '51823129492'],
5148
[PisPasep::LABEL, '51.82312.94-92'],

tests/RenavamTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public function provideEmptyData() : array
3737
{
3838
return [
3939
[Renavam::LABEL, ''],
40-
[Renavam::LABEL, null],
4140
];
4241
}
4342

tests/Sped/CTeTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function testGenerateAValidNumber()
8383
$this->assertEquals('33009911002506', "{$nfeKey->cnpj}", 'Failed assert for CNPJ');
8484
$this->assertEquals('57', "{$nfeKey->model}", 'Failed assert for model');
8585
$this->assertEquals('012', $nfeKey->sequence, 'Failed assert for sequence');
86-
$this->assertEquals('00000780', $nfeKey->invoiceNumber, 'Failed assert for invoice number');
86+
$this->assertEquals('000000780', $nfeKey->invoiceNumber, 'Failed assert for invoice number');
8787
$this->assertEquals(EmissionType::NORMAL, "{$nfeKey->emissionType}", 'Failed assert for emission type');
8888
$this->assertEquals('26730161', $nfeKey->controlNumber, 'Failed assert for digit');
8989
$this->assertEquals('52060433009911002506570120000007801267301610', "{$nfeKey}");

tests/Sped/MDFeTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public function testGenerateAValidNumber()
8282
$this->assertEquals($generatedAt, $nfeKey->generatedAt, 'Failed assert for generatedAt');
8383
$this->assertEquals('33009911002506', "{$nfeKey->cnpj}", 'Failed assert for CNPJ');
8484
$this->assertEquals(Model::TYPE_MDFE, "{$nfeKey->model}", 'Failed assert for model');
85-
$this->assertEquals('000000012', $nfeKey->sequence, 'Failed assert for sequence');
86-
$this->assertEquals('00000780', $nfeKey->invoiceNumber, 'Failed assert for invoice number');
85+
$this->assertEquals('012', $nfeKey->sequence, 'Failed assert for sequence');
86+
$this->assertEquals('000000780', $nfeKey->invoiceNumber, 'Failed assert for invoice number');
8787
$this->assertEquals(EmissionType::NORMAL, "{$nfeKey->emissionType}", 'Failed assert for emission type');
8888
$this->assertEquals('26730161', $nfeKey->controlNumber, 'Failed assert for digit');
8989
$this->assertEquals('52060433009911002506580120000007801267301614', "{$nfeKey}");

tests/Sped/NFCeTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function testGenerateAValidNumber()
8686
$this->assertEquals('012', $nfeKey->sequence, 'Failed assert for sequence');
8787
$this->assertEquals('000000780', $nfeKey->invoiceNumber, 'Failed assert for invoice number');
8888
$this->assertEquals(EmissionType::CONTINGENCY_ON_SAFETY_FORM, "{$nfeKey->emissionType}", 'Failed assert for emission type');
89-
$this->assertEquals('006730161', $nfeKey->controlNumber, 'Failed assert for digit');
89+
$this->assertEquals('06730161', $nfeKey->controlNumber, 'Failed assert for digit');
9090
$this->assertEquals('52060433009911002506650120000007802067301610', "{$nfeKey}");
9191
}
9292
}

tests/StateRegistration/AcreTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ public function provideEmptyData() : array
3737
{
3838
return [
3939
[Acre::LONG_NAME, ''],
40-
[Acre::LONG_NAME, null],
41-
[Acre::LONG_NAME, 0],
4240
];
4341
}
4442

4543
public function provideInvalidNumber() : array
4644
{
4745
return [
48-
[Acre::LONG_NAME, 1],
4946
[Acre::LONG_NAME, '0100482300113'],
5047
];
5148
}

tests/StateRegistration/AlagoasTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ public function provideValidNumbersAndExpectedFormat() : array
4444
public function provideEmptyData() : array
4545
{
4646
return [
47-
[Alagoas::LONG_NAME, 0],
47+
[Alagoas::LONG_NAME, ''],
4848
];
4949
}
5050

5151
public function provideInvalidNumber() : array
5252
{
5353
return [
54-
[Alagoas::LONG_NAME, 1],
54+
[Alagoas::LONG_NAME, '1'],
5555
[Alagoas::LONG_NAME, '0100482300113'],
5656
];
5757
}

tests/StateRegistration/AmapaTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public function provideValidNumbersAndExpectedFormat() : array
3737
public function provideEmptyData() : array
3838
{
3939
return [
40-
[Amapa::LONG_NAME, 0],
40+
[Amapa::LONG_NAME, ''],
4141
];
4242
}
4343

4444
public function provideInvalidNumber() : array
4545
{
4646
return [
47-
[Amapa::LONG_NAME, 1],
47+
[Amapa::LONG_NAME, '1'],
4848
[Amapa::LONG_NAME, '03.012.345-8'],
4949
];
5050
}

tests/StateRegistration/AmazonasTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public function provideValidNumbersAndExpectedFormat() : array
4040
public function provideEmptyData() : array
4141
{
4242
return [
43-
[Amazonas::LONG_NAME, 0],
43+
[Amazonas::LONG_NAME, ''],
4444
];
4545
}
4646

4747
public function provideInvalidNumber() : array
4848
{
4949
return [
50-
[Amazonas::LONG_NAME, 1],
50+
[Amazonas::LONG_NAME, '1'],
5151
[Amazonas::LONG_NAME, '03.012.345-8'],
5252
];
5353
}

tests/StateRegistration/BahiaTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ public function createDocumentFromString(string $number)
2222
public function provideValidNumbers() : array
2323
{
2424
return [
25-
['123456-63'],
25+
['0123456-63'],
2626
['1000003-06'],
2727
['1057652-04'],
2828
['0635718-30'],
29-
['770288-84'],
29+
['0770288-84'],
3030
['077.028.884'],
3131
['085456408'],
32-
['78215597'],
33-
['75467384'],
34-
['45564835'],
35-
['01314209'],
32+
['078215597'],
33+
['075467384'],
34+
['045564835'],
35+
['001314209'],
3636
['111568918'],
3737
['039681030']
3838
];
@@ -49,7 +49,7 @@ public function provideValidNumbersAndExpectedFormat() : array
4949
public function provideEmptyData() : array
5050
{
5151
return [
52-
[Bahia::LONG_NAME, 0],
52+
[Bahia::LONG_NAME, ''],
5353
];
5454
}
5555

tests/StateRegistration/CearaTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function provideValidNumbersAndExpectedFormat() : array
4040
public function provideEmptyData() : array
4141
{
4242
return [
43-
[Ceara::LONG_NAME, 0],
43+
[Ceara::LONG_NAME, ''],
4444
];
4545
}
4646

tests/StateRegistration/DistritoFederalTest.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ public function provideEmptyData() : array
4242
{
4343
return [
4444
[DF::LONG_NAME, ''],
45-
[DF::LONG_NAME, null],
46-
[DF::LONG_NAME, 0],
4745
];
4846
}
4947

5048
public function provideInvalidNumber() : array
5149
{
5250
return [
53-
[DF::LONG_NAME, 1],
51+
[DF::LONG_NAME, '1'],
5452
[DF::LONG_NAME, '0756855600125'],
5553
];
5654
}

tests/StateRegistration/EspiritoSantoTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function provideValidNumbersAndExpectedFormat() : array
4242
public function provideEmptyData() : array
4343
{
4444
return [
45-
[EspiritoSanto::LONG_NAME, 0],
45+
[EspiritoSanto::LONG_NAME, ''],
4646
];
4747
}
4848

tests/StateRegistration/GoiasTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function provideValidNumbersAndExpectedFormat() : array
3838
public function provideEmptyData() : array
3939
{
4040
return [
41-
[Goias::LONG_NAME, 0],
41+
[Goias::LONG_NAME, ''],
4242
];
4343
}
4444

tests/StateRegistration/MaranhaoTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function provideValidNumbersAndExpectedFormat() : array
3737
public function provideEmptyData() : array
3838
{
3939
return [
40-
[Maranhao::LONG_NAME, 0],
40+
[Maranhao::LONG_NAME, ''],
4141
];
4242
}
4343

0 commit comments

Comments
 (0)