Showing 48 of 67 total issues
Course
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class Course extends Model
{
use HasFactory;
use QueryCacheable;
File Course.php
has 275 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace EscolaLms\Courses\Models;
use EscolaLms\Categories\Models\Category;
Function run
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function run()
{
if (Course::count() === 0) {
$this->call(CoursesSeeder::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
CourseProgressCollection
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class CourseProgressCollection extends ValueObject implements ValueObjectContract, CourseProgressCollectionContract
{
public const FORGET_TRACKING_SESSION_AFTER_MINUTES = 60;
private CourseProgressRepositoryContract $courseProgressRepositoryContract;
File CourseRepository.php
has 265 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace EscolaLms\Courses\Repositories;
use EscolaLms\Categories\Models\Category;
Method allQueryBuilder
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function allQueryBuilder(array $search = [], array $criteria = []): Builder
{
/** search main category and all subcategories */
if (isset($search['category_id'])) {
$collection = Category::where('id', $search['category_id'])->with('children')->get();
Method update
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function update(array $input, int $id): Model
{
$query = $this->model->newQuery();
/** @var Course $model */
Method getCoursesListWithOrdering
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getCoursesListWithOrdering(OrderDto $orderDto, array $search = []): Builder
{
$criteria = $this->prepareCriteria($orderDto);
if (isset($search['title'])) {
Method toArray
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toArray($request)
{
$fields = [
'id' => $this->resource->id,
'created_at' => $this->resource->created_at,
Function update
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function update(Course $course, User $user, array $progress): CourseProgressCollection
{
$courseProgressCollection = CourseProgressCollection::make($user, $course);
if ($courseProgressCollection->courseCanBeProgressed()) {
- 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 toArray
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toArray($request)
{
$fields = [
'id' => $this->resource->id,
'created_at' => $this->resource->created_at,
Method toArray
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toArray($request)
{
$this->withoutWrapping();
if ($this->resource instanceof Course) {
Method toArray
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toArray($request): array
{
$this->withoutWrapping();
$course = $this->getResource();
Method run
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run()
{
if (Course::count() === 0) {
$this->call(CoursesSeeder::class);
}
Method toArray
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toArray($request): array
{
$this->withoutWrapping();
$course = $this->getResource();
Function update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function update(array $input, int $id): Model
{
$query = $this->model->newQuery();
/** @var Course $model */
- 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 allQueryBuilder
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function allQueryBuilder(array $search = [], array $criteria = []): Builder
{
/** search main category and all subcategories */
if (isset($search['category_id'])) {
$collection = Category::where('id', $search['category_id'])->with('children')->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
Method updateInTopic
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateInTopic(Topic $topic, Authenticatable $user, int $status, ?int $seconds = null, ?bool $newAttempt = false): void
{
$update = ['status' => $status];
if (!is_null($seconds)) {
Method run
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run()
{
// create permissions
$admin = Role::findOrCreate(UserRole::ADMIN, 'api');
$tutor = Role::findOrCreate(UserRole::TUTOR, 'api');
Function cloneTopic
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function cloneTopic(Topic $topic): Model
{
$clonedTopicArray = $topic->replicate()->toArray();
unset($clonedTopicArray['order']);
/** @var Topic $clonedTopic */
- 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"