Skip to content

Commit 5b3c207

Browse files
Merge pull request #3751 from ColoredCow/feat/operation_module_code_clean
operation_module_code_clean
2 parents 73a3aed + db46c19 commit 5b3c207

File tree

213 files changed

+2994
-2957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+2994
-2957
lines changed

.github/workflows/coding-standards.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,26 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13+
1314
- name: Setup PHP v7.4
1415
uses: shivammathur/setup-php@v2
1516
with:
1617
php-version: "7.4"
18+
1719
- name: Install composer dependencies
1820
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
21+
1922
- name: Setup env file
2023
run: cp ./.env.example .env
24+
2125
- name: Configure application encryption key
2226
run: php artisan key:generate
27+
2328
- name: Install NPM Dependencies
2429
run: npm install
25-
- name: clear cache
30+
31+
- name: Clear cache
2632
run: php artisan cache:clear
33+
2734
- name: ColoredCowLaravelCI
28-
run: "php artisan check:ci --with-tty"
35+
run: php artisan check:ci --with-tty

.php-cs-fixer.php

+30-23
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use PhpCsFixer\Finder;
44

55
$rules = [
6+
'@PSR12' => true,
67
'array_syntax' => ['syntax' => 'short'],
78
'binary_operator_spaces' => [
89
'default' => 'single_space',
@@ -13,77 +14,82 @@
1314
'blank_line_before_statement' => [
1415
'statements' => ['return'],
1516
],
16-
'braces' => true,
1717
'cast_spaces' => true,
18-
'class_definition' => true,
1918
'class_attributes_separation' => [
2019
'elements' => [
2120
'trait_import' => 'none',
2221
],
2322
],
23+
'class_definition' => true,
2424
'concat_space' => [
2525
'spacing' => 'one',
2626
],
27+
'control_structure_braces' => true,
28+
'control_structure_continuation_position' => true,
2729
'declare_equal_normalize' => true,
30+
'declare_parentheses' => true,
2831
'elseif' => true,
2932
'encoding' => true,
3033
'full_opening_tag' => true,
31-
'fully_qualified_strict_types' => true,
34+
'fully_qualified_strict_types' => false,
3235
'function_declaration' => true,
33-
'function_typehint_space' => true,
3436
'heredoc_to_nowdoc' => true,
3537
'include' => true,
3638
'increment_style' => ['style' => 'post'],
3739
'indentation_type' => true,
38-
'linebreak_after_opening_tag' => true,
3940
'line_ending' => true,
41+
'linebreak_after_opening_tag' => true,
4042
'lowercase_cast' => true,
4143
'lowercase_keywords' => true,
4244
'lowercase_static_reference' => true,
43-
'magic_method_casing' => true,
4445
'magic_constant_casing' => true,
46+
'magic_method_casing' => true,
4547
'method_argument_space' => true,
48+
'multiline_whitespace_before_semicolons' => [
49+
'strategy' => 'no_multi_line',
50+
],
4651
'native_function_casing' => true,
4752
'no_alias_functions' => true,
48-
'no_extra_blank_lines' => [
49-
'tokens' => [
50-
'extra',
51-
'throw',
52-
'use',
53-
],
54-
],
5553
'no_blank_lines_after_class_opening' => true,
5654
'no_blank_lines_after_phpdoc' => true,
5755
'no_closing_tag' => true,
5856
'no_empty_phpdoc' => true,
5957
'no_empty_statement' => true,
58+
'no_extra_blank_lines' => [
59+
'tokens' => [
60+
'curly_brace_block',
61+
],
62+
],
6063
'no_leading_import_slash' => true,
6164
'no_leading_namespace_whitespace' => true,
6265
'no_mixed_echo_print' => [
6366
'use' => 'echo',
6467
],
65-
'no_multiline_whitespace_around_double_arrow' => true,
66-
'multiline_whitespace_before_semicolons' => [
67-
'strategy' => 'no_multi_line',
68-
],
68+
'no_multiple_statements_per_line' => true,
6969
'no_short_bool_cast' => true,
7070
'no_singleline_whitespace_before_semicolons' => true,
7171
'no_spaces_after_function_name' => true,
7272
'no_spaces_around_offset' => true,
73-
'no_spaces_inside_parenthesis' => true,
7473
'no_trailing_comma_in_singleline' => true,
7574
'no_trailing_whitespace' => true,
7675
'no_trailing_whitespace_in_comment' => true,
7776
'no_unneeded_control_parentheses' => true,
7877
'no_unreachable_default_argument_value' => true,
78+
'no_unused_imports' => true,
7979
'no_useless_return' => true,
8080
'no_whitespace_before_comma_in_array' => true,
8181
'no_whitespace_in_blank_line' => true,
8282
'normalize_index_brace' => true,
8383
'not_operator_with_successor_space' => true,
8484
'object_operator_without_whitespace' => true,
85+
'ordered_class_elements' => true,
86+
'ordered_imports' => true,
87+
'phpdoc_align' => [
88+
'tags' => ['param', 'return', 'throws', 'type'],
89+
],
8590
'phpdoc_indent' => true,
8691
'phpdoc_no_access' => true,
92+
'phpdoc_no_alias_tag' => true,
8793
'phpdoc_no_package' => true,
8894
'phpdoc_no_useless_inheritdoc' => true,
8995
'phpdoc_scalar' => true,
@@ -97,31 +103,32 @@
97103
'short_scalar_cast' => true,
98104
'simplified_null_return' => true,
99105
'single_blank_line_at_eof' => true,
100-
'single_blank_line_before_namespace' => true,
101106
'single_class_element_per_statement' => true,
102107
'single_import_per_statement' => true,
103108
'single_line_after_imports' => true,
104109
'single_line_comment_style' => [
105110
'comment_types' => ['hash'],
106111
],
107112
'single_quote' => true,
113+
'single_space_around_construct' => true,
108114
'space_after_semicolon' => true,
115+
'spaces_inside_parentheses' => ['space' => 'none'],
109116
'standardize_not_equals' => true,
117+
'statement_indentation' => true,
110118
'switch_case_semicolon_to_colon' => true,
111119
'switch_case_space' => true,
112120
'ternary_operator_spaces' => true,
121+
'trailing_comma_in_multiline' => true,
113122
'trim_array_spaces' => true,
123+
'type_declaration_spaces' => true,
114124
'unary_operator_spaces' => true,
115-
'trailing_comma_in_multiline' => true,
116-
'ordered_class_elements' => true,
117-
'ordered_imports' => true,
118125
'visibility_required' => [
119126
'elements' => ['method', 'property'],
120127
],
121128
'whitespace_after_comma_in_array' => true,
122-
'no_unused_imports' => true,
123129
];
124130

131+
125132
$finder = Finder::create()
126133
->notPath('bootstrap')
127134
->notPath('storage')

Modules/AppointmentSlots/Services/AppointmentSlotsService.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private function createCalendarEvent(ApplicationRound $applicationRound)
199199
$applicationLink = URL::route($route, $applicationRound->application->id);
200200
$description = "<a href='{$applicationLink}'>Application Link</a> for Job role: <a href='{$applicationRound->application->job->link}'>{$applicationRound->application->job->title}</a>";
201201

202-
$event = new CalendarEventService;
202+
$event = new CalendarEventService();
203203

204204
$event->create([
205205
'summary' => $summary,

Modules/Client/Entities/Client.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
class Client extends Model
2020
{
21-
use HasHierarchy, HasFactory, Filters;
21+
use HasHierarchy;
22+
use HasFactory;
23+
use Filters;
2224

2325
protected $fillable = ['name', 'key_account_manager_id', 'status', 'is_channel_partner', 'has_departments', 'channel_partner_id', 'parent_organisation_id', 'client_id', 'is_billable'];
2426

@@ -152,6 +154,7 @@ public function getBillableAmountForTerm(int $monthsToSubtract, $projects, $peri
152154
public function getTaxAmountForTerm(int $monthsToSubtract, $projects, $periodStartDate = null, $periodEndDate = null)
153155
{
154156
$monthsToSubtract = $monthsToSubtract ?? 1;
157+
155158
// Todo: Implement tax calculation correctly as per the IGST rules
156159
return round($this->getBillableAmountForTerm($monthsToSubtract, $projects, $periodStartDate, $periodEndDate) * ($this->country->initials == 'IN' ? config('invoice.tax-details.igst') : 0), 2);
157160
}
@@ -409,7 +412,7 @@ public function getClientsAttribute()
409412

410413
protected static function booted()
411414
{
412-
static::addGlobalScope(new ClientGlobalScope);
415+
static::addGlobalScope(new ClientGlobalScope());
413416
}
414417

415418
protected static function newFactory()

Modules/Client/Entities/Scopes/ClientGlobalScope.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class ClientGlobalScope implements Scope
1111
/**
1212
* Apply the scope to a given Eloquent query builder.
1313
*
14-
* @param \Illuminate\Database\Eloquent\Builder $builder
15-
* @param \Illuminate\Database\Eloquent\Model $model
14+
* @param \Illuminate\Database\Eloquent\Builder $builder
15+
* @param \Illuminate\Database\Eloquent\Model $model
1616
*
1717
* @return \Illuminate\Database\Eloquent\Builder
1818
*/

Modules/Client/Http/Controllers/ModuleBaseController.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@
99

1010
class ModuleBaseController extends BaseController
1111
{
12-
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
12+
use AuthorizesRequests;
13+
use DispatchesJobs;
14+
use ValidatesRequests;
1315
}

Modules/Client/Rules/ClientNameExist.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public function __construct()
2020
/**
2121
* Determine if the validation rule passes.
2222
*
23-
* @param string $attribute
24-
* @param mixed $value
23+
* @param string $attribute
24+
* @param mixed $value
2525
*
2626
* @return bool
2727
*/

Modules/CodeTrek/Emails/CodeTrekApplicantRoundMail.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
class CodeTrekApplicantRoundMail extends Mailable
1010
{
11-
use Queueable, SerializesModels;
11+
use Queueable;
12+
use SerializesModels;
1213
public $applicationRound;
1314
public $codetrekApplicant;
1415

Modules/CodeTrek/Emails/CodetrekMailApplicant.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
class CodetrekMailApplicant extends Mailable
1010
{
11-
use Queueable, SerializesModels;
11+
use Queueable;
12+
use SerializesModels;
1213
public $applicant;
1314

1415
/**

Modules/CodeTrek/Entities/CodeTrekApplicant.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
use Illuminate\Database\Eloquent\Model;
88
use Illuminate\Database\Eloquent\SoftDeletes;
99
use Modules\CodeTrek\Database\factories\CodeTrekApplicantFactory;
10-
use Modules\Operations\Entities\OfficeLocation;
1110
use Modules\User\Entities\User;
1211

1312
class CodeTrekApplicant extends Model
1413
{
15-
use SoftDeletes, HasFactory;
14+
use SoftDeletes;
15+
use HasFactory;
1616
protected $guarded = [];
1717

1818
public function roundDetails()
@@ -25,11 +25,6 @@ public static function factory()
2525
return new CodeTrekApplicantFactory();
2626
}
2727

28-
public function center()
29-
{
30-
return $this->belongsTo(OfficeLocation::class, 'center_id');
31-
}
32-
3328
public function getDaysInCodetrekAttribute()
3429
{
3530
$internshipStartDate = Carbon::parse($this->internship_start_date);

Modules/CodeTrek/Http/Controllers/CodeTrekController.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Modules\CodeTrek\Entities\CodeTrekApplicant;
99
use Modules\CodeTrek\Http\Requests\CodeTrekRequest;
1010
use Modules\CodeTrek\Services\CodeTrekService;
11-
use Modules\Operations\Entities\OfficeLocation;
1211
use Modules\User\Entities\User;
1312

1413
class CodeTrekController extends Controller
@@ -28,7 +27,6 @@ public function index(Request $request)
2827
{
2928
// $this->authorize('view', $applicant); There are some issues in the production, which is why these lines are commented out.
3029

31-
$centres = OfficeLocation::all();
3230
$mentors = User::all();
3331
$applicantData = $this->service->getCodeTrekApplicants($request->all());
3432
$applicants = $applicantData['applicants'];
@@ -41,7 +39,6 @@ public function index(Request $request)
4139

4240
return view('codetrek::index', [
4341
'applicants' => $applicants,
44-
'centres' => $centres,
4542
'mentors' => $mentors,
4643
'reportApplicationCounts' => $reportApplicationCounts,
4744
'statusCounts' => $statusCounts,
@@ -78,12 +75,10 @@ public function edit(CodeTrekApplicant $applicant)
7875
{
7976
// $this->authorize('update', $applicant); There are some issues in the production, which is why these lines are commented out.
8077

81-
$centres = OfficeLocation::all();
82-
8378
$mentors = User::all();
8479
$this->service->edit($applicant);
8580

86-
return view('codetrek::edit', ['applicant' => $applicant, 'centres' => $centres, 'mentors' => $mentors]);
81+
return view('codetrek::edit', ['applicant' => $applicant, 'mentors' => $mentors]);
8782
}
8883
public function evaluate(CodeTrekApplicant $applicant)
8984
{

Modules/CodeTrek/Policies/CodetrekApplicantPolicy.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CodeTrekApplicantPolicy
1212
/**
1313
* Determine whether the user can view any models.
1414
*
15-
* @param \Modules\User\Entities\User $user
15+
* @param \Modules\User\Entities\User $user
1616
*
1717
* @return mixed
1818
*/
@@ -24,7 +24,7 @@ public function viewAny(User $user)
2424
/**
2525
* Determine whether the user can view the model.
2626
*
27-
* @param \Modules\User\Entities\User $user
27+
* @param \Modules\User\Entities\User $user
2828
*
2929
* @return mixed
3030
*/
@@ -36,7 +36,7 @@ public function view(User $user)
3636
/**
3737
* Determine whether the user can create models.
3838
*
39-
* @param \Modules\User\Entities\User $user
39+
* @param \Modules\User\Entities\User $user
4040
*
4141
* @return mixed
4242
*/
@@ -48,7 +48,7 @@ public function create(User $user)
4848
/**
4949
* Determine whether the user can update the model.
5050
*
51-
* @param \Modules\User\Entities\User $user
51+
* @param \Modules\User\Entities\User $user
5252
*
5353
* @return mixed
5454
*/
@@ -60,7 +60,7 @@ public function update(User $user)
6060
/**
6161
* Determine whether the user can delete the model.
6262
*
63-
* @param \Modules\User\Entities\User $user
63+
* @param \Modules\User\Entities\User $user
6464
*
6565
* @return mixed
6666
*/

0 commit comments

Comments
 (0)