freakimkaefig/Music-XML-Analyzer

View on GitHub
app/controllers/SearchController.php

Summary

Maintainability
F
1 wk
Test Coverage

File SearchController.php has 623 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Controller for analysis of uploads
 *
Severity: Major
Found in app/controllers/SearchController.php - About 1 day to fix

    Function _countIntervals has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

        private function _countIntervals($xml){
            $tonika = array("C" => 0,
                            "D" => 2,
                            "E" => 4,
                            "F" => 5,
    Severity: Minor
    Found in app/controllers/SearchController.php - About 7 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 _countIntervals has 173 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function _countIntervals($xml){
            $tonika = array("C" => 0,
                            "D" => 2,
                            "E" => 4,
                            "F" => 5,
    Severity: Major
    Found in app/controllers/SearchController.php - About 6 hrs to fix

      Function _determineKey has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          private function _determineKey($xml){
              $keys = $xml->xpath("//key");
              $keysArray = array(
                  (object)array("label" => "C major", "value" => 0 ),
                  (object)array("label" => "G major", "value" => 0 ),
      Severity: Minor
      Found in app/controllers/SearchController.php - About 5 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 _determineKey has 140 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function _determineKey($xml){
              $keys = $xml->xpath("//key");
              $keysArray = array(
                  (object)array("label" => "C major", "value" => 0 ),
                  (object)array("label" => "G major", "value" => 0 ),
      Severity: Major
      Found in app/controllers/SearchController.php - About 5 hrs to fix

        Function _countNoteValues has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

            private function _countNoteValues($xml){
                $notes = $xml->xpath("//note");
        
                $notesArray = array(
                    (object)array("label" => "B", "value" => 0 ),
        Severity: Minor
        Found in app/controllers/SearchController.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 _countNoteValues has 98 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function _countNoteValues($xml){
                $notes = $xml->xpath("//note");
        
                $notesArray = array(
                    (object)array("label" => "B", "value" => 0 ),
        Severity: Major
        Found in app/controllers/SearchController.php - About 3 hrs to fix

          Method _determineClef has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function _determineClef($xml){
                  $clefs = $xml->xpath("//clef");
          
                  $clefsArray = array(
                      (object)array("label" => "soprano clef", "value" => 0 ),
          Severity: Major
          Found in app/controllers/SearchController.php - About 2 hrs to fix

            Function _determineClef has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                private function _determineClef($xml){
                    $clefs = $xml->xpath("//clef");
            
                    $clefsArray = array(
                        (object)array("label" => "soprano clef", "value" => 0 ),
            Severity: Minor
            Found in app/controllers/SearchController.php - About 2 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 _countNoteTypes has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function _countNoteTypes($xml){
                    $notes = $xml->xpath("//note");
            
                    $noteTypesArray = array(
                        (object)array("label" => "whole", "value" => 0 ),
            Severity: Minor
            Found in app/controllers/SearchController.php - About 1 hr to fix

              Function _countNoteTypes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function _countNoteTypes($xml){
                      $notes = $xml->xpath("//note");
              
                      $noteTypesArray = array(
                          (object)array("label" => "whole", "value" => 0 ),
              Severity: Minor
              Found in app/controllers/SearchController.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 search has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function search()
                  {
                      // Getting files for current user
                      $user = User::find(Cookie::get('user_id'));
                      $user->uploads->each(function($upload) {
              Severity: Minor
              Found in app/controllers/SearchController.php - About 1 hr to fix

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

                    private function _determineInstruments($xml){
                        $instruments = $xml->xpath("//score-part");
                        $instrumentsArray = array();
                
                        foreach($instruments as $instrument){
                Severity: Minor
                Found in app/controllers/SearchController.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

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

                            if($fifths != null && $mode === "major"){
                                switch($fifths):
                                    case "0":
                                        $keysArray[0]->value = $keysArray[0]->value + 1;
                                        break;
                Severity: Major
                Found in app/controllers/SearchController.php and 1 other location - About 2 days to fix
                app/controllers/SearchController.php on lines 482..530

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

                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

                            elseif($fifths != null && $mode === "minor"){
                                switch($fifths):
                                    case "0":
                                        $keysArray[15]->value = $keysArray[15]->value + 1;
                                        break;
                Severity: Major
                Found in app/controllers/SearchController.php and 1 other location - About 2 days to fix
                app/controllers/SearchController.php on lines 432..533

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

                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