Showing 1,379 of 1,379 total issues
Method build
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build
klass = OpenC3.require_class(@config_params[0])
if @config_params.length > 1
interface_or_router = klass.new(*@config_params[1..-1])
else
Method format_seconds
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.format_seconds(seconds)
result = ""
mm, ss = seconds.divmod(60)
hh, mm = mm.divmod(60)
dd, hh = hh.divmod(24)
Method setup_open_telemetry
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.setup_open_telemetry(service_name, support_rails = false)
if ENV['OTEL_EXPORTER_OTLP_ENDPOINT']
split_services = ENV['OPENC3_OTEL'].to_s.split(',')
@otel_enabled = true if split_services.include?(service_name) or split_services.include?('ALL')
Method mark_stopped
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def mark_stopped
@state = :stopped
OpenC3::Store.publish([SCRIPT_API, "running-script-channel:#{@id}"].compact.join(":"), JSON.generate({ type: :line, filename: @current_filename, line_no: @current_line_number, state: @state }))
if OpenC3::SuiteRunner.suite_results
OpenC3::SuiteRunner.suite_results.complete
Method handle_log_entry
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_log_entry(log_entry)
log_entry_time = log_entry["time"].to_i
# Filter based on start_time
return nil if @start_time and log_entry_time < @start_time
Similar blocks of code found in 2 locations. Consider refactoring. Open
def critical_cmd_approve(uuid, scope: $openc3_scope)
begin
endpoint = "/openc3-api/criticalcmd/approve/#{uuid}"
response = $api_server.request('post', endpoint, :json => true, scope: scope)
if response.nil? || response.status != 200
- 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 54.
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
when 16
if data_type == :INT
if endianness == HOST_ENDIANNESS
value = buffer[lower_bound..upper_bound].unpack(PACK_NATIVE_16_BIT_INT_ARRAY)
else # endianness != HOST_ENDIANNESS
- 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 54.
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
when 32
if data_type == :INT
if endianness == HOST_ENDIANNESS
value = buffer[lower_bound..upper_bound].unpack(PACK_NATIVE_32_BIT_INT_ARRAY)
else # endianness != HOST_ENDIANNESS
- 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 54.
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 critical_cmd_reject(uuid, scope: $openc3_scope)
begin
endpoint = "/openc3-api/criticalcmd/reject/#{uuid}"
response = $api_server.request('post', endpoint, :json => true, scope: scope)
if response.nil? || response.status != 200
- 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 54.
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 decorate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function decorate(acediff) {
clearGutter(acediff)
clearArrows(acediff)
acediff.diffs.forEach((info, diffIndex) => {
Function __init__
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(self, name, is_plugin=False):
self.shutdown_complete = False
if name is None:
raise RuntimeError("Microservice must be named")
Function redis_metrics
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def redis_metrics(cls):
result = {}
metrics = Store.info("all")
result["redis_connected_clients_total"] = metrics["connected_clients"]
Method _wait_packet
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _wait_packet(check,
target_name,
packet_name,
num_packets,
timeout,
Method plugin_install_phase2
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def plugin_install_phase2(plugin_hash, update: false, scope: $openc3_scope)
response_body = nil
begin
plugin_name = plugin_hash['name']
if update
Method update_converted_hour_day_stats
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_converted_hour_day_stats(packet, reduced, state)
# Update statistics for this packet's converted values
state.converted_max_values.each do |key, value|
if value
max_key = "#{key}__CX"
Method initialize
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(filename, archive: nil)
if archive
time = Time.now.sys
timestamp = sprintf("%04u_%02u_%02u_%02u_%02u_%02u", time.year, time.month, time.mday, time.hour, time.min, time.sec)
# If archive is true we use the system LOGS path
Method plugin_install_phase1
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def plugin_install_phase1(file_path, update: false, existing_plugin_name: nil, scope: $openc3_scope)
response_body = nil
begin
if update
endpoint = "/openc3-api/plugins/#{existing_plugin_name}?scope=#{scope}"
Method decom_packet
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def decom_packet(_topic, msg_id, msg_hash, _redis)
OpenC3.in_span("decom_packet") do
msgid_seconds_from_epoch = msg_id.split('-')[0].to_i / 1000.0
delta = Time.now.to_f - msgid_seconds_from_epoch
@metric.set(name: 'decom_topic_delta_seconds', value: delta, type: 'gauge', unit: 'seconds', help: 'Delta time between data written to stream and decom start')
Method write_packet
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def write_packet(packet)
# Make sure we are past the initial data dropping period
if @initial_read_delay and @initial_read_delay_needed and @connect_complete_time and Time.now < @connect_complete_time
delay_needed = @connect_complete_time - Time.now
sleep(delay_needed) if delay_needed > 0
Method redis_metrics
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.redis_metrics
result = {}
metrics = OpenC3::Store.info("all")
result['redis_connected_clients_total'] = metrics['connected_clients']