Showing 494 of 494 total issues
Function readProductQuantity
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function readProductQuantity($product, $field, $friends_bookings)
{
$combo = null;
if (is_a($product, VariantCombo::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
Similar blocks of code found in 2 locations. Consider refactoring. Open
static detachUserRole(role_id, user_id, target_id, target_class) {
utils.postAjax({
method: 'POST',
url: 'roles/detach',
data: {
- 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 60.
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 retrievePreSelectedFields
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function retrievePreSelectedFields($parameters)
{
$selected = [];
if (isset($parameters['sorted_fields']) && empty($parameters['sorted_fields']) == false) {
- 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
static attachUserRole(role_id, user_id, target_id, target_class) {
utils.postAjax({
method: 'POST',
url: 'roles/attach',
data: {
- 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 60.
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 init
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
static init(container)
{
/*
Questo mostra/nasconde il trigger addizionale per modificare in
blocco l'ordinabilità dei prodotti, nella griglia della modifica
Method ensureAuth
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function ensureAuth($permissions = [], $or = true)
{
$user = Auth::user();
if (is_null($user)) {
Method sumUpProducts
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function sumUpProducts($booking, &$datarow)
{
/*
TODO: Nel caso di prenotazioni salvate sarebbe molto più efficiente
cambiare semplicemente lo stato della prenotazione stessa, giacché
Method create
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create(Request $request)
{
$type = $request->input('type', null);
if (is_null($type)) {
return view('movement.create');
Method postStatusScaleway
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function postStatusScaleway(Request $request)
{
if (env('MAIL_MAILER') == 'scaleway') {
$api_endpoint = 'https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/webhooks';
Method movementTypes
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function movementTypes($identifier = null, $with_trashed = false)
{
static $types = null;
if ($identifier == 'VOID') {
Method fields
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fields()
{
$ret = [
'date' => (object) [
'label' => _i('Data'),
Method up
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function up()
{
/*
Questa migrazione serve solo per il profiler, va adoperata per lo
sviluppo locale e non serve eseguirla sulle istanze di produzione
Method readDefinition
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function readDefinition($modifier, $json)
{
$definitions = [];
if (isset($json->fixed)) {
Method commons
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function commons($user)
{
static $gas_count = null;
$ret = [
Function success
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
success: (data) => {
if (data.hasOwnProperty('status') && data.status == 'error') {
utils.displayServerError(null, data);
return;
}
Method queryMovements
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function queryMovements($query = null, $type = 'all')
{
if (is_null($query)) {
$query = Movement::orderBy('created_at', 'desc');
}
Method create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function create(array $data)
{
$gas = Gas::find($data['gas_id']);
$user = new User();
Method roleByFunction
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function roleByFunction($identifier)
{
$gas = currentAbsoluteGas();
$role_id = $gas->roles[$identifier] ?? null;
$ret = App\Role::find($role_id);
Method up
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function up()
{
Schema::create('invoices', function (Blueprint $table) {
$table->string('id')->primary();
$table->timestamps();
Method formatSummaryShipping
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function formatSummaryShipping($order, $fields, $status, $shipping_place, $extra_modifiers)
{
$rows = [];
$total = 0;
$formattable = OrderFormatter::formattableColumns('summary');