EscolaLMS/Courses

View on GitHub

Showing 67 of 67 total issues

Function attend has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function attend(?User $user, Course $course): bool
    {
        if ($course->public && $course->is_published) {
            return true;
        }
Severity: Minor
Found in src/Policies/CoursesPolicy.php - About 25 mins to fix

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 isActive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function isActive(): bool
    {
        if (!$this->active ||
            ($this->active_from && $this->active_from >= Carbon::now()) ||
            ($this->active_to && $this->active_to <= Carbon::now())
Severity: Minor
Found in src/Models/Lesson.php - About 25 mins to fix

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 createTopicContentModelFromRequest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function createTopicContentModelFromRequest(FormRequest $request, Topic $topic): Model
    {
        $class = $request->input('topicable_type');

        if (!in_array($class, $this->contentClasses)) {
Severity: Minor
Found in src/Repositories/TopicRepository.php - About 25 mins to fix

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 ping has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function ping(User $user, Topic $topic): CourseProgressCollection
    {
        $course = $topic->course;

        $courseProgressCollection = CourseProgressCollection::make($user, $course);
Severity: Minor
Found in src/Services/ProgressService.php - About 25 mins to fix

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 sort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function sort($class, $orders): void
    {
        if ($class === 'Lesson') {
            foreach ($orders as $order) {
                Lesson::findOrFail($order[0])->update(['order' => $order[1]]);
Severity: Minor
Found in src/Services/CourseService.php - About 25 mins to fix

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 deleteModel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function deleteModel(Topic $topic): ?bool
    {
        if ($topic->delete()) {
            $topicable = $topic->topicable;
            if (is_a($topicable, AbstractTopicFileContent::class)) {
Severity: Minor
Found in src/Repositories/TopicRepository.php - About 25 mins to fix

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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function create(array $input): Model
    {
        /** @var Course $model */
        $model = $this->model->newInstance($input);

Severity: Minor
Found in src/Repositories/CourseRepository.php - About 25 mins to fix

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

Severity
Category
Status
Source
Language