Skip to content

Commit

Permalink
refactor: fix sonar issues (#5837)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Jan 7, 2022
1 parent a3e9b79 commit 57b31f6
Show file tree
Hide file tree
Showing 63 changed files with 213 additions and 269 deletions.
1 change: 0 additions & 1 deletion app/Helpers/CountriesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\App;
//use PragmaRX\Countries\Package\Support\Collection;
use PragmaRX\CountriesLaravel\Package\Facade as Countries;
use PragmaRX\Countries\Package\Support\Collection as Country;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,6 @@ public function updateOrCreateCalendarObject($calendarId, $objectUri, $calendarD

public function deleteCalendarObject($objectUri)
{
// Not implemented
}
}
6 changes: 2 additions & 4 deletions app/Http/Middleware/CheckCompliance.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ public function handle($request, Closure $next)
return $next($request);
}

if (Auth::check()) {
if (! ComplianceHelper::isCompliantWithCurrentTerm(auth()->user())) {
return redirect()->route('compliance');
}
if (Auth::check() && ! ComplianceHelper::isCompliantWithCurrentTerm(auth()->user())) {
return redirect()->route('compliance');
}

return $next($request);
Expand Down
6 changes: 3 additions & 3 deletions app/Jobs/Dav/UpdateVCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ private function updateCard($addressBookId, $cardUri, $cardData): ?string

$contact_id = null;
if ($cardUri) {
$contact = $backend->getObject($addressBookId, $cardUri);
$contactObject = $backend->getObject($addressBookId, $cardUri);

if ($contact) {
$contact_id = $contact->id;
if ($contactObject) {
$contact_id = $contactObject->id;
}
}

Expand Down
13 changes: 4 additions & 9 deletions database/factories/SettingsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@
});

$factory->define(\Laravel\Cashier\Subscription::class, function (Faker\Generator $faker) {
static $account_id;
static $stripe_plan;
static $name;
static $stripe_id;

return [
'account_id' => $account_id,
'name' => $name ?: $faker->randomElement(['main']),
'stripe_id' => $stripe_id,
'stripe_plan' => $stripe_plan ?: $faker->randomElement(['plan-1', 'plan-2', 'plan-3']),
'account_id' => factory(App\Models\Account\Account::class)->create()->id,
'name' => $faker->word(),
'stripe_id' => $faker->word(),
'stripe_plan' => $faker->randomElement(['plan-1', 'plan-2', 'plan-3']),
'quantity' => 1,
'created_at' => now(),
];
Expand Down
19 changes: 0 additions & 19 deletions database/migrations/2016_10_24_014257_create_journal_tables.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateJournalTables extends Migration
Expand All @@ -14,23 +13,5 @@ class CreateJournalTables extends Migration
public function up()
{
Schema::dropIfExists('gifts');

// Schema::create('journal', function (Blueprint $table) {
// $table->increments('id');
// $table->integer('account_id');
// $table->longText('entry');
// $table->softDeletes();
// $table->timestamps();
// });
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
18 changes: 0 additions & 18 deletions database/migrations/2017_01_26_022852_change_notes_to_contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,4 @@ public function up()
$table->integer('contact_id')->after('account_id');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('notes', function (Blueprint $table) {
$table->dropColumn(
'people_id'
);
});

Schema::table('notes', function (Blueprint $table) {
$table->integer('contact_id')->after('account_id');
});
}
}
52 changes: 25 additions & 27 deletions resources/js/components/dashboard/DashboardLog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@

<div class="pa3 bb b--gray-monica tc">
<ul>
<li :class="[activeTab == 'calls' ? 'di pointer mr3 b' : 'di pointer mr3 black-50']" @click.prevent="setActiveTab('calls')">
<li :class="[activeTab === 'calls' ? 'di pointer mr3 b' : 'di pointer mr3 black-50']" @click.prevent="setActiveTab('calls')">
{{ $t('dashboard.tab_recent_calls') }}
</li>
<li :class="[activeTab == 'notes' ? 'di pointer mr3 b' : 'di pointer mr3 black-50']" @click.prevent="setActiveTab('notes')">
<li :class="[activeTab === 'notes' ? 'di pointer mr3 b' : 'di pointer mr3 black-50']" @click.prevent="setActiveTab('notes')">
{{ $t('dashboard.tab_favorite_notes') }}
</li>
<li :class="[activeTab == 'debts' ? 'di pointer mr3 b' : 'di pointer mr3 black-50']" @click.prevent="setActiveTab('debts')">
<li :class="[activeTab === 'debts' ? 'di pointer mr3 b' : 'di pointer mr3 black-50']" @click.prevent="setActiveTab('debts')">
{{ $t('dashboard.tab_debts') }}
</li>
<li :class="[activeTab == 'tasks' ? 'di pointer mr3 b' : 'di pointer mr3 black-50']" @click.prevent="setActiveTab('tasks')">
<li :class="[activeTab === 'tasks' ? 'di pointer mr3 b' : 'di pointer mr3 black-50']" @click.prevent="setActiveTab('tasks')">
{{ $t('dashboard.tab_tasks') }}
</li>
</ul>
</div>
<div class="pa4">
<!-- Calls -->
<div v-if="activeTab == 'calls'">
<ul v-if="calls.length != 0">
<div v-if="activeTab === 'calls'">
<ul v-if="calls.length !== 0">
<li v-for="call in calls" :key="call.id" class="pb2">
<svg id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px"
y="0px" viewBox="0 0 473.806 473.806" style="enable-background:new 0 0 473.806 473.806;" xml:space="preserve" width="15px"
Expand Down Expand Up @@ -54,8 +54,8 @@
</div>

<!-- Notes -->
<div v-else-if="activeTab == 'notes'">
<template v-if="notes.length != 0">
<div v-else-if="activeTab === 'notes'">
<template v-if="notes.length !== 0">
<div v-for="note in notes" :key="note.id" class="pb3 cf">
<div class="fl w-10">
<avatar :contact="note.contact" :clickable="true" />
Expand Down Expand Up @@ -113,8 +113,8 @@
</div>

<!-- Debts -->
<div v-else-if="activeTab == 'debts'">
<ul v-if="debts.length != 0">
<div v-else-if="activeTab === 'debts'">
<ul v-if="debts.length !== 0">
<li v-for="debt in debts" :key="debt.id" class="pb2">
<span class="black-50 mr1 f6">
{{ debt.created_at | formatDate }}
Expand All @@ -129,7 +129,7 @@
</span>
{{ debt.amount_with_currency }}
<span v-if="debt.in_debt == 'yes'" class="black-50 f6">
<span v-if="debt.in_debt === 'yes'" class="black-50 f6">
<span class="mr1 black-50">
</span>
Expand All @@ -145,15 +145,15 @@
</div>

<!-- Tasks -->
<div v-if="activeTab == 'tasks'">
<div v-if="activeTab === 'tasks'">
<ul class="tc mb3">
<li class="di mr4">
<span :class="[contactRelatedTasksView == true ? 'b' : 'pointer']" @click.prevent="contactRelatedTasksView = true">
<span :class="[contactRelatedTasksView === true ? 'b' : 'pointer']" @click.prevent="contactRelatedTasksView = true">
{{ $t('dashboard.tasks_tab_your_contacts') }} ({{ contactRelated(tasks).length }})
</span>
</li>
<li class="di">
<span :class="[contactRelatedTasksView == true ? 'pointer' : 'b']" @click.prevent="contactRelatedTasksView = false">
<span :class="[contactRelatedTasksView === true ? 'pointer' : 'b']" @click.prevent="contactRelatedTasksView = false">
{{ $t('dashboard.tasks_tab_your_tasks') }} ({{ customNotCompleted(tasks).length }})
</span>
</li>
Expand All @@ -176,7 +176,7 @@
</div>

<!-- Tasks: list of contact related tasks -->
<div v-if="contactRelated(tasks).length != 0 && contactRelatedTasksView">
<div v-if="contactRelated(tasks).length !== 0 && contactRelatedTasksView">
<ul>
<li v-for="task in contactRelated(tasks)" :key="task.id" class="pb0 mb2">
<form-checkbox
Expand All @@ -199,7 +199,7 @@
<!-- Tasks: list of non contact related tasks -->
<div v-if="!contactRelatedTasksView">
<!-- Your tasks: Blank state -->
<div v-if="customNotCompleted(tasks).length == 0" class="tc mt4 mb4">
<div v-if="customNotCompleted(tasks).length === 0" class="tc mt4 mb4">
<p class="mb4">
<a v-show="!taskAddMode" class="btn pointer" href="" @click.prevent="taskAddMode = true">
{{ $t('dashboard.task_add_cta') }}
Expand All @@ -209,14 +209,14 @@
</div>

<!-- Add a task -->
<p v-if="customNotCompleted(tasks).length != 0">
<p v-if="customNotCompleted(tasks).length !== 0">
<a v-show="!taskAddMode" class="pointer" href="" @click.prevent="taskAddMode = true">
{{ $t('dashboard.task_add_cta') }}
</a>
</p>

<!-- Actual list -->
<ul v-if="customNotCompleted(tasks).length != 0">
<ul v-if="customNotCompleted(tasks).length !== 0">
<li v-for="task in customNotCompleted(tasks)" :key="task.id" class="pb0 mb2" @mouseover="showTaskAction = task.id" @mouseleave="showTaskAction = 0; confirmDestroyTask = 0">
<form-checkbox
v-model.lazy="task.completed"
Expand All @@ -226,10 +226,10 @@
>
{{ task.title }}
</form-checkbox>
<a v-show="showTaskAction == task.id" class="pointer mr1" href="" @click.prevent="confirmDestroyTask = task.id">
<a v-show="showTaskAction === task.id" class="pointer mr1" href="" @click.prevent="confirmDestroyTask = task.id">
{{ $t('app.delete') }}
</a>
<ul v-show="confirmDestroyTask == task.id" class="di">
<ul v-show="confirmDestroyTask === task.id" class="di">
<li class="di">
<a class="pointer mr1" href="" @click.prevent="confirmDestroyTask = 0">
{{ $t('app.cancel') }}
Expand All @@ -244,7 +244,7 @@
</li>
</ul>

<ul v-if="customCompleted(tasks).length != 0 && !contactRelatedTasksView">
<ul v-if="customCompleted(tasks).length !== 0 && !contactRelatedTasksView">
<li v-for="task in customCompleted(tasks)" :key="task.id" class="pb0 mb0 f6" @mouseover="showTaskAction = task.id" @mouseleave="showTaskAction = 0; confirmDestroyTask = 0">
<form-checkbox
v-model.lazy="task.completed"
Expand All @@ -254,10 +254,10 @@
>
{{ task.title }}
</form-checkbox>
<a v-show="showTaskAction == task.id" class="pointer mr1" href="" @click.prevent="confirmDestroyTask = task.id">
<a v-show="showTaskAction === task.id" class="pointer mr1" href="" @click.prevent="confirmDestroyTask = task.id">
{{ $t('app.delete') }}
</a>
<ul v-show="confirmDestroyTask == task.id" class="di">
<ul v-show="confirmDestroyTask === task.id" class="di">
<li class="di">
<a class="pointer mr1" href="" @click.prevent="confirmDestroyTask = 0">
{{ $t('app.cancel') }}
Expand Down Expand Up @@ -365,9 +365,7 @@ export default {
},
saveTab(view) {
axios.post('dashboard/setTab', {'tab':view})
.then(response => {
});
axios.post('dashboard/setTab', {'tab':view});
},
getCalls() {
Expand Down Expand Up @@ -415,7 +413,7 @@ export default {
// All the contact related tasks
contactRelated: function (tasks) {
return tasks.filter(function (task) {
return task.contact != null && !task.completed;
return task.contact !== null && !task.completed;
});
},
Expand Down
10 changes: 5 additions & 5 deletions resources/js/components/journal/JournalList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<!-- Logs -->
<div v-if="journalEntries.data" v-cy-name="'journal-entries-body'" v-cy-items="journalEntries.data.map(j => j.id)" :cy-object-items="journalEntries.data.map(j => j.object.id)">
<div v-for="journalEntry in journalEntries.data" :key="journalEntry.id" v-cy-name="'entry-body-' + journalEntry.id" class="cf">
<journal-content-rate v-if="journalEntry.journalable_type == 'App\\Models\\Journal\\Day'" :journal-entry="journalEntry" @deleteJournalEntry="deleteJournalEntry" />
<journal-content-rate v-if="journalEntry.journalable_type === 'App\\Models\\Journal\\Day'" :journal-entry="journalEntry" @deleteJournalEntry="deleteJournalEntry" />

<journal-content-activity v-else-if="journalEntry.journalable_type == 'App\\Models\\Account\\Activity'" :journal-entry="journalEntry" />
<journal-content-activity v-else-if="journalEntry.journalable_type === 'App\\Models\\Account\\Activity'" :journal-entry="journalEntry" />

<journal-content-entry v-else-if="journalEntry.journalable_type == 'App\\Models\\Journal\\Entry'" :journal-entry="journalEntry" @deleteJournalEntry="deleteJournalEntry" />
<journal-content-entry v-else-if="journalEntry.journalable_type === 'App\\Models\\Journal\\Entry'" :journal-entry="journalEntry" @deleteJournalEntry="deleteJournalEntry" />
</div>
</div>

Expand Down Expand Up @@ -74,7 +74,7 @@ export default {
computed: {
dirltr() {
return this.$root.htmldir == 'ltr';
return this.$root.htmldir === 'ltr';
},
hasMorePage: function() {
var total = this.journalEntries.per_page * this.journalEntries.current_page;
Expand Down Expand Up @@ -115,7 +115,7 @@ export default {
// the user does all his actions on the same page without ever
// reloading the page.
this.journalEntries.data.filter(function(obj) {
return obj.id == $journalEntryId;
return obj.id === $journalEntryId;
});
// Filter out the array without the deleted Journal Entry
Expand Down
Loading

0 comments on commit 57b31f6

Please sign in to comment.