Showing 202 of 202 total issues
File Certificate.php
has 884 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace vakata\certificate;
use vakata\asn1\ASN1;
Function parseLegacyCertificate
has a Cognitive Complexity of 95 (exceeds 5 allowed). Consider refactoring. Open
protected function parseLegacyCertificate(array $cert)
{
$iss = null;
$pro = null;
$nat = null;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($pro === '1.5.1.1') {
$parsed = $parseSubject(
$cert['subject'],
[ASN1::TextToOID('stateOrProvinceName'), ASN1::TextToOID('organizationalUnit')],
['EGN'=>'egn', 'PID'=>'pid', 'BULSTAT'=>'bulstat']
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 331.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
} elseif (in_array($pro, ['1.1.1.3', '1.1.1.4', '1.1.1.6'])) {
$parsed = $parseSubject(
$cert['subject'],
[ASN1::TextToOID('organizationalUnit'), ASN1::TextToOID('title')],
['EGN'=>'egn', 'PID'=>'pid', 'B'=>'bulstat']
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 331.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method parseLegacyCertificate
has 282 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function parseLegacyCertificate(array $cert)
{
$iss = null;
$pro = null;
$nat = null;
Function isRevokedOCSP
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
public function isRevokedOCSP() : bool
{
$ocsp = $this->getOCSPPoints();
if (count($ocsp)) {
if ($this->isSelfSigned()) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function verify
has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring. Open
public static function verify(
string $data,
string $signature,
string $publicKey,
string $algorithm,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validatePDF
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
public static function validatePDF(string $pdf) : array
{
$signers = [];
$matches = [];
$current = -1;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Certificate
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
class Certificate
{
protected $cert;
protected $data;
protected $sign;
Function parseCertificate
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
protected function parseCertificate(string $cert) : array
{
try {
$orig = Parser::fromString($cert)->toArray();
$data = $orig['tbsCertificate'];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getSubjectData
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function getSubjectData() : array
{
$original = $this->cert['extensions'][ASN1::TextToOID('subjectAltName')] ?? [];
while (is_array($original) && isset($original[0]) && is_array($original[0]) && isset($original[0][0]) && is_array($original[0][0])) {
$original = $original[0];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method verify
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function verify(
string $data,
string $signature,
string $publicKey,
string $algorithm,
The class Certificate has an overall complexity of 231 which is very high. The configured complexity threshold is 50. Open
class Certificate
{
protected $cert;
protected $data;
protected $sign;
- Exclude checks
The class P7S has an overall complexity of 63 which is very high. The configured complexity threshold is 50. Open
class P7S
{
protected $p7s;
protected $raw;
- Exclude checks
Method isRevokedOCSP
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function isRevokedOCSP() : bool
{
$ocsp = $this->getOCSPPoints();
if (count($ocsp)) {
if ($this->isSelfSigned()) {
Function revoked
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function revoked(bool $extensions = false)
{
$temp = $this->data->toArray(false, true)['tbsCertList'];
if (isset($temp['revokedCertificates'])) {
foreach ($temp['revokedCertificates']->rawData() as $v) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method validateXML
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function validateXML(string $xmlContent, ?Certificate $crt = null) : array
{
$xml = new \DOMDocument();
$xml->preserveWhiteSpace = true;
$xml->formatOutput = false;
Method parseCertificate
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function parseCertificate(string $cert) : array
{
try {
$orig = Parser::fromString($cert)->toArray();
$data = $orig['tbsCertificate'];
File P7S.php
has 275 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace vakata\certificate;
use vakata\asn1\ASN1;
Function getSigners
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function getSigners() : array
{
$signers = [];
foreach ($this->p7s->toArray()['data']['signerInfos'] as $k => $v) {
$signers[$k] = [
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"