Showing 1,379 of 1,379 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
put: function (
path,
{ data, params, headers = fullDefaultHeaders, noScope, noAuth } = {}
) {
return request('put', path, { data, params, headers, noScope, noAuth })
- 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 82.
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
Function patch_fromText
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff_match_patch.prototype.patch_fromText = function (textline) {
var patches = []
if (!textline) {
return patches
}
Method deploy_microservices
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def deploy_microservices(gem_path, variables, system)
command_topic_list = []
decom_command_topic_list = []
packet_topic_list = []
decom_topic_list = []
Method handle_packet
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_packet(packet)
if packet.stored
# Stored telemetry does not update the current value table
identified_packet = System.telemetry.identify_and_define_packet(packet, @interface.tlm_target_names)
else
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!noAuth) {
try {
let refreshed = await OpenC3Auth.updateToken(
OpenC3Auth.defaultMinValidity
)
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!noAuth) {
try {
let refreshed = await OpenC3Auth.updateToken(
OpenC3Auth.defaultMinValidity
)
- 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
Method unsegment_packet
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def unsegment_packet(packet)
@ccsds_packet.buffer = packet.buffer
previous_sequence_count = @sequence_count
@sequence_count = @ccsds_packet.read('CcsdsSeqcnt')
Function __init__
has 18 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Method _openc3_script_wait_implementation
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _openc3_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate, exp_to_eval, scope: $openc3_scope, token: $openc3_token, &block)
end_time = Time.now.sys + timeout
if exp_to_eval and !exp_to_eval.is_printable?
raise "ERROR: Invalid comparison to non-ascii value"
end
Method create
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create(overlap: true)
if @recurring['end'] and @recurring['frequency'] and @recurring['span']
# First validate the initial recurring activity ... all others are just offsets
validate_input(start: @start, stop: @stop, kind: @kind, data: @data)
Method dynamic_update
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dynamic_update(packets, cmd_or_tlm = :TELEMETRY, filename = "dynamic_tlm.txt")
# Build hash of targets/packets
packet_hash = {}
packets.each do |packet|
target_name = packet.target_name.upcase
Method define
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def define(item)
# Handle Overwriting Existing Item
if @items[item.name]
item_index = nil
@sorted_items.each_with_index do |sorted_item, index|
Method syntax
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.syntax(filename, text)
language = detect_language(text, filename)
if language == 'ruby'
check_process = IO.popen('ruby -c -rubygems 2>&1', 'r+')
check_process.write("require 'openc3'; require 'openc3/script'; " + text)
Method start_service
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start_service(hostname = nil, port = nil, object = nil, max_threads = 1000)
server_started = false
@server_mutex.synchronize do
server_started = true if @server
end
Method from_json
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.from_json(hash)
# Convert strings to symbols
endianness = hash['endianness'] ? hash['endianness'].intern : nil
data_type = hash['data_type'] ? hash['data_type'].intern : nil
overflow = hash['overflow'] ? hash['overflow'].intern : nil
Method monitor
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def monitor
processes_to_delete = []
cleanup_time = Time.now
while true
current_time = Time.now
Method install_phase1
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.install_phase1(gem_file_path, existing_variables: nil, existing_plugin_txt_lines: nil, process_existing: false, scope:, validate_only: false)
gem_name = File.basename(gem_file_path).split("__")[0]
temp_dir = Dir.mktmpdir
tf = nil
Method set_min_max_default
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_min_max_default(item, type, data_type)
return unless @current_cmd_or_tlm == PacketConfig::COMMAND
# Need to set min, max, and default
if data_type == :INT || data_type == :UINT
Method reduce_to_single_packet
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reduce_to_single_packet
# Discard sync pattern if present
if @sync_pattern
if @reduction_state == :START
return :STOP if @data.length < @sync_pattern.length
Method instrumented
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.instrumented(filename, text)
language = detect_language(text, filename)
if language == 'ruby'
return {
'title' => 'Instrumented Script',