Showing 77 of 77 total issues
Similar blocks of code found in 3 locations. Consider refactoring. Open
if $0 == __FILE__
# 検索に使用する最大キーワード数
@cgi = CGI.new
begin
app = Fuwatto::WorldcatApp.new( @cgi )
- Read upRead up
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 75.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method cinii_nrid_search
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def cinii_nrid_search( nrid, opts = {} )
q = URI.escape( nrid )
base_uri = "http://ci.nii.ac.jp/opensearch/nrid/"
cont = nil
cache_file = cache_xml( "cinii_nrid", q, opts[:start] )
- Read upRead up
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 epi_search
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def epi_search( keyword, opts = {} )
base_uri = "http://dl.nier.go.jp/epi"
client_base_uri = "http://dl.nier.go.jp/epi-search/sru-gw.rb"
q = URI.escape( keyword.split.join( " AND " ) )
cont = nil
Method cinii_nrid_search
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cinii_nrid_search( nrid, opts = {} )
q = URI.escape( nrid )
base_uri = "http://ci.nii.ac.jp/opensearch/nrid/"
cont = nil
cache_file = cache_xml( "cinii_nrid", q, opts[:start] )
Method jstage_search
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def jstage_search( keyword, opts = {} )
base_uri = "http://api.jstage.jst.go.jp/searchapi/do"
client_base_uri = "http://www.jstage.jst.go.jp/search/-char/ja?d6=te&typer=on&searchtype=1"
q = URI.escape( keyword )
cont = nil
Method start
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start
now = Time.now
sites.each do |site|
puts site
opts = build_options_hash( conf[ site ] )
Function fuwatto_show_result
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fuwatto_show_result( data ) {
var keywords = document.createElement('div');
keywords.setAttribute('class','fuwatto_keywords');
keywords.style.cssText = 'text-align:right;font-size:smaller';
keywords.appendChild( document.createTextNode( data.q + "\n" ) );
Method opac_hit_u_search
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def opac_hit_u_search( keyword, opts = {} )
require "htmlentities"
base_uri = "https://opac.lib.hit-u.ac.jp/opac/opac_list.cgi"
q = URI.escape( keyword )
opts[ :amode ] = 9 if opts.key?( :key )
- Read upRead up
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_images_search
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def springer_images_search( keyword, opts = {} )
base_uri = "http://api.springer.com/images/xml"
q = CGI.escape( keyword )
cont = nil
cache_file = cache_xml( "springer-images", q )
- Read upRead up
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 dpla_search
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dpla_search( keyword, opts = {} )
base_uri = "http://api.dp.la/v2/items"
q = CGI.escape( keyword )
cont = nil
cache = Cache.new( "dpla" )
Function preview_fuwatto
has 43 lines of code (exceeds 25 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";
Method wikipedia_ja_search
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def wikipedia_ja_search( keyword, opts = {} )
base_uri = "http://ja.wikipedia.org/w/api.php"
q = URI.escape( keyword )
cont = nil
cache_file = cache_xml( "jawikipedia", q, opts[:start] )
Method jstage_search
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def jstage_search( keyword, opts = {} )
base_uri = "http://api.jstage.jst.go.jp/searchapi/do"
client_base_uri = "http://www.jstage.jst.go.jp/search/-char/ja?d6=te&typer=on&searchtype=1"
q = URI.escape( keyword )
cont = nil
- Read upRead up
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 35 lines of code (exceeds 25 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] )
Method dpla_search
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def dpla_search( keyword, opts = {} )
base_uri = "http://api.dp.la/v2/items"
q = CGI.escape( keyword )
cont = nil
cache = Cache.new( "dpla" )
- Read upRead up
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 start
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def start
now = Time.now
sites.each do |site|
puts site
opts = build_options_hash( conf[ site ] )
- Read upRead up
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 30 lines of code (exceeds 25 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?
Method extract_keywords_mecab
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def extract_keywords_mecab( str, opts )
return [] if str.strip.empty?
mecab = MeCab::Tagger.new( '--node-format=%m\t%H\t%c\n --unk-format=%m\tUNK\t%c\n' )
lines = mecab.parse( str.toeuc )
#puts lines
Similar blocks of code found in 2 locations. Consider refactoring. Open
vector[ 0..(terms-1) ].map{|k| k[0] }.combination(2) do |v|
keyword = v.join( " " )
STDERR.puts keyword
data = send( search_method, keyword, search_opts )
if data[ :totalResults ] > 0
- Read upRead up
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 48.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
vector[ 0..(terms-1) ].map{|k| k[0] }.combination(3) do |v|
keyword = v.join( " " )
STDERR.puts keyword
data = send( search_method, keyword, search_opts )
if data[ :totalResults ] > 0
- Read upRead up
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 48.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76