jakim/ig-monitoring

View on GitHub

Showing 51 of 53 total issues

Function actionDictionaries has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionDictionaries()
    {
        $dictionaries = [
            AccountInvalidationType::class,
            TagInvalidationType::class,
Severity: Minor
Found in commands/AdminController.php - About 1 hr to fix

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    protected function findStatsIds(?string $date, array $ignoredStatsIds = [])
    {
        return TagStats::find()
            ->cache()
            ->select(new Expression('MAX(id) as id'))
Severity: Major
Found in components/stats/diffs/MultipleTagsDiff.php and 1 other location - About 1 hr to fix
components/stats/diffs/MultiAccountsDiff.php on lines 52..63

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 104.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

namespace app\models;

use yii\db\ActiveRecord;
Severity: Major
Found in models/TagInvalidationType.php and 1 other location - About 1 hr to fix
models/AccountInvalidationType.php on lines 1..54

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 104.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

namespace app\models;

use yii\db\ActiveRecord;
Severity: Major
Found in models/AccountInvalidationType.php and 1 other location - About 1 hr to fix
models/TagInvalidationType.php on lines 1..54

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 104.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    protected function findStatsIds(?string $date, array $ignoredStatsIds = [])
    {
        return AccountStats::find()
            ->cache()
            ->select(new Expression('MAX(id) as id'))
Severity: Major
Found in components/stats/diffs/MultiAccountsDiff.php and 1 other location - About 1 hr to fix
components/stats/diffs/MultipleTagsDiff.php on lines 49..60

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 104.

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

Further Reading

Method actionAccounts has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function actionAccounts()
    {
        $searchModel = new AccountSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->query->andWhere(['account.monitoring' => 1]);
Severity: Minor
Found in modules/admin/controllers/MonitoringController.php - About 1 hr to fix

Method initData has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function initData($olderDate, $newerDate = null)
    {
        $olderDate = (new Carbon($olderDate))->startOfDay()->toDateTimeString();
        $newerDate = (new Carbon($newerDate))->endOfDay()->toDateTimeString();

Severity: Minor
Found in components/stats/AccountDaily.php - About 1 hr to fix

Function run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function run()
    {
        $proxyManager = Yii::createObject(ProxyManager::class);
        $accountBuilder = Yii::createObject([
            'class' => AccountBuilder::class,
Severity: Minor
Found in components/services/AccountUpdater.php - About 1 hr to fix

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 fetchAccountData has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function fetchAccountData(AccountScraper $scraper): Account
    {
        $idents = array_filter([
            $this->account->username,
        ]);
Severity: Minor
Found in components/services/AccountUpdater.php - About 1 hr to fix

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function actionForceUpdate($id)
    {
        $model = $this->findModel($id);
        if (!$model->is_valid) {
            $accountUpdater = Yii::createObject([
Severity: Major
Found in modules/admin/controllers/AccountController.php and 1 other location - About 1 hr to fix
modules/admin/controllers/TagController.php on lines 39..55

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 102.

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

Further Reading

Method init has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function init()
    {
        if (empty($this->statsAttributes)) {
            $this->statsAttributes = [
                'followed_by',

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function actionForceUpdate($id)
    {
        $model = $this->findModel($id);
        if (!$model->is_valid) {
            $tagUpdater = Yii::createObject([
Severity: Major
Found in modules/admin/controllers/TagController.php and 1 other location - About 1 hr to fix
modules/admin/controllers/AccountController.php on lines 47..63

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 102.

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

Further Reading

Method run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function run()
    {
        if ($this->model->monitoring) {
            return AjaxButton::widget([
                'confirm' => true,
Severity: Minor
Found in modules/admin/widgets/OnOffMonitoringButton.php - About 1 hr to fix

Method prepareModels has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function prepareModels()
    {
        $models = [];

        $dbFrom = $this->from->copy();
Severity: Minor
Found in components/stats/providers/AccountDiffDataProvider.php - About 1 hr to fix

Method init has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function init()
    {
        parent::init();
        $this->throwExceptionIfAccountIsNotSet();
        $this->throwExceptionIfFromToAreNotSet();
Severity: Minor
Found in components/stats/providers/AccountTagsDataProvider.php - About 1 hr to fix

Method registerClientScript has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function registerClientScript()
    {
        $options = ArrayHelper::merge([
            'url' => Url::to($this->url),
            'method' => 'post',
Severity: Minor
Found in modules/admin/widgets/AjaxButton.php - About 1 hr to fix

Method run has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function run()
    {
        $config = [
            'id' => $this->id,
            'type' => $this->type,
Severity: Minor
Found in components/visualizations/widgets/ChartWidget.php - About 1 hr to fix

Method actionCreateAccount has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function actionCreateAccount()
    {
        $form = new MonitoringForm();
        $form->setScenario(TrackerType::ACCOUNT);

Severity: Minor
Found in modules/admin/controllers/MonitoringController.php - About 1 hr to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if ($this->visibleData === true || isset($this->visibleData[$key])) {
            $monthlyChange = $this->monthlyDiff->getModel($model->id);
            $monthlyChange = ArrayHelper::getValue($monthlyChange, $this->statsAttribute);
            $value[] = is_numeric($monthlyChange) ? $formatter->asChange($monthlyChange, true, $this->numberFormat) : '-';
        }
Severity: Major
Found in modules/admin/components/grid/StatsColumn.php and 1 other location - About 1 hr to fix
modules/admin/components/grid/StatsColumn.php on lines 56..60

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 101.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if ($this->visibleData === true || isset($this->visibleData[$key])) {
            $dailyChange = $this->dailyDiff->getModel($model->id);
            $dailyChange = ArrayHelper::getValue($dailyChange, $this->statsAttribute);
            $value[] = is_numeric($dailyChange) ? $formatter->asChange($dailyChange, true, $this->numberFormat) : '-';
        }
Severity: Major
Found in modules/admin/components/grid/StatsColumn.php and 1 other location - About 1 hr to fix
modules/admin/components/grid/StatsColumn.php on lines 64..68

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 101.

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

Further Reading

Severity
Category
Status
Source
Language