alientronics/fleetany-api

View on GitHub

Showing 12 of 235 total issues

Method sendAlertTireMail has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function sendAlertTireMail($company, $vehicle_id, $tireSensor, $ideal_pressure, $users)
    {
        try {
            $vehicle = Vehicle::where('id', $vehicle_id)->first();
    
Severity: Major
Found in app/Http/Controllers/AlertController.php - About 2 hrs to fix

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

        private function generateEntry($company, $tireSensor, $ideal_pressure)
        {
            if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
                $tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
                    ->where('created_at', '<', $tireSensor->created_at)
    Severity: Minor
    Found in app/Http/Controllers/TireConditionController.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 getPart has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getPart($user, $json, $inputs)
        {
            $part = Part::select('id')->where('number', $json['id'])
                ->where('company_id', $user->company_id)
                ->first();
    Severity: Minor
    Found in app/Http/Controllers/TireSensorController.php - About 1 hr to fix

      Method generateEntry has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function generateEntry($company, $tireSensor, $ideal_pressure)
          {
              if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
                  $tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
                      ->where('created_at', '<', $tireSensor->created_at)
      Severity: Minor
      Found in app/Http/Controllers/TireConditionController.php - About 1 hr to fix

        Method testGpsPostSuccessDataIsCompressed has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function testGpsPostSuccessDataIsCompressed()
            {
                $company = factory('App\Company')->create();
        
                $this->actingAs($company)
        Severity: Minor
        Found in tests/GpsTest.php - About 1 hr to fix

          Method create has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function create(Request $request)
              {
                  $gpsData = $request->all();
                  
                  if (!empty($gpsData)) {
          Severity: Minor
          Found in app/Http/Controllers/GpsController.php - About 1 hr to fix

            Function create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function create(Request $request)
                {
                    $inputs = $request->all();
                        
                    if (!empty($inputs['json'])) {
            Severity: Minor
            Found in app/Http/Controllers/TireSensorController.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

            Function create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function create(Request $request)
                {
                    $gpsData = $request->all();
                    
                    if (!empty($gpsData)) {
            Severity: Minor
            Found in app/Http/Controllers/GpsController.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 create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function create(Request $request)
                {
                    try {
                        $inputs = $request->all();
                        $user = User::where('email', $inputs['email'])->first();
            Severity: Minor
            Found in app/Http/Controllers/TripController.php - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (!empty($part->part_id)) {
                                          PartEntry::forceCreate([
                                              "part_id" => $part->part_id,
                                              "entry_id" => $entry->id,
                                          ]);
              Severity: Major
              Found in app/Http/Controllers/TireConditionController.php - About 45 mins to fix

                Method sendAlertTireMail has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function sendAlertTireMail($company, $vehicle_id, $tireSensor, $ideal_pressure, $users)
                Severity: Minor
                Found in app/Http/Controllers/AlertController.php - About 35 mins to fix

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

                      public function sendAlertTireMail($company, $vehicle_id, $tireSensor, $ideal_pressure, $users)
                      {
                          try {
                              $vehicle = Vehicle::where('id', $vehicle_id)->first();
                      
                  Severity: Minor
                  Found in app/Http/Controllers/AlertController.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