madbob/GASdottoNG

View on GitHub

Showing 494 of 494 total issues

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

    private function readProductQuantity($product, $field, $friends_bookings)
    {
        $combo = null;

        if (is_a($product, VariantCombo::class)) {
Severity: Minor
Found in code/app/Booking.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

    static detachUserRole(role_id, user_id, target_id, target_class) {
        utils.postAjax({
            method: 'POST',
            url: 'roles/detach',
            data: {
Severity: Major
Found in code/resources/assets/js/callables.js and 1 other location - About 1 hr to fix
code/resources/assets/js/callables.js on lines 8..19

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

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

    private function retrievePreSelectedFields($parameters)
    {
        $selected = [];

        if (isset($parameters['sorted_fields']) && empty($parameters['sorted_fields']) == false) {
Severity: Minor
Found in code/app/Importers/CSV/CSVImporter.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

    static attachUserRole(role_id, user_id, target_id, target_class) {
        utils.postAjax({
            method: 'POST',
            url: 'roles/attach',
            data: {
Severity: Major
Found in code/resources/assets/js/callables.js and 1 other location - About 1 hr to fix
code/resources/assets/js/callables.js on lines 21..32

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

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

    static init(container)
    {
        /*
            Questo mostra/nasconde il trigger addizionale per modificare in
            blocco l'ordinabilità dei prodotti, nella griglia della modifica
Severity: Minor
Found in code/resources/assets/js/products.js - About 1 hr to fix

    Method ensureAuth has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function ensureAuth($permissions = [], $or = true)
        {
            $user = Auth::user();
    
            if (is_null($user)) {
    Severity: Minor
    Found in code/app/Services/BaseService.php - About 1 hr to fix

      Method sumUpProducts has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function sumUpProducts($booking, &$datarow)
          {
              /*
                  TODO: Nel caso di prenotazioni salvate sarebbe molto più efficiente
                  cambiare semplicemente lo stato della prenotazione stessa, giacché
      Severity: Minor
      Found in code/app/Services/FastBookingsService.php - About 1 hr to fix

        Method create has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function create(Request $request)
            {
                $type = $request->input('type', null);
                if (is_null($type)) {
                    return view('movement.create');
        Severity: Minor
        Found in code/app/Http/Controllers/MovementsController.php - About 1 hr to fix

          Method postStatusScaleway has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function postStatusScaleway(Request $request)
              {
                  if (env('MAIL_MAILER') == 'scaleway') {
                      $api_endpoint = 'https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/webhooks';
          
          
          Severity: Minor
          Found in code/app/Http/Controllers/MailController.php - About 1 hr to fix

            Method movementTypes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function movementTypes($identifier = null, $with_trashed = false)
            {
                static $types = null;
            
                if ($identifier == 'VOID') {
            Severity: Minor
            Found in code/app/Helpers/Accounting.php - About 1 hr to fix

              Method fields has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function fields()
                  {
                      $ret = [
                          'date' => (object) [
                              'label' => _i('Data'),
              Severity: Minor
              Found in code/app/Importers/CSV/Movements.php - About 1 hr to fix

                Method up has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function up()
                    {
                        /*
                            Questa migrazione serve solo per il profiler, va adoperata per lo
                            sviluppo locale e non serve eseguirla sulle istanze di produzione
                Severity: Minor
                Found in code/database/migrations/2023_08_14_231825_create_xhprof_table.php - About 1 hr to fix

                  Method readDefinition has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private static function readDefinition($modifier, $json)
                      {
                          $definitions = [];
                  
                          if (isset($json->fixed)) {
                  Severity: Minor
                  Found in code/app/Importers/GDXP/Transformations.php - About 1 hr to fix

                    Method commons has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function commons($user)
                        {
                            static $gas_count = null;
                    
                            $ret = [
                    Severity: Minor
                    Found in code/app/View/Icons/Aggregate.php - About 1 hr to fix

                      Function success has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                                  success: (data) => {
                                      if (data.hasOwnProperty('status') && data.status == 'error') {
                                          utils.displayServerError(null, data);
                                          return;
                                      }
                      Severity: Minor
                      Found in code/resources/assets/js/bookings.js - About 1 hr to fix

                        Method queryMovements has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function queryMovements($query = null, $type = 'all')
                            {
                                if (is_null($query)) {
                                    $query = Movement::orderBy('created_at', 'desc');
                                }
                        Severity: Minor
                        Found in code/app/Supplier.php - About 1 hr to fix

                          Method create has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function create(array $data)
                              {
                                  $gas = Gas::find($data['gas_id']);
                          
                                  $user = new User();
                          Severity: Minor
                          Found in code/app/Http/Controllers/Auth/RegisterController.php - About 1 hr to fix

                            Method roleByFunction has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function roleByFunction($identifier)
                            {
                                $gas = currentAbsoluteGas();
                                $role_id = $gas->roles[$identifier] ?? null;
                                $ret = App\Role::find($role_id);
                            Severity: Minor
                            Found in code/app/Helpers/Permissions.php - About 1 hr to fix

                              Method up has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function up()
                                  {
                                      Schema::create('invoices', function (Blueprint $table) {
                                          $table->string('id')->primary();
                                          $table->timestamps();

                                Method formatSummaryShipping has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    private function formatSummaryShipping($order, $fields, $status, $shipping_place, $extra_modifiers)
                                    {
                                        $rows = [];
                                        $total = 0;
                                        $formattable = OrderFormatter::formattableColumns('summary');
                                Severity: Minor
                                Found in code/app/Printers/Concerns/Summary.php - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language