lib/site_linking.rb
Method has too many lines. [18/10] Open
Open
def error_linking_site
set_kete_net_urls
top_message = I18n.t('site_linking_lib.error_linking_site.error_occured')
site_listing
if @site_listing.blank?
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [15/10] Open
Open
def site_listing
check_nessesary_constants_set
set_kete_net_urls
@site_listing = nil
SiteLinkingResource.find(:all, params: { url: SystemSetting.full_site_url }).each do |link|
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method site_listing
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def site_listing
check_nessesary_constants_set
set_kete_net_urls
@site_listing = nil
SiteLinkingResource.find(:all, params: { url: SystemSetting.full_site_url }).each do |link|
- 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
Use the return of the conditional for variable assignment and comparison. Open
Open
if @site_listing.nil?
@site_listing = ''
else
@site_listing = "#{@kete_sites}/#{@site_listing['id']}"
end
- Exclude checks
Use the return of the conditional for variable assignment and comparison. Open
Open
if @site_listing.blank?
top_message += I18n.t(
'site_linking_lib.error_linking_site.manual_linking',
new_kete_site: @new_kete_site
)
- Exclude checks