masao/fuwatto

View on GitHub

Showing 77 of 77 total issues

File fuwatto.rb has 1512 lines of code (exceeds 250 allowed). Consider refactoring.
Open

$:.unshift "."

require "net/http"
require "net/https"
#require "pp"
Severity: Major
Found in fuwatto.rb - About 4 days to fix

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

          def execute( search_method, terms, opts = {} )
             data = {}
             opts[ :use_df ] = true if not opts.has_key?( :use_df )
             opts[ :prf_alpha ] = PRF_ALPHA if opts[ :prf ] and not opts.has_key?( :prf_alpha )
             prev_time = nil
    Severity: Minor
    Found in fuwatto.rb - About 2 days 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

       def cinii_research_search( keyword, opts = {} )
          base_uri = "https://cir.nii.ac.jp/opensearch/all"
          q = URI.escape( keyword )
          cont = nil
          cache_file = cache_xml( "cinii_r", q, opts[:start] )
    Severity: Major
    Found in fuwatto.rb and 1 other location - About 1 day to fix
    fuwatto.rb on lines 284..341

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

    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

       def cinii_search( keyword, opts = {} )
          base_uri = "http://ci.nii.ac.jp/opensearch/search"
          q = URI.escape( keyword )
          cont = nil
          cache_file = cache_xml( "cinii", q, opts[:start] )
    Severity: Major
    Found in fuwatto.rb and 1 other location - About 1 day to fix
    fuwatto.rb on lines 344..401

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

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

          def execute( search_method, terms, opts = {} )
             data = {}
             opts[ :use_df ] = true if not opts.has_key?( :use_df )
             opts[ :prf_alpha ] = PRF_ALPHA if opts[ :prf ] and not opts.has_key?( :prf_alpha )
             prev_time = nil
    Severity: Major
    Found in fuwatto.rb - About 1 day to fix

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

      function display_feed_as_examples( result )
      {
        if (!result.error){
          var container = document.getElementById("feed");
          var htmlstr = "<h3>Examples from Google News</h3><ul>";
      Severity: Major
      Found in default.js and 1 other location - About 6 hrs to fix
      default.js on lines 22..34

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

      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

      function display_feed_mainichi_opinion( result )
      {
        if (!result.error){
          var container = document.getElementById("feed_mainichi_opinion");
          var htmlstr = "<h3>検索例: 毎日新聞/社説・オピニオン</h3><ul>";
      Severity: Major
      Found in default.js and 1 other location - About 6 hrs to fix
      default.js on lines 9..21

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

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

         def ndl_search( keyword, opts = {} )
            base_uri = "http://api.porta.ndl.go.jp/servicedp/opensearch"
            q = URI.escape( keyword )
            cont = nil
            cache_file = cache_xml( "ndl", q, opts[:start] )
      Severity: Minor
      Found in fuwatto.rb - About 4 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 analyse has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.analyse(html, opt=nil)
          require "nkf"
          html = NKF.nkf("-w", html)
      
          # frameset or redirect
      Severity: Minor
      Found in extractcontent.rb - About 4 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 iss_ndl_search has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

         def iss_ndl_search( keyword, opts = {} )
            base_uri = "http://iss.ndl.go.jp/api/opensearch"
            q = URI.escape( keyword )
            cont = nil
            cache_file = cache_xml( "ndl", q, opts[:start] )
      Severity: Minor
      Found in fuwatto.rb - About 4 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 crd_search2 has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

         def crd_search2( keyword, opts = {} )
            base_uri = "http://api.porta.ndl.go.jp/servicedp/opensearch"
            q = URI.escape( keyword )
            cont = nil
            cache_file = cache_xml( "crd2", q, opts[:start] )
      Severity: Minor
      Found in fuwatto.rb - About 4 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 springer_metadata_search has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

         def springer_metadata_search( keyword, opts = {} )
            base_uri = "http://api.springer.com/metadata/pam"
            q = URI.escape( keyword )
            cont = nil
            cache_file = cache_xml( "springer", q, opts[:start] )
      Severity: Minor
      Found in fuwatto.rb - About 4 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

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

            entries.each do |e|
               title = e.find( "./xhtml:head/pam:article/dc:title", xmlns )[0].content 
               url = e.find( "./xhtml:head/pam:article/prism:url", xmlns )[0].content
               author = e.find( "./xhtml:head/pam:article/dc:creator", xmlns ).to_a.map{|au| au.content }.join( "; " )
               pubname = e.find( "./xhtml:head/pam:article/prism:publicationName", xmlns )[0].content
      Severity: Major
      Found in fuwatto.rb and 1 other location - About 3 hrs to fix
      fuwatto.rb on lines 1330..1356

      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

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

            entries.each do |e|
               title = e.find( "./xhtml:head/pam:article/dc:title", xmlns )[0].content 
               url = e.find( "./xhtml:head/pam:article/prism:url", xmlns )[0].content
               author = e.find( "./xhtml:head/pam:article/dc:creator", xmlns ).to_a.map{|au| au.content }.join( "; " )
               pubname = e.find( "./xhtml:head/pam:article/prism:publicationName", xmlns )[0].content
      Severity: Major
      Found in fuwatto.rb and 1 other location - About 3 hrs to fix
      fuwatto.rb on lines 1213..1239

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

         def iss_ndl_search( keyword, opts = {} )
            base_uri = "http://iss.ndl.go.jp/api/opensearch"
            q = URI.escape( keyword )
            cont = nil
            cache_file = cache_xml( "ndl", q, opts[:start] )
      Severity: Major
      Found in fuwatto.rb - About 3 hrs to fix

        Method ndl_search has 97 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

           def ndl_search( keyword, opts = {} )
              base_uri = "http://api.porta.ndl.go.jp/servicedp/opensearch"
              q = URI.escape( keyword )
              cont = nil
              cache_file = cache_xml( "ndl", q, opts[:start] )
        Severity: Major
        Found in fuwatto.rb - About 3 hrs to fix

          Method crd_search2 has 87 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

             def crd_search2( keyword, opts = {} )
                base_uri = "http://api.porta.ndl.go.jp/servicedp/opensearch"
                q = URI.escape( keyword )
                cont = nil
                cache_file = cache_xml( "crd2", q, opts[:start] )
          Severity: Major
          Found in fuwatto.rb - About 3 hrs to fix

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

               def cinii_search( keyword, opts = {} )
                  base_uri = "http://ci.nii.ac.jp/opensearch/search"
                  q = URI.escape( keyword )
                  cont = nil
                  cache_file = cache_xml( "cinii", q, opts[:start] )
            Severity: Minor
            Found in fuwatto.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 cinii_research_search has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

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

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

            if $0 == __FILE__
               # 検索に使用する最大キーワード数
               @cgi = CGI.new
               begin
                  app = Fuwatto::CRDApp.new( @cgi )
            Severity: Major
            Found in crd.rb and 5 other locations - About 3 hrs to fix
            cinii.rb on lines 24..54
            cinii_r.rb on lines 24..54
            dpla.rb on lines 34..64
            ja-wikipedia.rb on lines 28..59
            springer.rb on lines 34..64

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

            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

            Severity
            Category
            Status
            Source
            Language