Showing 494 of 494 total issues
Function hasBrokenModifier
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function hasBrokenModifier()
{
if ($this->id == 'booking-payment') {
$types = Modifier::has('movementType')->pluck('movement_type_id')->unique();
$types = MovementType::whereIn('id', $types)->get();
- 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 organizeForProducts
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function organizeForProducts(&$products_modifiers, $target_modifiers, $key): void
{
foreach($target_modifiers as $pmod) {
if ($pmod->target_type == BookedProduct::class) {
$mod_id = $pmod->modifier->modifier_type_id;
- 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 readVariants
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readVariants($product, $booked, $values, $quantities, $delivering)
{
$param = $this->handlingParam($delivering);
$quantity = 0;
$saved_variants = [];
Method updateOrders
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateOrders(array $request)
{
$user = $this->ensureAuth(['supplier.orders' => null]);
$suppliers = array_keys($user->targetsByAction('supplier.orders'));
Function content
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
content: function() {
var ret = '<div>\
<div class="row mb-2"><label for="password" class="col-4 col-form-label">' + _('Nuova Password') + '</label><div class="col-8"><input type="password" class="form-control" name="password" value="" autocomplete="off" minlength="8"></div></div>\
<div class="row mb-2"><label for="password_confirm" class="col-4 col-form-label">' + _('Conferma Password') + '</label><div class="col-8"><input type="password" class="form-control" name="password_confirm" value="" autocomplete="off" minlength="8"></div></div>';
Method readGdxpFile
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readGdxpFile($path, $execute, $supplier_replace)
{
$working_dir = sys_get_temp_dir();
$data = [];
Method fastShipping
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fastShipping($deliverer, $aggregate, $users = null)
{
DB::beginTransaction();
$service = app()->make('BookingsService');
Method productByString
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function productByString($string, $products = null)
{
if (is_null($products)) {
$products = App\Product::all();
}
Method up
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function up()
{
Schema::create('orders', function (Blueprint $table) {
$table->string('id')->primary();
$table->timestamps();
Method roleInit
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function roleInit($gas)
{
$queue = systemParameters('Roles');
while(true) {
Method dynamicModifiers
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function dynamicModifiers(array $request, $aggregate, $target_user)
{
/*
Innanzitutto, qui sospendo l'esecuzione delle callback sui movimenti
contabili. Nella fase di revisione della prenotazione capita che i
Method initCollectionMacros
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function initCollectionMacros()
{
/*
Questa va usata solo per una Collection di BookedProductVariant,
come ad esempio la relazione variants() di BookedProduct
Method getSupplier
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getSupplier($start, $end, $type, $target, $supplier)
{
$data = [];
$categories = [];
Method closeBalance
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function closeBalance($request)
{
$this->ensureAuth(['movements.admin' => 'gas']);
$hub = App::make('MovementsHub');
Method distributionLabels
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function distributionLabels()
{
$currency = defaultCurrency()->symbol;
return [
Method columnsByType
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function columnsByType($ret, $type)
{
if ($type == 'export' || $type == 'all') {
$ret['last_login'] = (object) [
'name' => _i('Ultimo Accesso'),
Method iban_split
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function iban_split($iban, $field)
{
switch($field) {
case 'country':
$start = 0;
Method otherFields
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function otherFields(&$ret)
{
$ret['birthplace'] = (object) [
'label' => _i('Luogo di Nascita'),
];
Method up
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function up()
{
Schema::create('suppliers', function (Blueprint $table) {
$table->string('id')->primary();
$table->timestamps();
Similar blocks of code found in 2 locations. Consider refactoring. Open
var ret = $('<div>\
<div class="row mb-2">\
<label for="street" class="col-4 col-form-label">' + _('Indirizzo') + '</label>\
<div class="col-8"><input type="text" class="form-control" name="street" value="" autocomplete="off"></div>\
</div>\
- 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 61.
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