Showing 1,243 of 1,243 total issues
Method has too many lines. [32/10] Open
def get_role(role)
case role
when VILLAGER
'Warga Kampung'
when GREEDY_VILLAGER
- 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.
Assignment Branch Condition size for protect_players is too high. [37.87/15] Open
def protect_players
self.with_lock(wait: true) do
ss = self.protectee
LycantululBot.log(ss.to_s)
self.update_attribute(:protectee, [])
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [32/10] Open
def get_task(role)
case role
when VILLAGER
"Diam menunggu kematian. Seriously. Tapi bisa bantu-bantu yang lain lah sumbang suara buat bunuh para serigala, sekalian berdoa biar dilindungi sama #{self.get_role(PROTECTOR)} kalo ada"
when GREEDY_VILLAGER
- 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. [31/10] Open
def send(message, text, reply: nil, html: nil, keyboard: nil, async: true)
options = {
chat_id: message.chat.id,
text: text[0...4000],
}
- 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. [29/10] Open
def summon(game, who)
if (Time.now - game.last_summon_query rescue 11).ceil > 10
to_call =
case who
when :all
- 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. [29/10] Open
def finish(stats: true)
self.with_lock(wait: true) do
self.update_attribute(:finished, true)
if stats
self.players.each do |pl|
- 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.
Assignment Branch Condition size for start is too high. [33.27/15] Open
def self.start
Telegram::Bot::Client.run($token) do |bot|
bot.listen do |message|
Lycantulul::InputProcessorJob.perform_async(message, bot)
end
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [28/10] Open
def list_players
liv_count = self.living_players.count
ded_count = self.dead_players.count
res = "Masi idup: <b>#{liv_count} makhluk</b>\n"
- 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.
Assignment Branch Condition size for finish is too high. [32.2/15] Open
def finish(stats: true)
self.with_lock(wait: true) do
self.update_attribute(:finished, true)
if stats
self.players.each do |pl|
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for check_round_finished is too high. [31.56/15] Open
def check_round_finished(game, round, force = false)
log("checking round finished #{round}")
game.reload
return unless round == game.round && game.night? && !game.waiting? && !game.discussion? && !game.finished?
log('continuing')
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for perform is too high. [31.97/15] Open
def perform(bot, options)
retry_count = 0
begin
bot.api.send_message(options)
rescue Faraday::TimeoutError => e
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for perform is too high. [31.97/15] Open
def perform(bot, options)
retry_count = 0
begin
bot.api.send_message(options)
rescue Faraday::TimeoutError => e
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [25/10] Open
def raise_the_dead
self.with_lock(wait: true) do
ss = self.necromancee
LycantululBot.log(ss.to_s)
self.update_attribute(:necromancee, [])
- 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.
Block has too many lines. [61/25] Open
self.with_lock(wait: true) do
vc = self.sort(victim)
hhost = self.homeless_host
LycantululBot.log(vc.to_s)
self.update_attribute(:victim, [])
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Method has too many lines. [24/10] Open
def statistics
res = "Statistik <b>#{self.full_name}</b>\n"
res += "\n"
res += "Main <b>#{self.game}</b>\n"
res += "Bertahan hidup <b>#{self.percentage(self.survived)}</b>\n"
- 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. [23/10] Open
def self.start
Telegram::Bot::Client.run($token) do |bot|
bot.listen do |message|
Lycantulul::InputProcessorJob.perform_async(message, bot)
end
- 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.
Assignment Branch Condition size for enlighten_seer is too high. [28.88/15] Open
def enlighten_seer
self.with_lock(wait: true) do
ss = self.seen
LycantululBot.log(ss.to_s)
self.update_attribute(:seen, [])
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Perceived complexity for kill_victim is too high. [20/7] Open
def kill_victim
self.with_lock(wait: true) do
vc = self.sort(victim)
hhost = self.homeless_host
LycantululBot.log(vc.to_s)
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Assignment Branch Condition size for role_valid? is too high. [27.82/15] Open
def role_valid?
ww_count_valid =
if self.custom_roles && ((ww = self.custom_roles[WEREWOLF]) || (sww = self.custom_roles[SUPER_WEREWOLF]))
val = true
wwc = ww > 0 rescue true
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Similar blocks of code found in 2 locations. Consider refactoring. Open
class MessageQueueJob
include SuckerPunch::Job
def perform(bot, options)
retry_count = 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 99.
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