yegor256/0rsk

View on GitHub

Showing 13 of 26 total issues

Method notify_all has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def notify_all
  users.fetch.each do |login|
    next unless telechats.wired?(login)
    chat = telechats.chat_of(login)
    fresh = telepings.fresh(login)
Severity: Minor
Found in front/front_telegram.rb - About 3 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 query has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def query(id, query)
    where = []
    words = []
    unless id.positive?
      query.strip.downcase.split.each do |w|
Severity: Minor
Found in objects/triples.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 query has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def query(id, query)
    where = []
    words = []
    unless id.positive?
      query.strip.downcase.split.each do |w|
Severity: Major
Found in objects/triples.rb - About 2 hrs to fix

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

    $stdout.sync = true
    
    require 'glogin'
    require 'glogin/codec'
    require 'haml'
    Severity: Minor
    Found in 0rsk.rb - About 2 hrs to fix

      Method reply has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def reply(msg, login)
        case msg
        when %r{^/done$}
          left = tasks(login: login).fetch(limit: 100)
          if left.empty?
      Severity: Minor
      Found in front/front_telegram.rb - About 1 hr to fix

        Method task_list has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def task_list(list)
          if list.count < 8
            [
              'Here is a full list of them:',
              list.map do |t|
        Severity: Minor
        Found in front/front_telegram.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

        Function auto has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function auto(kind, uri) {
          "use strict";
          var $input = $("#" + kind);
          $input.on("input", function() {
            $("#" + kind + "_detach").addClass("red");
        Severity: Minor
        Found in js/triple.js - About 1 hr to fix

          Method query has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def query(query)
              Rsk::Query.new(
                @pgsql,
                [
                  'SELECT * FROM (SELECT DISTINCT ON (task.id) task.id, task.plan,',
          Severity: Minor
          Found in objects/tasks.rb - About 1 hr to fix

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

            def reply(msg, login)
              case msg
              when %r{^/done$}
                left = tasks(login: login).fetch(limit: 100)
                if left.empty?
            Severity: Minor
            Found in front/front_telegram.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 task_list has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def task_list(list)
              if list.count < 8
                [
                  'Here is a full list of them:',
                  list.map do |t|
            Severity: Minor
            Found in front/front_telegram.rb - About 1 hr to fix

              Method notify_all has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def notify_all
                users.fetch.each do |login|
                  next unless telechats.wired?(login)
                  chat = telechats.chat_of(login)
                  fresh = telepings.fresh(login)
              Severity: Minor
              Found in front/front_telegram.rb - About 1 hr to fix

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

                  def delete(id)
                    @pgsql.transaction do |t|
                      triple = fetch(id: id.to_i)[0]
                      raise Rsk::Urror, "Triple ##{id} not found in your project ##{@project}" if triple.nil?
                      if t.exec('SELECT * FROM part WHERE id = $1 AND project = $2', [triple[:cid], @project]).empty?
                Severity: Minor
                Found in objects/triples.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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def process_request(chat, message)
                  login = telechats.login_of(chat)
                  response = begin
                    reply(message.text, login)
                  rescue StandardError => e
                Severity: Minor
                Found in front/front_telegram.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