Showing 196 of 196 total issues
Similar blocks of code found in 4 locations. Consider refactoring. Open
public static float[] getArrayColMajorFloat(float[][] matrix, int col, int row)
{
float[] array = new float[row * col];
for (int index=0, i=0; i < col ; i++){
for (int j=0; j < row; j++){
- 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 96.
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 3 locations. Consider refactoring. Open
public static double[][] getMatrixDouble(double[] array, int row, int col)
{
double[][] matrix = new double[row][col];
for (int index=0, i=0; i < row ; i++){
for (int j=0; j < col; j++){
- 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 96.
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 3 locations. Consider refactoring. Open
public static float[][] getMatrixFloat(float[] array, int row, int col)
{
float[][] matrix = new float[row][col];
for (int index=0, i=0; i < row ; i++){
for (int j=0; j < col; j++){
- 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 96.
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 doubly_even_magic
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def doubly_even_magic(nm, shape)
mini_square_num = shape / 4
count = 1
inv_count = shape * shape
shape.times do |row|
- 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 dense_storage_set
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def dense_storage_set(slice, right)
stride = get_stride(self)
v_size = 1
if right.is_a?(NMatrix)
- 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 solve
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def solve(b, opts = {})
raise(ShapeError, "Must be called on square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
raise(ShapeError, "number of rows of b must equal number of cols of self") if
self.shape[1] != b.shape[0]
raise(ArgumentError, "only works with dense matrices") if self.stype != :dense
- 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 transpose
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def transpose(permute = nil)
if permute.nil?
if self.dim == 1
return self.clone
elsif self.dim == 2
- 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 solve
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def solve(b, opts = {})
raise(ShapeError, "Must be called on square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
raise(ShapeError, "number of rows of b must equal number of cols of self") if
self.shape[1] != b.shape[0]
raise(ArgumentError, "only works with dense matrices") if self.stype != :dense
- 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 pow
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def pow n
raise ShapeError, "Only works with 2D square matrices." if
shape[0] != shape[1] or shape.size != 2
raise TypeError, "Only works with integer powers" unless n.is_a?(Integer)
- 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 singly_even_magic
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def singly_even_magic(nm, shape)
half_shape = shape / 2
complementary_pair = (shape - 2) / 4
swap_col = NMatrix.new([shape])
index = 0
Method cblas_syrk
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def cblas_syrk(order, uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
Method lapack_gesdd
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def lapack_gesdd(jobz, m, n, a, lda, s, u, ldu, vt, ldvt, lwork)
Method gemv
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def gemv(a, x, y = nil, alpha = 1.0, beta = 0.0,
transpose_a = false, m = nil, n = nil, lda = nil,
incx = nil, incy = nil)
Method cblas_herk
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def cblas_herk(order, uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
Method solve
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def solve(b, opts = {})
raise(ShapeError, "Must be called on square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
raise(ShapeError, "number of rows of b must equal number of cols of self") if
self.shape[1] != b.shape[0]
raise(ArgumentError, "only works with dense matrices") if self.stype != :dense
Method gemm
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def gemm(a, b, c = nil, alpha = 1.0, beta = 0.0,
transpose_a = false, transpose_b = false, m = nil,
n = nil, k = nil, lda = nil, ldb = nil, ldc = nil)
raise(ArgumentError, 'Expected dense NMatrices as first two arguments.') \
Method solve
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def solve(b, opts = {})
raise(ShapeError, "Must be called on square matrix") unless self.dim == 2 && self.shape[0] == self.shape[1]
raise(ShapeError, "number of rows of b must equal number of cols of self") if
self.shape[1] != b.shape[0]
raise(ArgumentError, "only works with dense matrices") if self.stype != :dense
Method load_coordinate
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def load_coordinate file, converter, dtype, entry_type, symmetry
mat = nil
# Read until we get the dimensions and nonzeros
Method concat
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def concat(*matrices)
rank = nil
rank = matrices.pop unless matrices.last.is_a?(NMatrix)
# Find the first matching dimension and concatenate along that (unless rank is specified)
Method dense_storage_set
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dense_storage_set(slice, right)
stride = get_stride(self)
v_size = 1
if right.is_a?(NMatrix)