Showing 41 of 41 total issues
Function buildOrderFromOrderCopy
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
public function buildOrderFromOrderCopy(Model $order, stdClass $orderCopy): Model
{
// Order namespace
$orderClass = config('nikolag.connections.square.order.namespace');
// Set payment type to square
- Read upRead up
- Create a ticketCreate a ticket
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 (($parent && ! $parent->hasTax($tax)) || ! Arr::has($tax, 'id')) {
$tempTax = new Tax($tax);
} else {
// Load tax with pivot
if (Arr::has($tax, 'pivot')) {
- Read upRead up
- Create a ticketCreate a ticket
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 171.
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
if (($parent && ! $parent->hasDiscount($discount)) || ! Arr::has($discount, 'id')) {
$tempDiscount = new Discount($discount);
} else {
// Load discount with pivot
if (Arr::has($discount, 'pivot')) {
- Read upRead up
- Create a ticketCreate a ticket
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 171.
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
Function buildDiscounts
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function buildDiscounts(Collection $discounts, string $currency): array
{
$temp = [];
if ($discounts->isNotEmpty()) {
foreach ($discounts as $discount) {
- Read upRead up
- Create a ticketCreate a ticket
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 createDiscounts
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public function createDiscounts(array $discounts, string $scope, Model $parent = null): Collection
{
$temp = collect([]);
foreach ($discounts as $discount) {
//If discount doesn't have amount AND percentage in discounts table
- Read upRead up
- Create a ticketCreate a ticket
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 buildOrderCopyFromArray
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function buildOrderCopyFromArray(array $order): stdClass
{
try {
$orderCopy = new stdClass();
// Create taxes Collection
- Read upRead up
- Create a ticketCreate a ticket
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
File SquareService.php
has 284 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Nikolag\Square;
use Nikolag\Core\Abstracts\CorePaymentService;
- Create a ticketCreate a ticket
Function buildOrderCopyFromModel
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function buildOrderCopyFromModel(Model $order): stdClass
{
try {
$orderCopy = new stdClass();
// Create taxes Collection
- Read upRead up
- Create a ticketCreate a ticket
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 charge
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function charge(array $options): Transaction
{
$location_id = array_key_exists('location_id', $options) ? $options['location_id'] : null;
$currency = array_key_exists('currency', $options) ? $options['currency'] : 'USD';
$prepData = [
- Create a ticketCreate a ticket
Function createTaxes
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function createTaxes(array $taxes, string $scope, Model $parent = null): Collection
{
$temp = collect([]);
foreach ($taxes as $tax) {
//If percentage doesn't exist on a taxes table
- Read upRead up
- Create a ticketCreate a ticket
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 buildOrderFromOrderCopy
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildOrderFromOrderCopy(Model $order, stdClass $orderCopy): Model
{
// Order namespace
$orderClass = config('nikolag.connections.square.order.namespace');
// Set payment type to square
- Create a ticketCreate a ticket
Function charge
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function charge(array $options): Transaction
{
$location_id = array_key_exists('location_id', $options) ? $options['location_id'] : null;
$currency = array_key_exists('currency', $options) ? $options['currency'] : 'USD';
$prepData = [
- Read upRead up
- Create a ticketCreate a ticket
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 buildTaxes
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function buildTaxes(Collection $taxes): array
{
$temp = [];
if ($taxes->isNotEmpty()) {
foreach ($taxes as $tax) {
- Read upRead up
- Create a ticketCreate a ticket
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 buildOrderCopyFromModel
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildOrderCopyFromModel(Model $order): stdClass
{
try {
$orderCopy = new stdClass();
// Create taxes Collection
- Create a ticketCreate a ticket
Method buildOrderCopyFromArray
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildOrderCopyFromArray(array $order): stdClass
{
try {
$orderCopy = new stdClass();
// Create taxes Collection
- Create a ticketCreate a ticket
Method buildDiscounts
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildDiscounts(Collection $discounts, string $currency): array
{
$temp = [];
if ($discounts->isNotEmpty()) {
foreach ($discounts as $discount) {
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($product->pivot->taxes->isNotEmpty()) {
$productTemp->taxes = $this->taxesBuilder->createTaxes($product->pivot->taxes->toArray(), Constants::DEDUCTIBLE_SCOPE_ORDER, $productTemp->productPivot);
// Check for any taxes that are missing on order level
$missingTaxes = $productTemp->taxes->reject(function ($tax) use ($orderCopy) {
- Read upRead up
- Create a ticketCreate a ticket
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 109.
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
if ($product->pivot->discounts->isNotEmpty()) {
$productTemp->discounts = $this->discountBuilder->createDiscounts($product->pivot->discounts->toArray(), Constants::DEDUCTIBLE_SCOPE_PRODUCT, $productTemp->pivot);
// Check for any discounts that are missing on order level
$missingDiscounts = $productTemp->discounts->reject(function ($discount) use ($orderCopy) {
- Read upRead up
- Create a ticketCreate a ticket
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 109.
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 addProductFromArray
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addProductFromArray(stdClass $orderCopy, Model $order, array $product, int $quantity): Product|stdClass
{
try {
// Get quantity
$tempQuantity = null;
- Create a ticketCreate a ticket
Method createDiscounts
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createDiscounts(array $discounts, string $scope, Model $parent = null): Collection
{
$temp = collect([]);
foreach ($discounts as $discount) {
//If discount doesn't have amount AND percentage in discounts table
- Create a ticketCreate a ticket