Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codespell]
skip = ./phpmd.xml,./CONTRIBUTORS.md,./composer.lock,*.min.js,*.map,./resources/lang/*,./node_modules/*,./public/vendor/*,./sample_csvs/*,./database/migrations/*,./public/js/*
count =
quiet-level = 3
ignore-words-list = checkin,Checkin,currentY,userA
22 changes: 22 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: codespell

on:
push:
branches:
- develop
pull_request:

jobs:
codespell:
runs-on: \${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run codespell
uses: codespell-project/[email protected]
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,17 @@ Please see the documentation on [contributing and developing for Snipe-IT](https


Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.

### Useful tools

Add codespell as a linter:
`pip install codespell`

Add a precommit hook:
`cp contrib/hooks/pre-commit .git/hooks/`

Add phpcs:
`curl -OL https://phars.phpcodesniffer.com/phpcs.phar`

Check against PSR12:
`php phpcs.phar -n --standard=PSR12 app/`
6 changes: 3 additions & 3 deletions ansible/freebsd/vagrant_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
become: true

#
# Install php and php dependancies
# Install php and php dependencies
#
- name: Install PHP dependancies
- name: Install PHP dependencies
pkgng:
name: "{{ item }}"
state: present
Expand Down Expand Up @@ -94,7 +94,7 @@
become: true

#
# Install the lastest version of composer
# Install the latest version of composer
#
- name: Composer check
stat:
Expand Down
2 changes: 1 addition & 1 deletion ansible/ubuntu/vagrant_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
- unzip
- python-pymysql
#
# Install the lastest version of composer
# Install the latest version of composer
#
- name: Composer check
stat:
Expand Down
8 changes: 4 additions & 4 deletions app/Console/Commands/LdapTroubleshooter.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function handle()
$this->line("Trying TLS first for port $port");
$ldap_url = "ldaps://".$parsed['host'].":$port";
if($this->test_anonymous_bind($ldap_url)) {
$this->info("Anonymous bind succesful to $ldap_url!");
$this->info("Anonymous bind successful to $ldap_url!");
$ldap_urls[] = [ $ldap_url, true, false ];
$pretty_ldap_urls[] = [ $ldap_url, "YES", "no" ];
continue; // TODO - lots of copypasta in these if(test_anonymous_bind()) routines...
Expand All @@ -282,7 +282,7 @@ public function handle()
}

if($this->test_anonymous_bind($ldap_url, false)) {
$this->info("Anonymous bind succesful to $ldap_url with certifcate-checks disabled");
$this->info("Anonymous bind successful to $ldap_url with certificate-checks disabled");
$ldap_urls[] = [ $ldap_url, false, false ];
$pretty_ldap_urls[] = [ $ldap_url, "no", "no" ];
continue;
Expand All @@ -292,7 +292,7 @@ public function handle()

$ldap_url = "ldap://".$parsed['host'].":$port";
if($this->test_anonymous_bind($ldap_url, true, true)) {
$this->info("Plain connection to $ldap_url with STARTTLS succesful!");
$this->info("Plain connection to $ldap_url with STARTTLS successful!");
$ldap_urls[] = [ $ldap_url, true, true ];
$pretty_ldap_urls[] = [ $ldap_url, "YES", "YES" ];
continue;
Expand All @@ -301,7 +301,7 @@ public function handle()
}

if($this->test_anonymous_bind($ldap_url)) {
$this->info("Plain connection to $ldap_url succesful!");
$this->info("Plain connection to $ldap_url successful!");
$ldap_urls[] = [ $ldap_url, true, false ];
$pretty_ldap_urls[] = [ $ldap_url, "YES", "no" ];
continue;
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/RestoreFromBackup.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static function guess_prefix($input):string
$parser->should_guess = true;
$parser->line_aware_piping(); // <----- THIS is doing the heavy lifting!

$check_tables = ['settings' => null, 'migrations' => null /* 'assets' => null */]; //TODO - move to statics?
$check_tables = ['settings' => null, 'migrations' => null /* 'assets' => null */]; //TODO - move to static?
//can't use 'users' because the 'accessories_checkout' table?
// can't use 'assets' because 'ver1_components_assets'
foreach($check_tables as $check_table => $_ignore) {
Expand Down Expand Up @@ -508,7 +508,7 @@ public function handle()
$bar->finish();
$this->line('');
} else {
$this->info(count($interesting_files).' files were succesfully transferred');
$this->info(count($interesting_files).' files were successfully transferred');
}
if (count($unsafe_files) > 0) {
foreach ($unsafe_files as $unsafe_file) {
Expand Down
2 changes: 1 addition & 1 deletion app/Events/CheckoutableCheckedIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CheckoutableCheckedIn
public $checkedOutTo;
public $checkedInBy;
public $note;
public $action_date; // Date setted in the hardware.checkin view at the checkin_at input, for the action log
public $action_date; // Date set in the hardware.checkin view at the checkin_at input, for the action log
public $originalValues;

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ static public function getRedirectOption($request, $id, $table, $item_id = null)

/**
* Check for inconsistencies before activating scoped locations with FullMultipleCompanySupport
* If there are locations with different companies than related objects unforseen problems could arise
* If there are locations with different companies than related objects unforeseen problems could arise
*
* @author T. Regnery <[email protected]>
* @since 7.0
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/PredefinedKitsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function destroy($id) : JsonResponse
$this->authorize('delete', PredefinedKit::class);
$kit = PredefinedKit::findOrFail($id);

// Delete childs
// Delete children
$kit->models()->detach();
$kit->licenses()->detach();
$kit->consumables()->detach();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AssetModelsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public function postBulkEdit(Request $request) : View | RedirectResponse


/**
* Returns a view that allows the user to bulk edit model attrbutes
* Returns a view that allows the user to bulk edit model attributes
*
* @author [A. Gianotto] [<[email protected]>]
* @since [v1.7]
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Assets/BulkAssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ public function storeCheckout(AssetCheckoutRequest $request) : RedirectResponse
}

$errors = [];
DB::transaction(function () use ($target, $admin, $checkout_at, $expected_checkin, &$errors, $assets, $request) { //NOTE: $errors is passsed by reference!
DB::transaction(function () use ($target, $admin, $checkout_at, $expected_checkin, &$errors, $assets, $request) { //NOTE: $errors is passed by reference!
foreach ($assets as $asset) {
$this->authorize('checkout', $asset);

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function reset(Request $request)
if (strpos(Setting::passwordComplexityRulesSaving('store'), 'disallow_same_pwd_as_user_fields') !== false) {
$request->validate(
[
'password' => 'required|notIn:["'.$user->email.'","'.$user->username.'","'.$user->first_name.'","'.$user->last_name.'"',
'password' => 'required|notIn:["'.$user->email.'","'.$user->username.'","'.$user->first_name.'","'.$user->last_name.'"', // codespell:ignore
], $messages);
}

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/BulkAssetModelsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class BulkAssetModelsController extends Controller
{
/**
* Returns a view that allows the user to bulk edit model attrbutes
* Returns a view that allows the user to bulk edit model attributes
*
* @author [A. Gianotto] [<[email protected]>]
* @since [v1.7]
Expand Down Expand Up @@ -55,7 +55,7 @@ public function edit(Request $request) : View | RedirectResponse
}

/**
* Returns a view that allows the user to bulk edit model attrbutes
* Returns a view that allows the user to bulk edit model attributes
*
* @author [A. Gianotto] [<[email protected]>]
* @since [v1.7]
Expand Down
12 changes: 6 additions & 6 deletions app/Http/Controllers/Kits/PredefinedKitsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function destroy($kit_id)
return redirect()->route('kits.index')->with('error', trans('admin/kits/general.kit_not_found'));
}

// Delete childs
// Delete children
$kit->models()->detach();
$kit->licenses()->detach();
$kit->consumables()->detach();
Expand Down Expand Up @@ -217,7 +217,7 @@ public function detachModel($kit_id, $model_id)
return redirect()->route('kits.index')->with('error', trans('admin/kits/general.kit_none'));
}

// Delete childs
// Delete children
$kit->models()->detach($model_id);

// Redirect to the kit management page
Expand Down Expand Up @@ -250,7 +250,7 @@ public function editLicense($kit_id, $license_id)
}

/**
* Update attached licese
* Update attached license
*
* @author [D. Minaev] [<[email protected]>]
* @param int $kit_id
Expand Down Expand Up @@ -296,7 +296,7 @@ public function detachLicense($kit_id, $license_id)
return redirect()->route('kits.index')->with('error', trans('admin/kits/general.kit_none'));
}

// Delete childs
// Delete children
$kit->licenses()->detach($license_id);

// Redirect to the kit management page
Expand Down Expand Up @@ -374,7 +374,7 @@ public function detachAccessory($kit_id, $accessory_id)
return redirect()->route('kits.index')->with('error', trans('admin/kits/general.kit_none'));
}

// Delete childs
// Delete children
$kit->accessories()->detach($accessory_id);

// Redirect to the kit management page
Expand Down Expand Up @@ -452,7 +452,7 @@ public function detachConsumable($kit_id, $consumable_id)
return redirect()->route('kits.index')->with('error', trans('admin/kits/general.kit_none'));
}

// Delete childs
// Delete children
$kit->consumables()->detach($consumable_id);

// Redirect to the kit management page
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ViewAssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getIndex() : View | RedirectResponse

}

// Since some models may re-use the same fieldsets/fields, let's make the array unique so we don't repeat columns
// Since some models may reuse the same fieldsets/fields, let's make the array unique so we don't repeat columns
array_unique($field_array);

if (isset($user->id)) {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/DeleteUserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function prepareForValidation(): void
public function rules(): array
{
return [
'user' => Rule::notIn([auth()->id()]),
'user' => Rule::notIn([auth()->id()]), // codespell:ignore
'managed_users' => Rule::in([0]),
'managed_locations' => Rule::in([0]),
'assigned_assets' => Rule::in([0]),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/SettingsSamlRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function withValidator($validator)
$x509 = openssl_x509_read($custom_x509cert);
$pkey = openssl_pkey_get_private($custom_privateKey);
} elseif ($this->input('saml_sp_regenerate_keypair') == '1' || ! $this->has('saml_sp_x509cert') || $was_custom_x509cert) {
// key regeneration requested, no certificate defined yet or previous custom certicate was removed
// key regeneration requested, no certificate defined yet or previous custom certificate was removed
error_log('regen');
$cert_updated = true;
$dn = [
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Transformers/DepreciationReportTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Illuminate\Database\Eloquent\Collection;

/**
* This tranformer looks like it's extraneous, since we return as much or more
* This transformer looks like it's extraneous, since we return as much or more
* info in the AssetsTransformer, but we want to flatten these results out so that they
* don't dislose more information than we want. Folks with depreciation powers don't necessaily
* don't dislose more information than we want. Folks with depreciation powers don't necessarily
* have the right to see additional info, and inspecting the API call here could disclose
* info they're not supposed to see.
*
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/PredefinedKitsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function transformPredefinedKit(PredefinedKit $kit)
}

/**
* transform collection of any elemets attached to kit
* transform collection of any elements attached to kit
* @return array
*/
public function transformElements(Collection $elements, $total)
Expand Down
4 changes: 2 additions & 2 deletions app/Importer/AccessoryImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function createAccessoryIfNotExists($row)
$accessory = Accessory::where('name', $this->item['name'])->first();
if ($accessory) {
if (! $this->updating) {
$this->log('A matching Accessory '.$this->item['name'].' already exists. ');
$this->log('A matching Accessory ' . $this->item['name'] . ' already exists. ');

return;
}
Expand All @@ -50,7 +50,7 @@ public function createAccessoryIfNotExists($row)
// This sets an attribute on the Loggable trait for the action log
$accessory->setImported(true);
if ($accessory->save()) {
$this->log('Accessory '.$this->item['name'].' was created');
$this->log('Accessory ' . $this->item['name'] . ' was created');

return;
}
Expand Down
Loading
Loading