Showing 21 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

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

              { step >= 4 ?
                <Step
                  step={4}
                  title={"Why do you want to " + action.whyDoYouWantToText + " this?"}
                  error={step > 4 ? errors['message'] : void 0}
    Severity: Major
    Found in app/javascript/react/src/components/TransactionForm.jsx and 1 other location - About 3 hrs to fix
    app/javascript/react/src/components/TransactionForm.jsx on lines 447..455

    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

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

              { step >= 2 ?
                <Step
                  step={2}
                  title={"How much do you want to " + action.howMuchDoYouWantToText + "?"}
                  error={step > 2 ? errors['amount'] : void 0}
    Severity: Major
    Found in app/javascript/react/src/components/TransactionForm.jsx and 1 other location - About 3 hrs to fix
    app/javascript/react/src/components/TransactionForm.jsx on lines 465..473

    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

    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

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

          static Give = new ActionType(
            "give",
            "Give money",
            "give",
            "give it to",
        Severity: Major
        Found in app/javascript/react/src/components/TransactionForm.jsx and 2 other locations - About 2 hrs to fix
        app/javascript/react/src/components/TransactionForm.jsx on lines 11..22
        app/javascript/react/src/components/TransactionForm.jsx on lines 23..33

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

        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

          static Take =  new ActionType(
            "take",
            "Take money",
            "take",
            "take it from",
        Severity: Major
        Found in app/javascript/react/src/components/TransactionForm.jsx and 2 other locations - About 2 hrs to fix
        app/javascript/react/src/components/TransactionForm.jsx on lines 23..33
        app/javascript/react/src/components/TransactionForm.jsx on lines 34..44

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

        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

          static Request =  new ActionType(
            "request",
            "Request money",
            "request",
            "request it from",
        Severity: Major
        Found in app/javascript/react/src/components/TransactionForm.jsx and 2 other locations - About 2 hrs to fix
        app/javascript/react/src/components/TransactionForm.jsx on lines 11..22
        app/javascript/react/src/components/TransactionForm.jsx on lines 34..44

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

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

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

          setMessage(m) {
            this.setState({
              message: m
            });
        
        
        Severity: Major
        Found in app/javascript/react/src/components/TransactionForm.jsx and 3 other locations - About 1 hr to fix
        app/javascript/react/src/components/TransactionForm.jsx on lines 292..302
        app/javascript/react/src/components/TransactionForm.jsx on lines 304..314
        app/javascript/react/src/components/TransactionForm.jsx on lines 316..326

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

        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

          setPeer(p) {
            this.setState({
              peer: p
            });
        
        
        Severity: Major
        Found in app/javascript/react/src/components/TransactionForm.jsx and 3 other locations - About 1 hr to fix
        app/javascript/react/src/components/TransactionForm.jsx on lines 292..302
        app/javascript/react/src/components/TransactionForm.jsx on lines 304..314
        app/javascript/react/src/components/TransactionForm.jsx on lines 328..338

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

        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

          setAction(action) {
            this.setState({
              action: action
            });
        
        
        Severity: Major
        Found in app/javascript/react/src/components/TransactionForm.jsx and 3 other locations - About 1 hr to fix
        app/javascript/react/src/components/TransactionForm.jsx on lines 304..314
        app/javascript/react/src/components/TransactionForm.jsx on lines 316..326
        app/javascript/react/src/components/TransactionForm.jsx on lines 328..338

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

        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

          setAmount(a) {
            this.setState({
              amount: a
            });
        
        
        Severity: Major
        Found in app/javascript/react/src/components/TransactionForm.jsx and 3 other locations - About 1 hr to fix
        app/javascript/react/src/components/TransactionForm.jsx on lines 292..302
        app/javascript/react/src/components/TransactionForm.jsx on lines 316..326
        app/javascript/react/src/components/TransactionForm.jsx on lines 328..338

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

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

            Severity
            Category
            Status
            Source
            Language