Showing 12 of 21 total issues

File TransactionForm.jsx has 421 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from "react";

import Select from 'react-select';
import Fuse from 'fuse.js';

Severity: Minor
Found in app/javascript/react/src/components/TransactionForm.jsx - About 6 hrs to fix

    Function connect has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      connect() {
        // Initialize the table
        const table = $('#transactions').DataTable({
          processing: true,
          serverSide: true,
    Severity: Major
    Found in app/javascript/controllers/datatable_controller.js - About 2 hrs to fix

      Function render has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render() {
          const { step, action, peer } = this.state;
          const { peers, penning } = this.props;
          const errors = this.errors();
      
      
      Severity: Major
      Found in app/javascript/react/src/components/TransactionForm.jsx - About 2 hrs to fix

        Method sanitize_params has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def sanitize_params(params)
            # Parsing according to https://datatables.net/manual/server-side
            clean = {
              draw: params.require(:draw).to_i,
              start: params.require(:start).to_i,
        Severity: Minor
        Found in app/controllers/concerns/data_table.rb - 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 sanitize_params has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def sanitize_params(params)
            # Parsing according to https://datatables.net/manual/server-side
            clean = {
              draw: params.require(:draw).to_i,
              start: params.require(:start).to_i,
        Severity: Minor
        Found in app/controllers/concerns/data_table.rb - About 1 hr to fix

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

            errors() {
              const { amount, action, message, peer } = this.state;
              const { peers, user_name, balance, penning } = this.props;
              const errors = {};
          
          
          Severity: Minor
          Found in app/javascript/react/src/components/TransactionForm.jsx - 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 render has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            render() {
              const { step, action, peer } = this.state;
              const { peers, penning } = this.props;
              const errors = this.errors();
          
          
          Severity: Minor
          Found in app/javascript/react/src/components/TransactionForm.jsx - 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 errors has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            errors() {
              const { amount, action, message, peer } = this.state;
              const { peers, user_name, balance, penning } = this.props;
              const errors = {};
          
          
          Severity: Minor
          Found in app/javascript/react/src/components/TransactionForm.jsx - About 1 hr to fix

            Function buttonClass has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              buttonClass(action) {
                const { action: activeAction, penning } = this.props;
                const c = ['inline-flex items-center py-2 px-4 text-sm font-medium focus:outline-none border focus:z-10 focus:ring-4'];
            
                if((penning && (action === ActionType.Take)) || (!penning && (action === ActionType.Request))) {
            Severity: Minor
            Found in app/javascript/react/src/components/TransactionForm.jsx - About 35 mins 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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                @transaction = Transaction.new(transaction_params)
                @transaction.reverse if @transaction.amount.negative?
            
                @transaction = Request.new(@transaction.info) if action_param[:action].to_sym == :request
            Severity: Minor
            Found in app/controllers/transactions_controller.rb - About 35 mins 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 transaction_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def transaction_params
                    t = params.require(:transaction).permit(:debtor, :creditor, :message, :euros, :cents, :id_at_client)
            
                    {
                      debtor: t[:debtor] ? User.find_by(name: t[:debtor]) : User.zeus,
            Severity: Minor
            Found in app/controllers/api/v1/transactions_controller.rb - About 35 mins 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 cancel! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def cancel!
                return unless open?
            
                Notification.create! user: creditor, message: cancelled_message unless issuer == creditor
                Notification.create! user: debtor, message: cancelled_message unless issuer == debtor
            Severity: Minor
            Found in app/models/request.rb - About 25 mins 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

            Severity
            Category
            Status
            Source
            Language