Showing 90 of 90 total issues
Class Dimensions
has 60 methods (exceeds 20 allowed). Consider refactoring. Open
class Dimensions
include Common::Inspect
attr_reader :parent, :x_dimension, :y_dimension
protected :parent # we shall not mess with parent,see #495
Class Slot
has 47 methods (exceeds 20 allowed). Consider refactoring. Open
class Slot < Common::UIElement
include Common::Clickable
include Common::Hover
# We need that offset because otherwise element overlap e.g. occupy
Class App
has 44 methods (exceeds 20 allowed). Consider refactoring. Open
class App
include Common::Container
include Common::Clickable
attr_reader :dsl, :real, :shell, :click_listener
Class Dimension
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
class Dimension
attr_reader :parent
attr_accessor :absolute_start
protected :parent # we shall not mess with parent,see #495
Class InternalApp
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
class InternalApp
include Common::Clickable
include Common::Style
include Common::SafelyEvaluate
include DimensionsDelegations
Method start_packaging
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def start_packaging
pictures
stack width: 600, margin_left: 200, margin_top: 170 do
@mac = package_check("Mac")
@windows = package_check("Windows")
- 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
File expert_tankspank.rb
has 334 lines of code (exceeds 250 allowed). Consider refactoring. Open
WIDTH = 700
HEIGHT = 500
CAMERA_TIGHTNESS = 0.1
module Collisions
Method initialize_backend
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.initialize_backend
return if defined?(@initialized) && @initialized
@initialized = true
::Shoes.configuration.backend = :swt
Class Field
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Field
CELL_SIZE = 20
COLORS = %w[#00A #0A0 #A00 #004 #040 #400 #000].freeze
class Cell
Method draw_board
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def draw_board
clear do
background black
draw_player_1
stack margin: 10 do
- 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
File slot.rb
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Shoes
class Slot < Common::UIElement
include Common::Clickable
include Common::Hover
Class Shape
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Shape < Common::ArtElement
attr_reader :blk, :x, :y, :left_bound, :top_bound, :right_bound, :bottom_bound
style_with :art_styles, :center, :common_styles, :dimensions
STYLES = { fill: Shoes::COLORS[:black] }.freeze
File app.rb
has 289 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Shoes
module Swt
shoes_icon = ::Shoes::ICON
if shoes_icon.include? 'uri:classloader'
ICON = File.join(Dir.tmpdir, 'shoes-icon.png').freeze
Class TextSegmentCollection
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class TextSegmentCollection
extend Forwardable
def_delegators :@segments, :length, :last, :inject,
:one?, :any?, :empty?
Method run
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def run(str)
obj = nil
@io << str
@io.rewind
l = lex
- 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
File dimensions.rb
has 265 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Shoes
# Dimensions is a central class that most Shoes classes use to represent their
# dimensions, e.g. where they are and how much space they are taking up there.
# All the different position types might be confusing. So here is a little list:
#
File expert_othello.rb
has 264 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Othello
PIECE_WIDTH = 62
PIECE_HEIGHT = 62
TOP_OFFSET = 47
LEFT_OFFSET = 12
Class Shoes
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Shoes
module Common
module Style
DEFAULT_STYLES = {
rotate: 0,
Class Fitter
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Fitter
attr_reader :parent
def initialize(text_block, current_position)
@text_block = text_block
Similar blocks of code found in 2 locations. Consider refactoring. Open
20.times do |i|
current_size = 50 + size
d = to_radians(i * 30 - degree)
rx = Math.cos(d) * 150
ry = Math.sin(d) * 150
- 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 81.
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