qomoteam/qomo

View on GitHub

Showing 97 of 97 total issues

File scholar.py has 851 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#! /usr/bin/env python
"""
This module provides classes for querying Google Scholar and parsing
returned results. It currently *only* processes the first results
page. It is not a recursive crawler.
Severity: Major
Found in scripts/scholar.py - About 2 days to fix

    File rails.validations.js has 634 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    
    /*!
     * Client Side Validations - v5.0.0 (https://github.com/DavyJonesLocker/client_side_validations)
     * Copyright (c) 2016 Geremia Taglialatela, Brian Cardarella
     * Licensed under MIT (http://opensource.org/licenses/mit-license.php)
    Severity: Major
    Found in app/assets/javascripts/rails.validations.js - About 1 day to fix

      File jquery.raty.js has 574 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*!
       * jQuery Raty - A Star Rating Plugin
       *
       * The MIT License
       *
      Severity: Major
      Found in app/assets/javascripts/jquery.raty.js - About 1 day to fix

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

          def submit(job_name, boxes, conns)
            job_id = SecureRandom.uuid
            job = Job.new id: job_id, user_id: @user_id, name: job_name
        
            result = {
        Severity: Minor
        Found in app/services/job_engine.rb - About 1 day 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 main has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
        Open

        def main():
            usage = """scholar.py [options] <query string>
        A command-line interface to Google Scholar.
        
        Examples:
        Severity: Minor
        Found in scripts/scholar.py - About 6 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

        Function _parse_article has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
        Open

            def _parse_article(self, div):
                self.article = ScholarArticle()
        
                for tag in div:
                    if not hasattr(tag, 'name'):
        Severity: Minor
        Found in scripts/scholar.py - About 5 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

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

                  if (ref = element.val(), indexOf.call((function() {
                    var i, len, ref1, results;
                    ref1 = options["in"];
                    results = [];
                    for (i = 0, len = ref1.length; i < len; i++) {
        Severity: Major
        Found in app/assets/javascripts/rails.validations.js and 1 other location - About 4 hrs to fix
        app/assets/javascripts/rails.validations.js on lines 420..431

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

        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

                  if (ref = element.val(), indexOf.call((function() {
                    var i, len, ref1, results;
                    ref1 = options["in"];
                    results = [];
                    for (i = 0, len = ref1.length; i < len; i++) {
        Severity: Major
        Found in app/assets/javascripts/rails.validations.js and 1 other location - About 4 hrs to fix
        app/assets/javascripts/rails.validations.js on lines 451..462

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

        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 submit has 112 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def submit(job_name, boxes, conns)
            job_id = SecureRandom.uuid
            job = Job.new id: job_id, user_id: @user_id, name: job_name
        
            result = {
        Severity: Major
        Found in app/services/job_engine.rb - About 4 hrs to fix

          Function _parse_links has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              def _parse_links(self, span):
                  for tag in span:
                      if not hasattr(tag, 'name'):
                          continue
                      if tag.name != 'a' or tag.get('href') is None:
          Severity: Minor
          Found in scripts/scholar.py - 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

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

              SCHOLAR_QUERY_URL = ScholarConf.SCHOLAR_SITE + '/scholar?' \
                  + 'as_q=%(words)s' \
                  + '&as_epq=%(phrase)s' \
                  + '&as_oq=%(words_some)s' \
                  + '&as_eq=%(words_none)s' \
          Severity: Major
          Found in scripts/scholar.py and 1 other location - About 3 hrs to fix
          scripts/scholar.py on lines 881..890

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

          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

              SET_SETTINGS_URL = ScholarConf.SCHOLAR_SITE + '/scholar_setprefs?' \
                  + 'q=' \
                  + '&scisig=%(scisig)s' \
                  + '&inststart=0' \
                  + '&as_sdt=1,5' \
          Severity: Major
          Found in scripts/scholar.py and 1 other location - About 3 hrs to fix
          scripts/scholar.py on lines 715..724

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

          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 _parse_article has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              def _parse_article(self, div):
                  self.article = ScholarArticle()
          
                  for tag in div:
                      if not hasattr(tag, 'name'):
          Severity: Minor
          Found in scripts/scholar.py - 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

          Function input has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              input: function(input) {
                var $form, $input, binding, event, form, ref;
                $input = $(input);
                form = input.form;
                $form = $(form);
          Severity: Major
          Found in app/assets/javascripts/rails.validations.js - About 2 hrs to fix

            Method filetree has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

              def filetree
                dir = params[:dir]
                if !dir.blank?
                  username = dir.split(':')[0][1..-1]
                  path = dir.split(':')[1..-1].join('/')
            Severity: Minor
            Found in app/controllers/library_controller.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 rating_for has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def rating_for(rateable_obj, dimension=nil, options={})
            
                cached_average = rateable_obj.average dimension
                avg = cached_average ? cached_average.avg : 0
            
            
            Severity: Major
            Found in app/helpers/ratyrate_helper.rb - About 2 hrs to fix

              Class ToolsController has 22 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class ToolsController < ApplicationController
              
                before_action :authenticate_user!, except: [:index, :search, :show]
              
                def index
              Severity: Minor
              Found in app/controllers/tools_controller.rb - About 2 hrs to fix

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

                                if hasattr(tag, 'string') and tag.string.startswith('All '):
                                    self.article['num_versions'] = \
                                        self._as_int(tag.string.split()[1])
                Severity: Major
                Found in scripts/scholar.py and 1 other location - About 2 hrs to fix
                scripts/scholar.py on lines 429..431

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

                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

                                if hasattr(tag, 'string') and tag.string.startswith('Cited by'):
                                    self.article['num_citations'] = \
                                        self._as_int(tag.string.split()[-1])
                Severity: Major
                Found in scripts/scholar.py and 1 other location - About 2 hrs to fix
                scripts/scholar.py on lines 450..452

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

                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 read has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def read(path, offset, len)
                    File.open(path) do |file|
                      offset ||= 0
                      len ||= 10.kilobytes
                      content = ''
                Severity: Minor
                Found in app/services/reader/text_reader.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

                Severity
                Category
                Status
                Source
                Language