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();
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)
- 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 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();
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)
Method testGpsPostSuccessDataIsCompressed
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testGpsPostSuccessDataIsCompressed()
{
$company = factory('App\Company')->create();
$this->actingAs($company)
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create(Request $request)
{
$gpsData = $request->all();
if (!empty($gpsData)) {
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'])) {
- 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 create
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function create(Request $request)
{
$gpsData = $request->all();
if (!empty($gpsData)) {
- 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 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();
Avoid deeply nested control flow statements. Open
if (!empty($part->part_id)) {
PartEntry::forceCreate([
"part_id" => $part->part_id,
"entry_id" => $entry->id,
]);
Method sendAlertTireMail
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function sendAlertTireMail($company, $vehicle_id, $tireSensor, $ideal_pressure, $users)
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();
- 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"