enwords/enwords

View on GitHub

Showing 10 of 16 total issues

Function initQtip has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function initQtip() {
    $selectedWord.qtip({
      position: {
        my: 'bottom left',
        at: 'top right',
Severity: Major
Found in app/assets/javascripts/translate.js - About 3 hrs to fix

    Function text has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            text: function(event, api) {
              $.ajax({
                url: '/api/web/translations',
                data: {
                  word: $(this).text(),
    Severity: Major
    Found in app/assets/javascripts/translate.js - About 2 hrs to fix

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

        def update_with_password(params, *options)
          current_password = params.delete(:current_password)
      
          if params[:password].blank?
            params.delete(:password)
      Severity: Minor
      Found in app/models/user.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 text has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def text
            result = "*#{word.value}*"
            result << ' '
            result << "_[#{word_transcription}]_ " if word_transcription.present?
      
      
      Severity: Minor
      Found in app/services/sentence/by_word.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 execute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def execute
            unless word
              tr = yandex_translate
              return tr ? { translation: tr, text: text, youglish: youglish, sound_url: sound_url, from: from, to: to } : nil
            end
      Severity: Minor
      Found in app/services/word/translate.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 process_word has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_word
            unless word
              return I18n.t('telegram.process_message.only_one_word', locale: :ru) if clean_text.split(' ').size > 1
      
              return I18n.t('telegram.process_message.go_premium', locale: :ru) unless telegram_chat_user.premium?
      Severity: Minor
      Found in app/services/telegram/process_message.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 update_trans has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_trans(trans)
            return unless word && trans
            return if word.data&.dig('trans', to)
      
            data = word.data || {}
      Severity: Minor
      Found in app/services/word/translate.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

      Method build_get_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_get_response(url, params = {})
            uri       = URI(url)
            uri.query = URI.encode_www_form(params)
            response  = Net::HTTP.get_response(uri)
            response  = Net::HTTP.get_response(URI.parse(response.header['location'])) if response.code == '301'
      Severity: Minor
      Found in app/services/api/skyeng.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

      Method execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def execute
            result =
              if status
                case status
                when 'learning' then learning
      Severity: Minor
      Found in app/services/word/by_status.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

      Method update_word_status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_word_status
            return unless telegram_chat
      
            if word && word.language == telegram_chat_user.learning_language
              Word::UpdateState.run(ids: [word.id], to_state: 'learning', user: telegram_chat_user)
      Severity: Minor
      Found in app/services/telegram/process_message.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