The class WeaponCodeTest has 11 public methods. Consider refactoring WeaponCodeTest to keep number of public methods under 10. Open
abstract class WeaponCodeTest extends WeaponlikeCodeTest
{
/**
* @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
Method I_can_extended_it_by_custom_translatable_code
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function I_can_extended_it_by_custom_translatable_code()
{
/** @var WeaponCode $sutClass */
$sutClass = self::getSutClass();
$reflectionClass = new \ReflectionClass($sutClass);
Missing class import via use statement (line '81', column '18'). Open
if ((new \ReflectionClass($sutClass))->isAbstract()) {
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '62', column '32'). Open
$reflectionClass = new \ReflectionClass($sutClass);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class '\DrdPlus\Codes\Armaments\WeaponCategoryCode' in method 'getRandomWeaponCategoryCode'. Open
$category = WeaponCategoryCode::getIt(
$this->getWeaponCategoryValues()[array_rand($this->getWeaponCategoryValues())]
);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function I_can_not_use_empty_string_for_translation_of_custom_code()
{
$this->expectException(\DrdPlus\Codes\Partials\Exceptions\InvalidTranslationFormat::class);
$this->expectExceptionMessageMatches("~''~");
/** like @see \DrdPlus\Codes\Armaments\MeleeWeaponCode::addNewMeleeWeaponCode */
- 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 92.
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 I_can_not_use_invalid_plural_for_translation_of_custom_code()
{
$this->expectException(\DrdPlus\Codes\Partials\Exceptions\UnknownTranslationPlural::class);
$this->expectExceptionMessageMatches('~all~');
/** like @see \DrdPlus\Codes\Armaments\MeleeWeaponCode::addNewMeleeWeaponCode */
- 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 92.
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
The method I_can_not_use_non_string_for_translation_of_custom_code is not named in camelCase. Open
public function I_can_not_use_non_string_for_translation_of_custom_code()
{
$this->expectException(\DrdPlus\Codes\Partials\Exceptions\InvalidTranslationFormat::class);
$this->expectExceptionMessageMatches('~NULL~');
/** like @see \DrdPlus\Codes\Armaments\MeleeWeaponCode::addNewMeleeWeaponCode */
- 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_easily_find_out_if_is_weapon is not named in camelCase. Open
public function I_can_easily_find_out_if_is_weapon()
{
/** @var WeaponCode $sut */
$sut = $this->getSut();
self::assertTrue($sut->isWeapon());
- 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_extended_it_by_custom_translatable_code is not named in camelCase. Open
public function I_can_extended_it_by_custom_translatable_code()
{
/** @var WeaponCode $sutClass */
$sutClass = self::getSutClass();
$reflectionClass = new \ReflectionClass($sutClass);
- 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_use_empty_string_for_translation_of_custom_code is not named in camelCase. Open
public function I_can_not_use_empty_string_for_translation_of_custom_code()
{
$this->expectException(\DrdPlus\Codes\Partials\Exceptions\InvalidTranslationFormat::class);
$this->expectExceptionMessageMatches("~''~");
/** like @see \DrdPlus\Codes\Armaments\MeleeWeaponCode::addNewMeleeWeaponCode */
- 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_use_invalid_language_code_format_for_custom_code is not named in camelCase. Open
public function I_can_not_use_invalid_language_code_format_for_custom_code()
{
$this->expectException(\DrdPlus\Codes\Partials\Exceptions\InvalidLanguageCode::class);
$this->expectExceptionMessageMatches('~a1~');
/** @var WeaponCode $sutClass */
- 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_easily_find_out_it_is_not_projectile is not named in camelCase. Open
public function I_can_easily_find_out_it_is_not_projectile()
{
/** @var WeaponCode $sut */
$sut = $this->getSut();
self::assertFalse($sut->isProjectile());
- 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_use_invalid_plural_for_translation_of_custom_code is not named in camelCase. Open
public function I_can_not_use_invalid_plural_for_translation_of_custom_code()
{
$this->expectException(\DrdPlus\Codes\Partials\Exceptions\UnknownTranslationPlural::class);
$this->expectExceptionMessageMatches('~all~');
/** like @see \DrdPlus\Codes\Armaments\MeleeWeaponCode::addNewMeleeWeaponCode */
- 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_extended_it_by_same_code_but_different_category is not named in camelCase. Open
abstract public function I_can_not_extended_it_by_same_code_but_different_category();
- 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 It_is_weapon_code is not named in camelCase. Open
public function It_is_weapon_code()
{
/** @var WeaponCode $sut */
$sut = $this->getSut();
self::assertInstanceOf(WeaponCode::class, $sut);
- 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_easily_find_out_if_is_shield is not named in camelCase. Open
public function I_can_easily_find_out_if_is_shield()
{
/** @var WeaponCode $sut */
$sut = $this->getSut();
self::assertFalse($sut->isShield());
- 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_use_invalid_data_format_of_translations_for_custom_code is not named in camelCase. Open
public function I_can_not_use_invalid_data_format_of_translations_for_custom_code()
{
$this->expectException(\DrdPlus\Codes\Partials\Exceptions\InvalidTranslationFormat::class);
$this->expectExceptionMessageMatches('~this should be array~');
/** like @see \DrdPlus\Codes\Armaments\MeleeWeaponCode::addNewMeleeWeaponCode */
- 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() {
}
}