Showing 37 of 37 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
def tcp_receive_from_client_first_packet n
# check version
version = async_recv(1).unpack("C").first
if version != SOCKS5
raise PharseError, "SOCKS version not supported: #{version.inspect}"
- 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 134.
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. Open
def tcp_receive_from_localbackend_first_packet n
# check version
version = async_recv(1).unpack("C").first
if version != SOCKS5
raise PharseError, "SOCKS version not supported: #{version.inspect}"
- 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 134.
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 execute!
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute!
# here sets default options
options = {
:port => 8388,
:local_addr => '0.0.0.0',
Method execute!
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute!
# here sets default options
options = {
:server => '0.0.0.0',
:port => 8388,
Method bytes_to_key1
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def bytes_to_key1(salt, data, count, nkey, niv)
key = ''
iv = ''
md_buf = ''
- 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 build!
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build! conn
cipher = nil
protocols = @cfg_ary.map do | klass, params|
case klass.to_s
File tls_ticket.rb
has 262 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'lrucache'
module ShadowsocksRuby
module Protocols
# TLS 1.2 Obfuscation Protocol
Method tcp_receive_from_localbackend_first_packet
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def tcp_receive_from_localbackend_first_packet n
data = async_recv 10
if (data =~ /^GET|^POST/) == nil
if @params[:compatible]
@buffer << data << async_recv(n - data.length)
- 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 recv_client_hello
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def recv_client_hello
data = async_recv 3
if data != [CTYPE_Handshake, *VERSION_TLS_1_0].pack("C3")
if @params[:compatible]
@buffer = data
Method recv_client_hello
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def recv_client_hello
data = async_recv 3
if data != [CTYPE_Handshake, *VERSION_TLS_1_0].pack("C3")
if @params[:compatible]
@buffer = data
- 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 tcp_receive_from_localbackend_first_packet
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tcp_receive_from_localbackend_first_packet n
# check version
version = async_recv(1).unpack("C").first
if version != SOCKS5
raise PharseError, "SOCKS version not supported: #{version.inspect}"
Method tcp_receive_from_client_first_packet
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tcp_receive_from_client_first_packet n
# check version
version = async_recv(1).unpack("C").first
if version != SOCKS5
raise PharseError, "SOCKS version not supported: #{version.inspect}"
Similar blocks of code found in 2 locations. Consider refactoring. Open
def tcp_receive_from_remoteserver_in_buffer n
if n == -1
class << self
alias tcp_receive_from_remoteserver tcp_receive_from_remoteserver_other_packet
end
- 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 58.
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. Open
def tcp_receive_from_localbackend_in_buffer n
if n == -1
class << self
alias tcp_receive_from_localbackend tcp_receive_from_localbackend_other_packet
end
- 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 58.
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 tcp_send_to_remoteserver_first_packet
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tcp_send_to_remoteserver_first_packet data
if data.length > 30 + 64
headlen = 30 + Random.rand(64 + 1)
else
headlen = data.length
Method send_client_hello
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send_client_hello
client_hello = ""
client_hello << [*VERSION_TLS_1_2].pack("C2") # ProtocolVersion
client_hello << get_random # Random len 32
Method execute!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def execute!
# here sets default options
options = {
:port => 8388,
:local_addr => '0.0.0.0',
- 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 initialize
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
@options = @@options
@totalcounter = 0
@maxcounter = 0
Method tcp_receive_from_localbackend_first_packet
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tcp_receive_from_localbackend_first_packet n
data = async_recv 10
if (data =~ /^GET|^POST/) == nil
if @params[:compatible]
@buffer << data << async_recv(n - data.length)
Similar blocks of code found in 2 locations. Consider refactoring. Open
def tcp_receive_from_localbackend_other_packet_helper n
if n == -1
return @buffer.slice!(0, @buffer.length)
elsif n < @buffer.length
class << 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 52.
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