Skip to content

Commit

Permalink
Get the static code analysis back (#49)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tonicospinelli committed Mar 23, 2022
1 parent 90ebac5 commit 1692158
Show file tree
Hide file tree
Showing 44 changed files with 121 additions and 131 deletions.
31 changes: 20 additions & 11 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,34 @@ tools:

build:
dependencies:
before:
- "sudo composer self-update"
override:
- "composer install --no-interaction --prefer-dist"
tests:
override:
-
command: './vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=clover.xml'
coverage:
file: 'clover.xml'
format: 'php-clover'
nodes:
analysis:
tests:
override:
- php-scrutinizer-run

coverage:
environment:
php:
ini:
"xdebug.mode": coverage
tests:
override:
-
command: './vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=clover.xml'
coverage:
file: 'clover.xml'
format: 'php-clover'
environment:
php:
version: 7.0.8
version: 8
mysql: false
postgresql: false
redis: false
elasticsearch: false
rabbitmq: false
mongodb: false
neo4j: false
memcached: false
memcached: false
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Brazanation Documents
=====================

[![Build Status](https://travis-ci.org/brazanation/php-documents.svg?branch=master)](https://travis-ci.org/brazanation/php-documents)
[![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)
[![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)
[![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)
[![StyleCI](https://styleci.io/repos/66179431/shield)](https://styleci.io/repos/66179431)
[![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)
[![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)
[![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)
[![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)
[![StyleCI](https://github.styleci.io/repos/66179431/shield?branch=main)](https://github.styleci.io/repos/66179431?branch=main)

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

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.4",
"phpunit/phpunit": "^9.5",
"codacy/coverage": "^1.0"
},
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/DigitCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private function calculateAdditionalDigit(string $digit) : int
private function calculateSingleSum(int $total) : int
{
if ($this->singleSum) {
return intval(($total / 10) + ($total % 10));
return (int) (($total / 10) + ($total % 10));
}

return $total;
Expand Down
4 changes: 2 additions & 2 deletions src/JudiciaryProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ protected function extractBaseNumber(string $number) : string
*/
public function calculateDigit(string $input) : string
{
$remainderNumber = intval($this->sequentialNumber) % 97;
$remainderNumber = (int) $this->sequentialNumber % 97;

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

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

$remainder = (float) $originNumber % 97;
Expand Down
2 changes: 1 addition & 1 deletion src/StateRegistration/Amapa.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct()
*/
public function calculateDigit(string $baseNumber) : string
{
$number = intval($baseNumber);
$number = (int) $baseNumber;
$lastDigit = $this->discoverLastDigit($number);
$digitToReplace = $this->discoverDigitToReplace($number);

Expand Down
2 changes: 1 addition & 1 deletion src/StateRegistration/Goias.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private function setCurrentDigit(string $digit)
*/
public function calculateDigit(string $baseNumber) : string
{
$digitToReplace = $this->discoverDigitToReplace(intval($baseNumber));
$digitToReplace = $this->discoverDigitToReplace((int) $baseNumber);

$calculator = new DigitCalculator($baseNumber);
$calculator->useComplementaryInsteadOfModule();
Expand Down
3 changes: 0 additions & 3 deletions tests/CnhTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,12 @@ public function provideEmptyData() : array
{
return [
[Cnh::LABEL, ''],
[Cnh::LABEL, null],
[Cnh::LABEL, 0],
];
}

public function provideInvalidNumber() : array
{
return [
[Cnh::LABEL, 1],
[Cnh::LABEL, '11111111111'],
[Cnh::LABEL, '06843273172'],
];
Expand Down
3 changes: 0 additions & 3 deletions tests/CnpjTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ public function provideEmptyData() : array
{
return [
[Cnpj::LABEL, ''],
[Cnpj::LABEL, null],
[Cnpj::LABEL, 0],
];
}

public function provideInvalidNumber() : array
{
return [
[Cnpj::LABEL, 1],
[Cnpj::LABEL, '11111111111111'],
[Cnpj::LABEL, '00111222100099'],
[Cnpj::LABEL, '00.111.222/1000-99'],
Expand Down
3 changes: 0 additions & 3 deletions tests/CnsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,12 @@ public function provideEmptyData() : array
{
return [
[Cns::LABEL, ''],
[Cns::LABEL, null],
[Cns::LABEL, 0],
];
}

public function provideInvalidNumber() : array
{
return [
[Cns::LABEL, 1],
[Cns::LABEL, '123123232323'],
[Cns::LABEL, '861238979874'],
];
Expand Down
3 changes: 0 additions & 3 deletions tests/CpfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ public function provideEmptyData() : array
{
return [
[Cpf::LABEL, ''],
[Cpf::LABEL, null],
[Cpf::LABEL, 0],
];
}

public function provideInvalidNumber() : array
{
return [
[Cpf::LABEL, 1],
[Cpf::LABEL, '11111111111'],
[Cpf::LABEL, '06843273172'],
[Cpf::LABEL, '068.432.731-72'],
Expand Down
3 changes: 0 additions & 3 deletions tests/JudiciaryProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ public function provideEmptyData() : array
{
return [
[JudiciaryProcess::LABEL, ''],
[JudiciaryProcess::LABEL, null],
[JudiciaryProcess::LABEL, 0],
];
}

public function provideInvalidNumber() : array
{
return [
[JudiciaryProcess::LABEL, 1],
[JudiciaryProcess::LABEL, '11111111111111'],
[JudiciaryProcess::LABEL, '00111222100099'],
[JudiciaryProcess::LABEL, '00.111.222/1000-99'],
Expand Down
3 changes: 0 additions & 3 deletions tests/PisPasepTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ public function provideEmptyData() : array
{
return [
[PisPasep::LABEL, ''],
[PisPasep::LABEL, null],
[PisPasep::LABEL, 0],
];
}

public function provideInvalidNumber() : array
{
return [
[PisPasep::LABEL, 1],
[PisPasep::LABEL, '11111111111'],
[PisPasep::LABEL, '51823129492'],
[PisPasep::LABEL, '51.82312.94-92'],
Expand Down
1 change: 0 additions & 1 deletion tests/RenavamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function provideEmptyData() : array
{
return [
[Renavam::LABEL, ''],
[Renavam::LABEL, null],
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Sped/CTeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testGenerateAValidNumber()
$this->assertEquals('33009911002506', "{$nfeKey->cnpj}", 'Failed assert for CNPJ');
$this->assertEquals('57', "{$nfeKey->model}", 'Failed assert for model');
$this->assertEquals('012', $nfeKey->sequence, 'Failed assert for sequence');
$this->assertEquals('00000780', $nfeKey->invoiceNumber, 'Failed assert for invoice number');
$this->assertEquals('000000780', $nfeKey->invoiceNumber, 'Failed assert for invoice number');
$this->assertEquals(EmissionType::NORMAL, "{$nfeKey->emissionType}", 'Failed assert for emission type');
$this->assertEquals('26730161', $nfeKey->controlNumber, 'Failed assert for digit');
$this->assertEquals('52060433009911002506570120000007801267301610', "{$nfeKey}");
Expand Down
4 changes: 2 additions & 2 deletions tests/Sped/MDFeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public function testGenerateAValidNumber()
$this->assertEquals($generatedAt, $nfeKey->generatedAt, 'Failed assert for generatedAt');
$this->assertEquals('33009911002506', "{$nfeKey->cnpj}", 'Failed assert for CNPJ');
$this->assertEquals(Model::TYPE_MDFE, "{$nfeKey->model}", 'Failed assert for model');
$this->assertEquals('000000012', $nfeKey->sequence, 'Failed assert for sequence');
$this->assertEquals('00000780', $nfeKey->invoiceNumber, 'Failed assert for invoice number');
$this->assertEquals('012', $nfeKey->sequence, 'Failed assert for sequence');
$this->assertEquals('000000780', $nfeKey->invoiceNumber, 'Failed assert for invoice number');
$this->assertEquals(EmissionType::NORMAL, "{$nfeKey->emissionType}", 'Failed assert for emission type');
$this->assertEquals('26730161', $nfeKey->controlNumber, 'Failed assert for digit');
$this->assertEquals('52060433009911002506580120000007801267301614', "{$nfeKey}");
Expand Down
2 changes: 1 addition & 1 deletion tests/Sped/NFCeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function testGenerateAValidNumber()
$this->assertEquals('012', $nfeKey->sequence, 'Failed assert for sequence');
$this->assertEquals('000000780', $nfeKey->invoiceNumber, 'Failed assert for invoice number');
$this->assertEquals(EmissionType::CONTINGENCY_ON_SAFETY_FORM, "{$nfeKey->emissionType}", 'Failed assert for emission type');
$this->assertEquals('006730161', $nfeKey->controlNumber, 'Failed assert for digit');
$this->assertEquals('06730161', $nfeKey->controlNumber, 'Failed assert for digit');
$this->assertEquals('52060433009911002506650120000007802067301610', "{$nfeKey}");
}
}
3 changes: 0 additions & 3 deletions tests/StateRegistration/AcreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ public function provideEmptyData() : array
{
return [
[Acre::LONG_NAME, ''],
[Acre::LONG_NAME, null],
[Acre::LONG_NAME, 0],
];
}

public function provideInvalidNumber() : array
{
return [
[Acre::LONG_NAME, 1],
[Acre::LONG_NAME, '0100482300113'],
];
}
Expand Down
4 changes: 2 additions & 2 deletions tests/StateRegistration/AlagoasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public function provideValidNumbersAndExpectedFormat() : array
public function provideEmptyData() : array
{
return [
[Alagoas::LONG_NAME, 0],
[Alagoas::LONG_NAME, ''],
];
}

public function provideInvalidNumber() : array
{
return [
[Alagoas::LONG_NAME, 1],
[Alagoas::LONG_NAME, '1'],
[Alagoas::LONG_NAME, '0100482300113'],
];
}
Expand Down
4 changes: 2 additions & 2 deletions tests/StateRegistration/AmapaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public function provideValidNumbersAndExpectedFormat() : array
public function provideEmptyData() : array
{
return [
[Amapa::LONG_NAME, 0],
[Amapa::LONG_NAME, ''],
];
}

public function provideInvalidNumber() : array
{
return [
[Amapa::LONG_NAME, 1],
[Amapa::LONG_NAME, '1'],
[Amapa::LONG_NAME, '03.012.345-8'],
];
}
Expand Down
4 changes: 2 additions & 2 deletions tests/StateRegistration/AmazonasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public function provideValidNumbersAndExpectedFormat() : array
public function provideEmptyData() : array
{
return [
[Amazonas::LONG_NAME, 0],
[Amazonas::LONG_NAME, ''],
];
}

public function provideInvalidNumber() : array
{
return [
[Amazonas::LONG_NAME, 1],
[Amazonas::LONG_NAME, '1'],
[Amazonas::LONG_NAME, '03.012.345-8'],
];
}
Expand Down
14 changes: 7 additions & 7 deletions tests/StateRegistration/BahiaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ public function createDocumentFromString(string $number)
public function provideValidNumbers() : array
{
return [
['123456-63'],
['0123456-63'],
['1000003-06'],
['1057652-04'],
['0635718-30'],
['770288-84'],
['0770288-84'],
['077.028.884'],
['085456408'],
['78215597'],
['75467384'],
['45564835'],
['01314209'],
['078215597'],
['075467384'],
['045564835'],
['001314209'],
['111568918'],
['039681030']
];
Expand All @@ -49,7 +49,7 @@ public function provideValidNumbersAndExpectedFormat() : array
public function provideEmptyData() : array
{
return [
[Bahia::LONG_NAME, 0],
[Bahia::LONG_NAME, ''],
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/StateRegistration/CearaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function provideValidNumbersAndExpectedFormat() : array
public function provideEmptyData() : array
{
return [
[Ceara::LONG_NAME, 0],
[Ceara::LONG_NAME, ''],
];
}

Expand Down
4 changes: 1 addition & 3 deletions tests/StateRegistration/DistritoFederalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ public function provideEmptyData() : array
{
return [
[DF::LONG_NAME, ''],
[DF::LONG_NAME, null],
[DF::LONG_NAME, 0],
];
}

public function provideInvalidNumber() : array
{
return [
[DF::LONG_NAME, 1],
[DF::LONG_NAME, '1'],
[DF::LONG_NAME, '0756855600125'],
];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/StateRegistration/EspiritoSantoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function provideValidNumbersAndExpectedFormat() : array
public function provideEmptyData() : array
{
return [
[EspiritoSanto::LONG_NAME, 0],
[EspiritoSanto::LONG_NAME, ''],
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/StateRegistration/GoiasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function provideValidNumbersAndExpectedFormat() : array
public function provideEmptyData() : array
{
return [
[Goias::LONG_NAME, 0],
[Goias::LONG_NAME, ''],
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/StateRegistration/MaranhaoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function provideValidNumbersAndExpectedFormat() : array
public function provideEmptyData() : array
{
return [
[Maranhao::LONG_NAME, 0],
[Maranhao::LONG_NAME, ''],
];
}

Expand Down
Loading

0 comments on commit 1692158

Please sign in to comment.