Bottaajat/cultura

View on GitHub
app/Http/Controllers/TaskController.php

Summary

Maintainability
F
1 wk
Test Coverage

File TaskController.php has 561 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
Severity: Major
Found in app/Http/Controllers/TaskController.php - About 1 day to fix

    Function edit_ordering_images has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        public function edit_ordering_images(Request $request, $task_id)
        {
            $task = Task::find($task_id);
            $destinationPath = public_path() . "/img/";
            $all_in = true;
    Severity: Minor
    Found in app/Http/Controllers/TaskController.php - About 4 hrs 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

    Method edit_ordering_images has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function edit_ordering_images(Request $request, $task_id)
        {
            $task = Task::find($task_id);
            $destinationPath = public_path() . "/img/";
            $all_in = true;
    Severity: Major
    Found in app/Http/Controllers/TaskController.php - About 3 hrs to fix

      Method edit_crossword has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function edit_crossword(Request $request, $task_id)
          {
              $task = Task::find($task_id);
      
              //HAE OBJEKTIT
      Severity: Major
      Found in app/Http/Controllers/TaskController.php - About 2 hrs to fix

        TaskController has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class TaskController extends Controller
        {
            public function __construct() {
                $this->middleware('auth', ['except' => ['index','show']]);
            }
        Severity: Minor
        Found in app/Http/Controllers/TaskController.php - About 2 hrs to fix

          Function show has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

            public function show($id) {
              if($task = Task::findOrFail($id)) {
                $videos = [];
                if(Auth::user() && Auth::user()->is_admin) {
                  $videos = Video::all();
          Severity: Minor
          Found in app/Http/Controllers/TaskController.php - About 1 hr 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

          Method edit_multipleChoice has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function edit_multipleChoice(Request $request, $task_id)
              {
                  $task = Task::find($task_id);
          
                  //HAE OBJEKTIT
          Severity: Minor
          Found in app/Http/Controllers/TaskController.php - About 1 hr to fix

            Method edit_ordering_words has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function edit_ordering_words(Request $request, $task_id)
                {
                    $task = Task::find($task_id);
            
                    //HAE SYÖTTEET
            Severity: Minor
            Found in app/Http/Controllers/TaskController.php - About 1 hr to fix

              Method store_ordering_images has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function store_ordering_images(Request $request, $task_id)
                  {
                      $destinationPath = public_path() . "/img/";
                      $count = 0;
                      $all_in = true;
              Severity: Minor
              Found in app/Http/Controllers/TaskController.php - About 1 hr to fix

                Method store_crossword has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function store_crossword(Request $request, $task_id)
                    {
                        $count = 0;
                        foreach ($request->input('words') as $word) {
                            $words[$count] = $word;
                Severity: Minor
                Found in app/Http/Controllers/TaskController.php - About 1 hr to fix

                  Method index has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public function index(Request $request) {
                      if (Auth::check())
                        $exercise_list = Exercise::when(Auth::user()->school != NULL, 
                            function ($query)  {
                              return $query->Where('school_id', '=', Auth::user()->school->id);
                  Severity: Minor
                  Found in app/Http/Controllers/TaskController.php - About 1 hr to fix

                    Function edit_ordering_words has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function edit_ordering_words(Request $request, $task_id)
                        {
                            $task = Task::find($task_id);
                    
                            //HAE SYÖTTEET
                    Severity: Minor
                    Found in app/Http/Controllers/TaskController.php - About 55 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 edit_crossword has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function edit_crossword(Request $request, $task_id)
                        {
                            $task = Task::find($task_id);
                    
                            //HAE OBJEKTIT
                    Severity: Minor
                    Found in app/Http/Controllers/TaskController.php - About 55 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 edit_multipleChoice has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function edit_multipleChoice(Request $request, $task_id)
                        {
                            $task = Task::find($task_id);
                    
                            //HAE OBJEKTIT
                    Severity: Minor
                    Found in app/Http/Controllers/TaskController.php - About 55 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 store has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function store(Request $request)
                        {
                            $exercise = Exercise::findorFail($request->input('exercise_id'));
                    
                            if(!Auth::user()->is_admin && $exercise->school == null)
                    Severity: Minor
                    Found in app/Http/Controllers/TaskController.php - About 45 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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function update(Request $request, $id)
                        {
                          $task = Task::find($id);
                    
                          if(!Auth::user()->is_admin && $task->exercise->school == NULL)
                    Severity: Minor
                    Found in app/Http/Controllers/TaskController.php - About 45 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 store_ordering_images has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function store_ordering_images(Request $request, $task_id)
                        {
                            $destinationPath = public_path() . "/img/";
                            $count = 0;
                            $all_in = true;
                    Severity: Minor
                    Found in app/Http/Controllers/TaskController.php - About 35 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 addVideo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function addVideo(Request $request, $id) {
                          $task = Task::find($id);
                          if($task && Auth::user()->is_admin) {
                              $video = Video::find($request->input('video_id'));
                              if ($video) {
                    Severity: Minor
                    Found in app/Http/Controllers/TaskController.php - About 35 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

                    Avoid too many return statements within this method.
                    Open

                            return view('errors.404');
                    Severity: Major
                    Found in app/Http/Controllers/TaskController.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return view('errors.404');
                      Severity: Major
                      Found in app/Http/Controllers/TaskController.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                              return back()->withErrors('Et voi muuttaa tätä tehtävää!');
                        Severity: Major
                        Found in app/Http/Controllers/TaskController.php - About 30 mins to fix

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                              public function store_ordering_words(Request $request, $task_id)
                              {
                                  $count = 0;
                                  foreach ($request->input('droppable') as $droppable) {
                                      $droppables[$count] = $droppable;
                          Severity: Major
                          Found in app/Http/Controllers/TaskController.php and 1 other location - About 6 hrs to fix
                          app/Http/Controllers/TaskController.php on lines 209..235

                          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 215.

                          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

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                              public function store_multipleChoice(Request $request, $task_id)
                              {
                                  $count = 0;
                                  foreach ($request->input('questions') as $question) {
                                      $questions[$count] = $question;
                          Severity: Major
                          Found in app/Http/Controllers/TaskController.php and 1 other location - About 6 hrs to fix
                          app/Http/Controllers/TaskController.php on lines 135..161

                          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 215.

                          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

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  while ( $count < count($multiplechoices)) {
                                      if ( $count < count($questions) ) {
                                          $multipleChoice = $multiplechoices[$count];
                                          $multipleChoice->question = $questions[$count];
                                          $multipleChoice->choices = $choices[$count];
                          Severity: Major
                          Found in app/Http/Controllers/TaskController.php and 1 other location - About 2 hrs to fix
                          app/Http/Controllers/TaskController.php on lines 337..351

                          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 126.

                          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

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  while ( $ordering_count < count($orderings)) {
                                      if ( $ordering_count < count($droppables) ) {
                                          $ordering = $orderings[$ordering_count];
                                          $ordering->droppable = $droppables[$ordering_count];
                                          $ordering->draggable = $draggables[$ordering_count];
                          Severity: Major
                          Found in app/Http/Controllers/TaskController.php and 1 other location - About 2 hrs to fix
                          app/Http/Controllers/TaskController.php on lines 482..496

                          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 126.

                          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

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  while ($ordering_count < count($droppables)) {
                                      $ordering = new Ordering;
                                      $ordering->droppable = $droppables[$ordering_count];
                                      $ordering->draggable = $draggables[$ordering_count];
                                      $ordering->showable = $showables[$ordering_count];
                          Severity: Minor
                          Found in app/Http/Controllers/TaskController.php and 1 other location - About 50 mins to fix
                          app/Http/Controllers/TaskController.php on lines 497..506

                          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 97.

                          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

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                                  while ($count < count($questions)) {
                                      $multipleChoice = new multipleChoice;
                                      $multipleChoice->question = $questions[$count];
                                      $multipleChoice->choices = $choices[$count];
                                      $multipleChoice->solution = $solutions[$count];
                          Severity: Minor
                          Found in app/Http/Controllers/TaskController.php and 1 other location - About 50 mins to fix
                          app/Http/Controllers/TaskController.php on lines 352..361

                          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 97.

                          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

                          Further Reading

                          There are no issues that match your filters.

                          Category
                          Status