Method I_can_get_all_values
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function I_can_get_all_values()
{
self::assertSame(
[
0 => [
File RangedWeaponStrengthSanctionsTableTest.php
has 344 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php declare(strict_types = 1);
namespace DrdPlus\Tests\Tables\Armaments\Weapons\Ranged;
use DrdPlus\Tables\Armaments\Weapons\Ranged\RangedWeaponStrengthSanctionsTable;
The class RangedWeaponStrengthSanctionsTableTest has 20 public methods. Consider refactoring RangedWeaponStrengthSanctionsTableTest to keep number of public methods under 10. Open
class RangedWeaponStrengthSanctionsTableTest extends AbstractStrengthSanctionsTableTest
{
/**
* @test
*/
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The method I_can_get_all_values() has 128 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function I_can_get_all_values()
{
self::assertSame(
[
0 => [
- Exclude checks
Avoid unused local variables such as '$actual'. Open
$actual = (new RangedWeaponStrengthSanctionsTable())->getHeader()
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused local variables such as '$expected'. Open
$expected =[
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function provideMissingStrengthAndDefenseNumberSanction()
{
return [
[10, -4],
[9, -4],
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 124.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function provideMissingStrengthAndEncounterRangeSanction()
{
return [
[10, -4],
[9, -4],
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 124.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid excessively long variable names like $shootingWeaponSanctionsTable. Keep variable name length under 20. Open
$shootingWeaponSanctionsTable = new RangedWeaponStrengthSanctionsTable();
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $shootingWeaponSanctionsTable. Keep variable name length under 20. Open
$shootingWeaponSanctionsTable = new RangedWeaponStrengthSanctionsTable();
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
The method I_can_get_attack_number_sanction is not named in camelCase. Open
public function I_can_get_attack_number_sanction($missingStrength, $expectedSanction)
{
self::assertSame(
$expectedSanction,
(new RangedWeaponStrengthSanctionsTable())->getAttackNumberSanction($missingStrength)
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_get_fight_number_sanction is not named in camelCase. Open
public function I_can_get_fight_number_sanction($missingStrength, $expectedSanction)
{
self::assertSame(
$expectedSanction,
(new RangedWeaponStrengthSanctionsTable())->getFightNumberSanction($missingStrength)
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_get_sanctions_for_missing_strength is not named in camelCase. Open
public function I_can_get_sanctions_for_missing_strength()
{
self::assertSame(
[
'missing_strength' => 1,
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_get_loading_sanction is not named in camelCase. Open
public function I_can_get_loading_sanction($missingStrength, $expectedSanction)
{
self::assertSame(
$expectedSanction,
(new RangedWeaponStrengthSanctionsTable())->getLoadingInRounds($missingStrength)
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_get_header is not named in camelCase. Open
public function I_can_get_header()
{
self::assertSame(
$expected =[
[
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_get_all_values is not named in camelCase. Open
public function I_can_get_all_values()
{
self::assertSame(
[
0 => [
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_not_get_any_sanction_for_too_much_missing_strength is not named in camelCase. Open
public function I_can_not_get_any_sanction_for_too_much_missing_strength($sanctionName)
{
$this->expectException(\DrdPlus\Tables\Armaments\Weapons\Exceptions\CanNotUseWeaponBecauseOfMissingStrength::class);
$sanctionGetter = 'get' . ucfirst($sanctionName);
(new RangedWeaponStrengthSanctionsTable())->$sanctionGetter(11);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_get_always_zero_for_every_sanction_if_no_missing_strength is not named in camelCase. Open
public function I_get_always_zero_for_every_sanction_if_no_missing_strength($sanctionName)
{
$sanctionGetter = 'get' . ucfirst($sanctionName);
$shootingWeaponSanctionsTable = new RangedWeaponStrengthSanctionsTable();
self::assertSame(0, $shootingWeaponSanctionsTable->$sanctionGetter(0));
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_get_base_of_wounds_sanction is not named in camelCase. Open
public function I_can_get_base_of_wounds_sanction($missingStrength, $expectedSanction)
{
self::assertSame(
$expectedSanction,
(new RangedWeaponStrengthSanctionsTable())->getBaseOfWoundsSanction($missingStrength)
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_properly_detect_if_can_use_a_shooting_weapon is not named in camelCase. Open
public function I_can_properly_detect_if_can_use_a_shooting_weapon($missingStrength, $canUse)
{
$shootingWeaponSanctionsTable = new RangedWeaponStrengthSanctionsTable();
self::assertSame($canUse, $shootingWeaponSanctionsTable->canUseIt($missingStrength));
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_get_encounter_range_sanction is not named in camelCase. Open
public function I_can_get_encounter_range_sanction($missingStrength, $expectedSanction)
{
self::assertSame(
$expectedSanction,
(new RangedWeaponStrengthSanctionsTable())->getEncounterRangeSanction($missingStrength)
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_get_defense_number_sanction is not named in camelCase. Open
public function I_can_get_defense_number_sanction($missingStrength, $expectedSanction)
{
self::assertSame(
$expectedSanction,
(new RangedWeaponStrengthSanctionsTable())->getDefenseNumberSanction($missingStrength)
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}