Showing 503 of 503 total issues
Consider simplifying this complex logical expression. Open
if (navigator.userAgent &&
(navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i) ||
Method prepareDataProvider
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function prepareDataProvider()
{
$requestParams = Yii::$app->getRequest()->getBodyParams();
if (empty($requestParams)) {
$requestParams = Yii::$app->getRequest()->getQueryParams();
Function showCalendar
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
, showCalendar = function showCalendar() {
//lets hide all the latest instances of datepicker
pageDatepickers = $window.document.getElementsByClassName('_720kb-datepicker-calendar');
angular.forEach(pageDatepickers, function forEachDatepickerPages(value, key) {
Function update
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
var update = function () {
if ($shadow == null) {
$shadow = angular.element('<div></div>').css({
position: 'absolute',
top: -10000,
Method getAvailableApiEndpoints
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getAvailableApiEndpoints()
{
$data = [];
$generic = [];
$userId = $this->model->id;
Similar blocks of code found in 2 locations. Consider refactoring. Open
element.on('dragenter', function(e) {
e = e.originalEvent || e;
scope.addClass(scope.dndCss.onHover);
e.preventDefault();
});
- 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 61.
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
element.on('dragend', function(e) {
e = e.originalEvent || e;
scope.removeClass(scope.dndCss.onDrag);
e.stopPropagation();
});
- 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 61.
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
Method addImage
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addImage($fileId, $filterId = 0, $throwException = false)
{
try {
// if the filterId is provded as a string the filter will be looked up by its name in the get filters array list.
if (is_string($filterId) && !is_numeric($filterId)) {
Function searchDetailClick
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
$scope.searchDetailClick = function(itemConfig, itemData) {
if (itemConfig.type === 'custom') {
$scope.click(itemConfig.menuItem, true).then(function() {
if (itemConfig.stateProvider) {
var params = {};
Function template
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
template: function () {
return '' +
'<div class="form-group form-side-by-side" ng-class="{\'input--hide-label\': i18n}">' +
'<div class="form-side form-side-label">' +
'<label>{{label}}</label>' +
Method callbackUpload
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function callbackUpload()
{
$config = new Config();
$config->setTempDir($this->getTempFolder());
$file = new File($config);
Method actionAsync
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionAsync()
{
if (($lockout = $this->sessionBruteForceLock(0))) {
return $this->sendArray(false, [Module::t('login_async_submission_limit_reached', ['time' => Yii::$app->formatter->asRelativeTime($lockout)])]);
}
Function addFile
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function addFile($fileSource, $fileName, $folderId = 0, $isHidden = false)
{
// ensure the file upload
$fileData = $this->ensureFileUpload($fileSource, $fileName);
// generate md5 hash from file source
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function formatExportValues
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function formatExportValues(ActiveQuery $query, array $formatter)
{
Yii::$app->formatter->nullDisplay = '';
$data = [];
$rowId = 0;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function ngRestConfig
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function ngRestConfig($config)
{
foreach ($this->ngRestScopes() as $arrayConfig) {
if (!isset($arrayConfig[0]) && !isset($arrayConfig[1])) {
throw new InvalidConfigException("Invalid ngRestScope definition. Definition must contain an array with two elements: `['create', []]`");
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function extractFilesDataFromMultipleFiles
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function extractFilesDataFromMultipleFiles(array $files)
{
$data = [];
$i = 0;
foreach ($files as $type => $field) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getActiveLanguage
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getActiveLanguage()
{
if ($this->_activeLanguage === null) {
if ($this->activeShortCodeCallable && is_callable($this->activeShortCodeCallable)) {
$langShortCode = call_user_func($this->activeShortCodeCallable, $this);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function extractFilesDataFromFilesArray
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function extractFilesDataFromFilesArray(array $file)
{
if (!isset($file['tmp_name'])) {
return [];
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function actionFixTableNames
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function actionFixTableNames()
{
$batch = TagRelation::find()->batch();
$i = 0;
$fixed = 0;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validatePassword
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function validatePassword($attribute)
{
if (!$this->hasErrors()) {
$user = $this->getUser();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"