Showing 5 of 8 total issues

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

      def run
        # The goal here is to automatically find  the optimal C and gamma values
        # for a Gaussian SVM kernel. Currently an 80-line method 'script' that could benefit from some refactoring, comparing with 'run_with_c_and_gamma' not very 'dry'. Also with bigger data could do with plenty of optimization. Cover with tests and measure performance first.

        # Adapted from: https://github.com/daugaard/example-svm
Severity: Major
Found in app/models/machine_learning/strategies/svm.rb - About 2 hrs to fix

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

          def run
            # The goal here is to automatically find  the optimal C and gamma values
            # for a Gaussian SVM kernel. Currently an 80-line method 'script' that could benefit from some refactoring, comparing with 'run_with_c_and_gamma' not very 'dry'. Also with bigger data could do with plenty of optimization. Cover with tests and measure performance first.
    
            # Adapted from: https://github.com/daugaard/example-svm
    Severity: Minor
    Found in app/models/machine_learning/strategies/svm.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 run_with_c_and_gamma has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def run_with_c_and_gamma(predicted_c, predicted_gamma)
            # The goal here is to automatically find  the optimal C and gamma values
            # for a Gaussian SVM kernel
    
            # Adapted from: https://github.com/daugaard/example-svm
    Severity: Minor
    Found in app/models/machine_learning/strategies/svm.rb - About 1 hr to fix

      Method call has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def call
          context.incoming_message = context.message.get_command_for(context.bot)
          return if context.message.location
          if context&.incoming_message&.split(" ")[0].downcase == 'signup'
            if User.where(friendly_name: context.message.from.username).count > 0
      Severity: Minor
      Found in app/interactors/signup_user.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 call has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def call
          context.incoming_message = context.message.get_command_for(context.bot)
          return if context.message.location
          if context&.incoming_message&.split(" ")[0].downcase == 'signup'
            if User.where(friendly_name: context.message.from.username).count > 0
      Severity: Minor
      Found in app/interactors/signup_user.rb - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language