File string.rb
has 1595 lines of code (exceeds 1000 allowed). Consider refactoring. Open
require 'corelib/comparable'
require 'corelib/regexp'
class ::String < `String`
include ::Comparable
Method tr_s
has 149 lines of code (exceeds 30 allowed). Consider refactoring. Open
def tr_s(from, to)
%x{
from = $coerce_to(from, #{::String}, 'to_str').$to_s();
to = $coerce_to(to, #{::String}, 'to_str').$to_s();
Method tr
has 130 lines of code (exceeds 30 allowed). Consider refactoring. Open
def tr(from, to)
%x{
from = $coerce_to(from, #{::String}, 'to_str').$to_s();
to = $coerce_to(to, #{::String}, 'to_str').$to_s();
Method split
has 77 lines of code (exceeds 30 allowed). Consider refactoring. Open
def split(pattern = undefined, limit = undefined)
%x{
if (self.length === 0) {
return [];
}
Method next
has 67 lines of code (exceeds 30 allowed). Consider refactoring. Open
def next
%x{
var i = self.length;
if (i === 0) {
return '';
Method []
has 66 lines of code (exceeds 30 allowed). Consider refactoring. Open
def [](index, length = undefined)
%x{
var size = self.length, exclude, range;
if (index.$$is_range) {
Method gsub
has 61 lines of code (exceeds 30 allowed). Consider refactoring. Open
def gsub(pattern, replacement = undefined, &block)
%x{
if (replacement === undefined && block === nil) {
return #{enum_for :gsub, pattern};
}
Method to_i
has 51 lines of code (exceeds 30 allowed). Consider refactoring. Open
def to_i(base = 10)
%x{
var result,
string = self.toLowerCase(),
radix = $coerce_to(base, #{::Integer}, 'to_int');
Method sub
has 40 lines of code (exceeds 30 allowed). Consider refactoring. Open
def sub(pattern, replacement = undefined, &block)
%x{
if (!pattern.$$is_regexp) {
pattern = $coerce_to(pattern, #{::String}, 'to_str');
pattern = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
Method index
has 39 lines of code (exceeds 30 allowed). Consider refactoring. Open
def index(search, offset = undefined)
%x{
var index,
match,
regex;
Method oct
has 37 lines of code (exceeds 30 allowed). Consider refactoring. Open
def oct
%x{
var result,
string = self,
radix = 8;
Method rindex
has 35 lines of code (exceeds 30 allowed). Consider refactoring. Open
def rindex(search, offset = undefined)
%x{
var i, m, r, _m;
if (offset === undefined) {
Method each_line
has 35 lines of code (exceeds 30 allowed). Consider refactoring. Open
def each_line(separator = $/, chomp: false, &block)
return enum_for :each_line, separator, chomp: chomp unless block_given?
%x{
if (separator === nil) {
Method upto
has 35 lines of code (exceeds 30 allowed). Consider refactoring. Open
def upto(stop, excl = false, &block)
return enum_for :upto, stop, excl unless block_given?
%x{
var a, b, s = self.toString();
Method rpartition
has 32 lines of code (exceeds 30 allowed). Consider refactoring. Open
def rpartition(sep)
%x{
var i, m, r, _m;
if (sep.$$is_regexp) {
Similar blocks of code found in 2 locations. Consider refactoring. Invalid
width = `$coerce_to(#{width}, #{::Integer}, 'to_int')`
padstr = `$coerce_to(#{padstr}, #{::String}, 'to_str')`.to_s
if padstr.empty?
::Kernel.raise ::ArgumentError, 'zero width padding'
- 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 33.
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. Invalid
def ljust(width, padstr = ' ')
width = `$coerce_to(#{width}, #{::Integer}, 'to_int')`
padstr = `$coerce_to(#{padstr}, #{::String}, 'to_str')`.to_s
if padstr.empty?
- 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 33.
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. Invalid
if (from.length == 0 || from === to) {
return self;
}
- 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 33.
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. Invalid
if (from.length == 0) {
return self;
}
- 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 33.
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