Showing 84 of 84 total issues
Method convertFromControlChars
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function convertFromControlChars(string $value): string
{
// critical ctrl values
$search = [
chr(0), chr(1), chr(2), chr(3), chr(4), chr(5),
Method localize
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function localize(string $key, array $args = []): string
{
$locale = $this->appLocale;
$segments = explode(".", $key);
$localizeIdentifier = $segments[0];
Function initializeRoutesFromAttributes
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private static function initializeRoutesFromAttributes(RouteRepository $repository): void
{
$class = new ReflectionClass(static::class);
$baseRoute = self::initializeBaseRoute($class);
$result = self::initializeBaseAuthorizationRules($class);
- 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 14 (exceeds 5 allowed). Consider refactoring. Open
public function verify(array $fields = []): bool
{
if ($this->optional && $this->isEmpty()) {
return true;
}
- 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 convertFromJSCharCode
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function convertFromJSCharCode(string $value): string
{
$matches = [];
// check if value matches typical charCode pattern
Similar blocks of code found in 2 locations. Consider refactoring. Open
private function getDirectoryLastModifiedTime(string $rootDirectoryPath): int
{
$lastModifiedTime = 0;
$directoryLastModifiedTime = filemtime($rootDirectoryPath);
foreach (glob("$rootDirectoryPath/*") as $file) {
- 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 111.
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
private function getDirectoryLastAccessedTime(string $rootDirectoryPath): int
{
$lastAccessedTime = 0;
$directoryLastAccessedTime = fileatime($rootDirectoryPath);
foreach (glob("$rootDirectoryPath/*") as $file) {
- 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 111.
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 convertFromUTF7
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function convertFromUTF7(string $value): string
{
if (preg_match('/\+A\w+-?/m', $value)) {
if (function_exists('mb_convert_encoding')) {
$value .= "\n" . mb_convert_encoding($value, 'UTF-8', 'UTF-7');
Method convertFromConcatenated
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function convertFromConcatenated(string $value): string
{
//normalize remaining backslashes
if ($value != preg_replace('/(\w)\\\/', "$1", $value)) {
$value .= preg_replace('/(\w)\\\/', "$1", $value);
Method nested
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function nested(string $key, array $rules): Rule
{
$resultRule = new Rule(null, "", "nested");
foreach ($rules as $rule) {
if (!($rule instanceof Rule)) {
Method uploadAsChunks
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function uploadAsChunks(string $filePath, array $payload = [], ?callable $callback = null, int $chuckSize = 1024000 * 20)
{
if (!is_readable($filePath)) {
throw new InvalidArgumentException("Specified filepath [$filePath] is not readable and thus cannot be prepared as a remote request file transfer.");
}
Method iteration
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function iteration(array $rules, string $mode = 'values'): Rule
{
$resultRule = new Rule(null, "", ($mode == 'values') ? "each" : "eachKey");
foreach ($rules as $rule) {
if (!($rule instanceof Rule)) {
Method initializeRoutesFromAttributes
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function initializeRoutesFromAttributes(RouteRepository $repository): void
{
$class = new ReflectionClass(static::class);
$baseRoute = self::initializeBaseRoute($class);
$result = self::initializeBaseAuthorizationRules($class);
Method getallheaders
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getallheaders(): array
{
$headers = [];
$copy_server = [
'CONTENT_TYPE' => 'Content-Type',
Function restrictArguments
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function restrictArguments(Controller $controller, RouteDefinition $route): void
{
$parameterNames = $route->getArgumentNames();
foreach ($controller->getRestrictedArguments() as $name => $rules) {
if (in_array($name, $parameterNames)) {
- 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 convertFromSQLHex
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function convertFromSQLHex(string $value): string
{
$matches = [];
if (preg_match_all('/(?:(?:\A|[^\d])0x[a-f\d]{3,}[a-f\d]*)+/im', $value, $matches)) {
foreach ($matches[0] as $match) {
- 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 buildResponse
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildResponse(): Response
{
ob_start(); ?>
BEGIN:VCALENDAR
VERSION:2.0
Method download
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function download(string $filePath, ?string $filename = null, bool $deleteAfter = false): Response
{
if (!File::exists($filePath)) {
throw new InvalidArgumentException("Specified file doesn't exists");
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function encrypt(string $key, ?string $destination = null)
{
$clearTextContent = $this->read();
$cipher = Cryptography::encrypt($clearTextContent, $key);
if (!is_null($destination)) {
- 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 101.
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
public function decrypt(string $key, ?string $destination = null)
{
$cipher = $this->read();
$clearTextContent = Cryptography::decrypt($cipher, $key);
if (!is_null($destination)) {
- 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 101.
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