Showing 2,466 of 2,466 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
private function setFormatterIntAttribute($formatter, $attribute, $value, $source, $alternative)
{
if (!is_int($attribute)) {
throw new InvalidArgumentException(
"The $source array keys must be integers recognizable by NumberFormatter::setAttribute(). \""
- 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 150.
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 class Controller has 11 public methods. Consider refactoring Controller to keep number of public methods under 10. Open
class Controller extends \yii\base\Controller
{
/**
* @deprecated since 2.0.13. Use [[ExitCode::OK]] instead.
*/
- 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 class AssetController has an overall complexity of 115 which is very high. The configured complexity threshold is 50. Open
class AssetController extends Controller
{
/**
* @var string controller default action ID.
*/
- Exclude checks
The class BaseMigrateController has an overall complexity of 154 which is very high. The configured complexity threshold is 50. Open
abstract class BaseMigrateController extends Controller
{
/**
* The name of the dummy migration that marks the beginning of the whole migration history.
*/
- Exclude checks
The class Container has an overall complexity of 123 which is very high. The configured complexity threshold is 50. Open
class Container extends Component
{
/**
* @var array singleton objects indexed by their types
*/
- Exclude checks
The class MessageController has an overall complexity of 156 which is very high. The configured complexity threshold is 50. Open
class MessageController extends \yii\console\Controller
{
/**
* @var string controller default action ID.
*/
- Exclude checks
The class BaseMigrateController has 11 public methods. Consider refactoring BaseMigrateController to keep number of public methods under 10. Open
abstract class BaseMigrateController extends Controller
{
/**
* The name of the dummy migration that marks the beginning of the whole migration history.
*/
- 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 class FixtureController has an overall complexity of 56 which is very high. The configured complexity threshold is 50. Open
class FixtureController extends Controller
{
use FixtureTrait;
/**
- Exclude checks
The class Cache has 16 public methods. Consider refactoring Cache to keep number of public methods under 10. Open
abstract class Cache extends Component implements CacheInterface
{
/**
* @var string a string prefixed to every cache key so that it is unique globally in the whole cache storage.
* It is recommended that you set a unique cache key prefix for each application if the same cache
- 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 class Controller has an overall complexity of 109 which is very high. The configured complexity threshold is 50. Open
class Controller extends \yii\base\Controller
{
/**
* @deprecated since 2.0.13. Use [[ExitCode::OK]] instead.
*/
- Exclude checks
The class DbManager has 29 non-getter- and setter-methods. Consider refactoring DbManager to keep number of methods under 25. Open
class DbManager extends BaseManager
{
/**
* @var Connection|array|string the DB connection object or the application component ID of the DB connection.
* After the DbManager object is created, if you want to change this property, you should only assign it
- Read upRead up
- Exclude checks
TooManyMethods
Since: 0.1
A class with too many 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'.
The default was changed from 10 to 25 in PHPMD 2.3.
Example
Source https://phpmd.org/rules/codesize.html#toomanymethods
The class PhpManager has an overall complexity of 149 which is very high. The configured complexity threshold is 50. Open
class PhpManager extends BaseManager
{
/**
* @var string the path of the PHP script that contains the authorization items.
* This can be either a file path or a [path alias](guide:concept-aliases) to the file.
- Exclude checks
The class HelpController has an overall complexity of 95 which is very high. The configured complexity threshold is 50. Open
class HelpController extends Controller
{
/**
* Displays available commands or the detailed information
* about a particular command.
- Exclude checks
The class DbManager has 16 public methods. Consider refactoring DbManager to keep number of public methods under 10. Open
class DbManager extends BaseManager
{
/**
* @var Connection|array|string the DB connection object or the application component ID of the DB connection.
* After the DbManager object is created, if you want to change this property, you should only assign it
- 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 class DbManager has an overall complexity of 148 which is very high. The configured complexity threshold is 50. Open
class DbManager extends BaseManager
{
/**
* @var Connection|array|string the DB connection object or the application component ID of the DB connection.
* After the DbManager object is created, if you want to change this property, you should only assign it
- Exclude checks
The class PhpManager has 31 non-getter- and setter-methods. Consider refactoring PhpManager to keep number of methods under 25. Open
class PhpManager extends BaseManager
{
/**
* @var string the path of the PHP script that contains the authorization items.
* This can be either a file path or a [path alias](guide:concept-aliases) to the file.
- Read upRead up
- Exclude checks
TooManyMethods
Since: 0.1
A class with too many 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'.
The default was changed from 10 to 25 in PHPMD 2.3.
Example
Source https://phpmd.org/rules/codesize.html#toomanymethods
The class BaseArrayHelper has 12 public methods. Consider refactoring BaseArrayHelper to keep number of public methods under 10. Open
class BaseArrayHelper
{
/**
* Converts an object or an array of objects into an array.
* @param object|array|string $object the object to be converted into an array
- 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 class PhpManager has 16 public methods. Consider refactoring PhpManager to keep number of public methods under 10. Open
class PhpManager extends BaseManager
{
/**
* @var string the path of the PHP script that contains the authorization items.
* This can be either a file path or a [path alias](guide:concept-aliases) to the file.
- 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 class Cache has an overall complexity of 68 which is very high. The configured complexity threshold is 50. Open
abstract class Cache extends Component implements CacheInterface
{
/**
* @var string a string prefixed to every cache key so that it is unique globally in the whole cache storage.
* It is recommended that you set a unique cache key prefix for each application if the same cache
- Exclude checks
The class Table has an overall complexity of 54 which is very high. The configured complexity threshold is 50. Open
class Table extends Widget
{
const DEFAULT_CONSOLE_SCREEN_WIDTH = 120;
const CONSOLE_SCROLLBAR_OFFSET = 3;
const CHAR_TOP = 'top';
- Exclude checks