yegor256/0pdd

View on GitHub

Showing 28 of 28 total issues

File 0pdd.rb has 491 lines of code (exceeds 250 allowed). Consider refactoring.
Open

$stdout.sync = true

require 'mail'
require 'haml'
require 'json'
Severity: Minor
Found in 0pdd.rb - About 7 hrs to fix

    Method extract_features has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      def extract_features(puzzles, samples = {}, level = 1)
        puzzles = [puzzles] unless puzzles.is_a?(Array)
        puzzles.each do |puzzle|
          next if puzzle.nil?
          prev_puzzle = samples[samples.keys.last]
    Severity: Minor
    Found in model/linear.rb - About 2 hrs 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 interate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def interate(vector, best, perfect, speed)
          if vector == perfect
            out = generate_random_noise_particle
            new_vec = vector + ((best - vector).normalize * 0.2) + (out * rand * 0.05) + (speed * 0.05)
            minimal = @f.f(vector, **@options) > @f.f(new_vec, **@options)
    Severity: Minor
    Found in model/pso/lib/solver.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 proceed has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def proceed
        @job.proceed
      rescue Exception => e
        yaml = @vcs.repo.config
        emails = yaml['errors'] || []
    Severity: Minor
    Found in objects/jobs/job_emailed.rb - About 1 hr to fix

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

        def submit(puzzle)
          submitted = @tickets.submit(puzzle)
          config = @vcs.repo.config
          if config['tickets']&.include?('inherit-milestone') &&
             puzzle.xpath('ticket')[0].text =~ /[0-9]+/
      Severity: Minor
      Found in objects/tickets/milestone_tickets.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 process_request has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def process_request(vcs)
        JobDetached.new(
          vcs,
          JobCommitErrors.new(
            vcs,
      Severity: Minor
      Found in 0pdd.rb - About 1 hr to fix

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

          def run
            c = [
              'set -x',
              'set -e',
              'set -o pipefail',
        Severity: Minor
        Found in objects/exec.rb - About 1 hr to fix

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

            def expose(xml, tickets)
              seen = []
              Kernel.loop do
                puzzles = xml.xpath(
                  [
          Severity: Minor
          Found in objects/puzzles.rb - About 1 hr to fix

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

              def run
                c = [
                  'set -x',
                  'set -e',
                  'set -o pipefail',
            Severity: Minor
            Found in objects/exec.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 summary has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def summary(xml, ticket)
                all = issues(
                  xml,
                  "//puzzle[ticket='#{ticket}']/children//puzzle",
                  "//puzzle[ticket='#{ticket}']"
            Severity: Minor
            Found in objects/diff.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 submit has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def submit(puzzle)
                submitted = @tickets.submit(puzzle)
                config = @vcs.repo.config
                if config['tickets']&.include?('inherit-milestone') &&
                   puzzle.xpath('ticket')[0].text =~ /[0-9]+/
            Severity: Minor
            Found in objects/tickets/milestone_tickets.rb - About 1 hr to fix

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

                def submit(puzzle)
                  issue = @tickets.submit(puzzle)
                  issue_id = issue[:number]
                  yaml = @vcs.repo.config
                  if yaml['tags'].is_a?(Array)
              Severity: Minor
              Found in objects/tickets/tagged_tickets.rb - About 1 hr to fix

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

                  def expose(xml, tickets)
                    seen = []
                    Kernel.loop do
                      puzzles = xml.xpath(
                        [
                Severity: Minor
                Found in objects/puzzles.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 storage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                def storage(repo, vcs)
                  file_name = vcs == 'github' ? repo : "#{vcs}-#{repo}"
                  SyncStorage.new(
                    UpgradedStorage.new(
                      SafeStorage.new(
                Severity: Minor
                Found in 0pdd.rb - About 1 hr to fix

                  Method solve has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def solve(precision: 100, threads: 1, debug: false)
                        n_iterations = 0
                        Array.new(threads).map do
                          Thread.new do
                            ((precision / @swarm.size) / threads).times do |_interation_number|
                  Severity: Minor
                  Found in model/pso/lib/solver.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 summary has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def summary(xml, ticket)
                      all = issues(
                        xml,
                        "//puzzle[ticket='#{ticket}']/children//puzzle",
                        "//puzzle[ticket='#{ticket}']"
                  Severity: Minor
                  Found in objects/diff.rb - About 1 hr to fix

                    Method extract_features has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def extract_features(puzzles, samples = {}, level = 1)
                        puzzles = [puzzles] unless puzzles.is_a?(Array)
                        puzzles.each do |puzzle|
                          next if puzzle.nil?
                          prev_puzzle = samples[samples.keys.last]
                    Severity: Minor
                    Found in model/linear.rb - About 1 hr to fix

                      Method title has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def title(puzzle)
                          yaml = @vcs.repo.config
                          format = []
                          format += yaml['format'].map(&:strip).map(&:downcase) if !yaml.nil? && yaml['format'].is_a?(Array)
                          len = format.find { |i| i =~ /title-length=\d+/ }
                      Severity: Minor
                      Found in objects/tickets/tickets.rb - About 55 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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def initialize(ocket, bucket, region, key, secret)
                      Severity: Minor
                      Found in model/storage.rb - About 35 mins to fix

                        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          def initialize(ocket, bucket, region, key, secret)
                        Severity: Minor
                        Found in objects/storage/s3.rb - About 35 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language