Showing 390 of 390 total issues
Avoid assigning values to variables in if clauses and the like (line '59', column '13'). Open
protected function loadSessionPreferences(User $user)
{
logger()->info("Loading user preferences");
if ($timezone = $user->pref('timezone')) {
session()->set('timezone', $timezone);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '27', column '13'). Open
public function getHome($slug)
{
logger()->info(__METHOD__);
logger()->info(sprintf('slug:%s', $slug));
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\Illuminate\Support\Facades\Storage' in method 'recallStatements'. Open
if (!Storage::exists($this->getStatementsFile($businessId))) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method getAvailability uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if (!$contact = auth()->user()->getContactSubscribedTo($business->id)) {
logger()->info(' [ADVICE] User not subscribed to Business');
flash()->warning(trans('user.booking.msg.you_are_not_subscribed_to_business'));
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\Carbon\Carbon' in method 'touchAudit'. Open
$user->last_login_at = Carbon::now();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Facades\Storage' in method 'processBusiness'. Open
Storage::delete("business/{$business->id}/ical/ical-exclusion.compiled");
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Timegridio\Concierge\Models\Business' in method 'getTimes'. Open
$business = Business::findOrFail($businessId);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Timegridio\Concierge\Models\Business' in method 'getDates'. Open
$business = Business::findOrFail($businessId);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Timegridio\Concierge\Models\Business' in method 'postStore'. Open
$business = Business::findOrFail($request->input('businessId'));
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Facades\Cache' in method 'getActiveAppointments'. Open
return Cache::get('user-{auth()->id()}-active-appointments', function () {
return auth()->user()->appointments()->active()->get();
});
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Timegridio\Concierge\Models\Appointment' in method 'postAction'. Open
$appointment = Appointment::findOrFail($request->input('appointment'));
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method postStore uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$contact = $this->getContact($business, $email);
if (!$contact) {
logger()->info('[ADVICE] Not subscribed');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\Request' in method 'store'. Open
$contact = $business->addressbook()->register(Request::all());
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '57', column '14'). Open
protected function sendEmailToContactUser($event)
{
if (!$user = $event->appointment->contact->user) {
return false;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Line exceeds 120 characters; contains 144 characters Open
$this->counter['appointments_active_tomorrow'] = $this->business->bookings()->active()->ofDate($this->time->tomorrow())->get()->count();
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
'instructions' => 'Enter the appointments capacity for each service on each day day. This is, how may appointments can you handle per service per day?',
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
'out_of_vacancies' => 'Publish your availability<br><br>For clients to begin taking reservations you need to publish your availability.',
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
'hello-paragraph' => 'Timegrid helps contractors and customers to find the perfect meeting time through online appointments.',
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 154 characters Open
'hello-paragraph' => 'You made a guest reservation which needs your validation. In case you don\'t confirm, it will automatically expire.',
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
'content' => 'Welcome to your dashboard. Here you will have a quick insights view about the reservations of your business',
- Create a ticketCreate a ticket
- Exclude checks