A free open source IT asset/license management system
Fixed small codacy nits
snipe4af5b2967c81
diff --git a/app/SyncAdapters/Mosyle/MosyleAdapter.php b/app/SyncAdapters/Mosyle/MosyleAdapter.phpindex e13105cdb6..43478f25a2 100644--- a/app/SyncAdapters/Mosyle/MosyleAdapter.php+++ b/app/SyncAdapters/Mosyle/MosyleAdapter.php@@ -154,6 +154,8 @@ class MosyleAdapter extends ConfigurableAdapter implements PushableAdapter* pull and is more stable across re-enrollment).** @param array<int, string> $changedFields+ *+ * @SuppressWarnings("PHPMD.ElseExpression")*/public function push(Asset $asset, array $changedFields = []): void{diff --git a/app/SyncAdapters/Support/ConfigurableAdapter.php b/app/SyncAdapters/Support/ConfigurableAdapter.phpindex 92849653fb..1649226875 100644--- a/app/SyncAdapters/Support/ConfigurableAdapter.php+++ b/app/SyncAdapters/Support/ConfigurableAdapter.php@@ -193,6 +193,9 @@ abstract class ConfigurableAdapter implements HostInventoryAdapterreturn $rules;}+ /**+ * @SuppressWarnings("PHPMD.ElseExpression")+ */public function saveConfig(Request $request): void{$slug = $this->instance->slug;diff --git a/app/SyncAdapters/SyncHostFromAdapter.php b/app/SyncAdapters/SyncHostFromAdapter.phpindex d55ceab91c..a595824e18 100644--- a/app/SyncAdapters/SyncHostFromAdapter.php+++ b/app/SyncAdapters/SyncHostFromAdapter.php@@ -33,6 +33,9 @@ use RuntimeException;*/class SyncHostFromAdapter{+ /**+ * @SuppressWarnings("PHPMD.ElseExpression")+ */public static function run(HostInventoryRecord $record): Asset{return DB::transaction(function () use ($record) {diff --git a/tests/Feature/SyncAdapters/AssetTagPatternTest.php b/tests/Feature/SyncAdapters/AssetTagPatternTest.phpindex 060f4ed99c..72d8b0024b 100644--- a/tests/Feature/SyncAdapters/AssetTagPatternTest.php+++ b/tests/Feature/SyncAdapters/AssetTagPatternTest.php@@ -91,7 +91,7 @@ class AssetTagPatternTest extends TestCasepublic function test_no_pattern_falls_back_to_synthetic_source_id_tag(){- $fleet = $this->configuredFleet();+ $this->configuredFleet();// No asset_tag_pattern stored.SyncHostFromAdapter::run(new HostInventoryRecord(@@ -168,7 +168,7 @@ class AssetTagPatternTest extends TestCasepublic function test_default_category_falls_back_to_discovered_hardware_when_unset(){- $fleet = $this->configuredFleet();+ $this->configuredFleet();// No default_category_id stored.SyncHostFromAdapter::run(new HostInventoryRecord(diff --git a/tests/Feature/SyncAdapters/ExtraFieldMappingTest.php b/tests/Feature/SyncAdapters/ExtraFieldMappingTest.phpindex ff66181d9d..47eb75ee14 100644--- a/tests/Feature/SyncAdapters/ExtraFieldMappingTest.php+++ b/tests/Feature/SyncAdapters/ExtraFieldMappingTest.php@@ -133,7 +133,7 @@ class ExtraFieldMappingTest extends TestCase// custom:{id}.$this->assertArrayHasKey('native:asset_tag', $options);$this->assertArrayHasKey('native:notes', $options);- foreach ($options as $target => $label) {+ foreach (array_keys($options) as $target) {if (in_array($target, ['skip', 'native:asset_tag', 'native:notes'], true)) {continue;}@@ -186,7 +186,7 @@ class ExtraFieldMappingTest extends TestCasepublic function test_asset_tag_defaults_to_native_and_writes_vendor_tag(){- $fleet = $this->configuredFleetInstance();+ $this->configuredFleetInstance();// No explicit mapping stored: default target for asset_tag is// native:asset_tag so the vendor's tag flows into Snipe-IT's@@ -250,7 +250,12 @@ class ExtraFieldMappingTest extends TestCasepublic function test_settings_page_renders_extra_field_dropdowns_for_adapter_that_declares_them(){- $customField = CustomField::factory()->create(['element' => 'text', 'name' => 'Team Assignment']);+ // Side-effect factory create. The custom field is a fixture that+ // has to exist on the DB for the settings page to render it as an+ // extras-mapping target. The returned instance isn't referenced+ // by name; the assertion just checks the field's name string+ // shows up in the rendered HTML.+ CustomField::factory()->create(['element' => 'text', 'name' => 'Team Assignment']);$html = $this->actingAs(\App\Models\User::factory()->superuser()->create())->get(route('settings.adapters.index', ['adapter' => 'fleet']))diff --git a/tests/Feature/SyncAdapters/GroupCompanyMappingTest.php b/tests/Feature/SyncAdapters/GroupCompanyMappingTest.phpindex e27be0a91f..e0ff8a1e71 100644--- a/tests/Feature/SyncAdapters/GroupCompanyMappingTest.php+++ b/tests/Feature/SyncAdapters/GroupCompanyMappingTest.php@@ -52,7 +52,7 @@ class GroupCompanyMappingTest extends TestCasepublic function test_unmapped_group_falls_back_to_instance_company(){$customerA = Company::factory()->create();- $fleet = $this->configuredFleet($customerA->id);+ $this->configuredFleet($customerA->id);SyncHostFromAdapter::run(new HostInventoryRecord(sourceKey: 'fleet',diff --git a/tests/Feature/SyncAdapters/UserAssignmentTest.php b/tests/Feature/SyncAdapters/UserAssignmentTest.phpindex f7b0f48a92..ab2f7c97d5 100644--- a/tests/Feature/SyncAdapters/UserAssignmentTest.php+++ b/tests/Feature/SyncAdapters/UserAssignmentTest.php@@ -75,7 +75,7 @@ class UserAssignmentTest extends TestCasepublic function test_none_strategy_leaves_asset_unassigned_even_when_user_field_populated(){- $fleet = $this->configuredFleet();+ $this->configuredFleet();// Default strategy is 'none' when nothing is stored.User::factory()->create(['email' => '[email protected]']);