masao/fuwatto

View on GitHub

Showing 77 of 77 total issues

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

      def load_robots_txt
         robots = []
         open("robots.txt") do |io|
       io.each do |line|
         if line =~ /\A\s*User\-Agent\:\s*(.+?)\Z/i
Severity: Minor
Found in fuwatto.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 worldcat_search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

   def worldcat_search( keyword, opts = {} )
      base_uri = "http://worldcat.org/webservices/catalog/search/opensearch"
      q = URI.escape( keyword )
      cont = nil
      cache_file = cache_xml( "worldcat", q, opts[:start] )
Severity: Minor
Found in fuwatto.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 9 (exceeds 5 allowed). Consider refactoring.
Open

      def execute( method = :cinii_author_search, terms = TERMS, opts = {} )
         opts[ :reranking ] = true
         opts[ :combination ] = true
         data = super( :cinii_search, terms, opts )
         return data if data.empty?
Severity: Minor
Found in cinii-author.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

Avoid deeply nested control flow statements.
Open

                        search_opts[ :key ] = data[ :opac_hit_u_key ] if data[ :opac_hit_u_key ]
Severity: Major
Found in fuwatto.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if data[ :itemsPerPage ]
                               start += data[ :itemsPerPage ]
                            else
                               start += count
                            end
    Severity: Major
    Found in fuwatto.rb - About 45 mins to fix

      Method cinii_author_nrid_search has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

         def cinii_author_nrid_search( name, naid = [] )
            data = cinii_author_search( name )
            result = data
            if not naid.empty?
               entries = []
      Severity: Minor
      Found in fuwatto.rb - About 45 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

      Avoid deeply nested control flow statements.
      Open

                  if search_method == :dpla_search
                     search_opts[ :page ] = start / count
                  else
                                 search_opts[ :start ] = start
                  end
      Severity: Major
      Found in fuwatto.rb - About 45 mins to fix

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

              if File.exist?( cache_file ) and ( Time.now - File.mtime( cache_file ) ) < CACHE_TIME
                 cont = open( cache_file ){|io| io.read }
              else
                 response = http_get( uri )
                 cont = response.body
        Severity: Minor
        Found in fuwatto.rb and 1 other location - About 35 mins to fix
        fuwatto.rb on lines 825..831

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

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

        function seltab(bpref, hpref, id_max, selected) {
          if (! document.getElementById) return;
          for (i = 0; i <= id_max; i++) {
            if (! document.getElementById(bpref + i)) continue;
            if (i == selected) {
        Severity: Minor
        Found in seltab.js - 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 cinii_author_search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

           def cinii_author_search( keyword, opts = {} )
              base_uri = "http://ci.nii.ac.jp/opensearch/author"
              q = URI.escape( keyword )
              cont = nil
              cache_file = cache_xml( "cinii_author", q, opts[:start] )
        Severity: Minor
        Found in fuwatto.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

        Function preview_fuwatto has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        function preview_fuwatto()
        {
          // Build a preview format:
          var form = document.forms[0];
          var url = "http://www.asahi.com/paper/editorial.html";
        Severity: Minor
        Found in widget-helper.js - 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

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

              if File.exist?( cache_file ) and ( Time.now - File.mtime( cache_file ) ) < CACHE_TIME
                 cont = open( cache_file ){|io| io.read }
              else
                 response = http_get( uri )
                 cont = response.body
        Severity: Minor
        Found in fuwatto.rb and 1 other location - About 35 mins to fix
        fuwatto.rb on lines 1110..1116

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

        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

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

                 if date and date[0]
                    date = date[0].content
                 else
                    date = e.find( "./dcterms:modified", "http://purl.org/dc/terms/" )
                    if date and date[0]
        Severity: Minor
        Found in fuwatto.rb and 2 other locations - About 25 mins to fix
        fuwatto.rb on lines 570..579
        fuwatto.rb on lines 676..685

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

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

              def output( prefix, data = {} )
                 #STDERR.puts data.inspect
                 case format
                 when "html"
                    result = eval_rhtml( "./#{ prefix }.rhtml", binding ) if query? and not data.has_key?( :error )
        Severity: Minor
        Found in fuwatto.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

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

                 if date and date[0]
                    date = date[0].content
                 else
                    date = e.find( "./dcterms:modified", "http://purl.org/dc/terms/" )
                    if date and date[0]
        Severity: Minor
        Found in fuwatto.rb and 2 other locations - About 25 mins to fix
        fuwatto.rb on lines 570..579
        fuwatto.rb on lines 770..779

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

        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

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

                 if date and date[0]
                    date = date[0].content
                 else
                    date = e.find( "./dcterms:modified", "http://purl.org/dc/terms/" )
                    if date and date[0]
        Severity: Minor
        Found in fuwatto.rb and 2 other locations - About 25 mins to fix
        fuwatto.rb on lines 676..685
        fuwatto.rb on lines 770..779

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

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

           def http_get( uri, limit = 10 )
              #STDERR.puts uri.to_s
              raise "Too many redirects: #{ uri }" if limit < 0
              http_proxy = ENV[ "http_proxy" ]
              proxy, proxy_port = nil
        Severity: Minor
        Found in fuwatto.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