Showing 32 of 123 total issues

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

<?php

namespace App\Services\AssignRule;

use App\Services\CustomerService;
Severity: Major
Found in app/Services/AssignRule/Rule3.php and 3 other locations - About 1 day to fix
app/Services/AssignRule/Rule5.php on lines 1..30
app/Services/AssignRule/Rule6.php on lines 1..30
app/Services/AssignRule/Rule7.php on lines 1..30

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

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 4 locations. Consider refactoring.
Open

<?php

namespace App\Services\AssignRule;

use App\Services\CustomerService;
Severity: Major
Found in app/Services/AssignRule/Rule7.php and 3 other locations - About 1 day to fix
app/Services/AssignRule/Rule3.php on lines 1..30
app/Services/AssignRule/Rule5.php on lines 1..30
app/Services/AssignRule/Rule6.php on lines 1..30

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

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 4 locations. Consider refactoring.
Open

<?php

namespace App\Services\AssignRule;

use App\Services\CustomerService;
Severity: Major
Found in app/Services/AssignRule/Rule5.php and 3 other locations - About 1 day to fix
app/Services/AssignRule/Rule3.php on lines 1..30
app/Services/AssignRule/Rule6.php on lines 1..30
app/Services/AssignRule/Rule7.php on lines 1..30

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

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 4 locations. Consider refactoring.
Open

<?php

namespace App\Services\AssignRule;

use App\Services\CustomerService;
Severity: Major
Found in app/Services/AssignRule/Rule6.php and 3 other locations - About 1 day to fix
app/Services/AssignRule/Rule3.php on lines 1..30
app/Services/AssignRule/Rule5.php on lines 1..30
app/Services/AssignRule/Rule7.php on lines 1..30

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

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

    public function important(Request $request) {
        $userId = $request->session()->get('user_id');
        $params = $request->all();
        DB::beginTransaction();
        $model = Customer::find($params['id']);
Severity: Major
Found in app/Http/Controllers/CustomController.php and 1 other location - About 3 hrs to fix
app/Http/Controllers/CustomController.php on lines 366..377

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

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

    public function lock(Request $request) {
        $userId = $request->session()->get('user_id');
        $params = $request->all();
        DB::beginTransaction();
        $model = Customer::find($params['id']);
Severity: Major
Found in app/Http/Controllers/CustomController.php and 1 other location - About 3 hrs to fix
app/Http/Controllers/CustomController.php on lines 437..448

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

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 info has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function info(Request $request)
    {
        $userId = $request->session()->get('user_id');
        $color = ['', 'green', 'blue', 'purple', 'pinkpurple', 'red'];
        $params = $request->all();
Severity: Minor
Found in app/Http/Controllers/CustomController.php - About 1 hr to fix

    Method getDefaultRight has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getDefaultRight()
        {
            return [
                [
                    'key'  => 9999,
    Severity: Minor
    Found in app/Services/RightService.php - About 1 hr to fix

      Function add has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function add($params, $operUserId) {
              $customModel = new Customer();
      
              $result = ['status'=>1, 'error'=>''];
              $params['add_user_id'] = $operUserId;
      Severity: Minor
      Found in app/Services/CustomerEditService.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

      Method getLogListByCustomerId has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getLogListByCustomerId($customerId, $limit) {
              $dictModel = new SystemDict();
              $userModel = new SystemUser();
              $followUserArray = $userModel->getAllUserWithDelMap();
              $dict = $dictModel->getListByGroup($dictModel::GROUP_CUSTOM);
      Severity: Minor
      Found in app/Models/CustomerLog.php - About 1 hr to fix

        Method handle has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function handle($request, Closure $next)
            {
                $userId = $request->session()->get('user_id', 0);
        
                if (empty($userId)) {
        Severity: Minor
        Found in app/Http/Middleware/AuthMiddleware.php - About 1 hr to fix

          Method get has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function get($customId, $followUserId, $operUserId = 0, $assignType = 0) {
                  $customModel = new Customer();
                  $custom = $customModel->find($customId);
                  $oldFollowUserId = $custom->follow_user_id;
                  if (empty($custom) || $oldFollowUserId == $followUserId) {
          Severity: Minor
          Found in app/Services/CustomerService.php - About 1 hr to fix

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

                    if (isset($params['backTime']) && !empty($params['backTime']) && is_array($params['backTime']) ) {
                        $query = $query->where('date',  '>', strtotime($params['backTime'][0]));
                        $query = $query->where('date',  '<', strtotime($params['backTime'][1]));
                    }
            Severity: Major
            Found in app/Models/CustomerBack.php and 2 other locations - About 1 hr to fix
            app/Models/CustomerBack.php on lines 39..42
            app/Models/Notice.php on lines 52..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 106.

            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 3 locations. Consider refactoring.
            Open

                    if (isset($params['time']) && !empty($params['time']) && is_array($params['time']) ) {
                        $query = $query->where('date',  '>', strtotime($params['time'][0]));
                        $query = $query->where('date',  '<', strtotime($params['time'][1]));
                    }
            Severity: Major
            Found in app/Models/Notice.php and 2 other locations - About 1 hr to fix
            app/Models/CustomerBack.php on lines 39..42
            app/Models/CustomerBack.php on lines 43..46

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

            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 3 locations. Consider refactoring.
            Open

                    if (isset($params['applyTime']) && !empty($params['applyTime']) && is_array($params['applyTime']) ) {
                        $query = $query->where('apply_date',  '>', strtotime($params['applyTime'][0]));
                        $query = $query->where('apply_date',  '<', strtotime($params['applyTime'][1]));
                    }
            Severity: Major
            Found in app/Models/CustomerBack.php and 2 other locations - About 1 hr to fix
            app/Models/CustomerBack.php on lines 43..46
            app/Models/Notice.php on lines 52..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 106.

            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

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

                public function handle($config) {
                    echo PHP_EOL;
                    // 获取今天还有分配名额的用户
                    $customService = app(CustomerService::class);
                    $userService = app(UserService::class);
            Severity: Minor
            Found in app/Services/AssignRule/Rule1.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

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

                public function addNotices(Request $request) {
                    $userId = $request->session()->get('user_id');
                    $params = $request->all();
                    $customId = $params['id'];
                    $notices = $params['notices'];
            Severity: Minor
            Found in app/Http/Controllers/CustomController.php - About 1 hr to fix

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

                  public function handle() {
                      echo date('Y-m-d H:i:s') . ' start.......'.PHP_EOL;
                      // 取到所有分配规则
                      $model = new CustomerRuleConfig();
                      $rules = $model->get();
              Severity: Minor
              Found in app/Console/Commands/Assign.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

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

                  public function handle($config) {
                      echo PHP_EOL;
                      // 获取今天还有分配名额的用户
                      $customService = app(CustomerService::class);
                      $userService = app(UserService::class);
              Severity: Minor
              Found in app/Services/AssignRule/Rule1.php - About 1 hr to fix

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

                    private function _createWhere($params) {
                        $query = $this->leftJoin('customer', 'customer_backs.custom_id', '=', 'customer.id')->where('customer_backs.status', 1);
                        if (isset($params['customId']) && !empty($params['customId'])) {
                            $query = $query->where('customer_backs.custom_id', $params['customId']);
                        }
                Severity: Minor
                Found in app/Models/CustomerBack.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language