Showing 1,379 of 1,379 total issues
Identical blocks of code found in 15 locations. Consider refactoring. Open
const vueLifecycles = singleSpaVue({
Vue,
appOptions: {
router,
store,
- 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 67.
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 15 locations. Consider refactoring. Open
const vueLifecycles = singleSpaVue({
Vue,
appOptions: {
router,
store,
- 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 67.
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 copy
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function copy(acediff, e, dir) {
const diffIndex = parseInt(e.target.getAttribute('data-diff-index'), 10)
const diff = acediff.diffs[diffIndex]
let sourceEditor
let targetEditor
Function diff
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff() {
const dmp = new diff_match_patch()
const val1 = this.editors.left.ace.getSession().getValue()
const val2 = this.editors.right.ace.getSession().getValue()
// Main diff method that calculates the diffs
Function __init__
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(
self,
write_port,
read_port,
write_timeout,
Function __init__
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(self):
self.state = "DISCONNECTED"
self.target_names = []
self.cmd_target_names = []
self.tlm_target_names = []
Method create_telemetry
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_telemetry(xml, telemetry, target_name)
# Gather and make unique all the packet items
unique_items = telemetry[target_name] ? get_unique(telemetry[target_name]) : {}
xml['xtce'].TelemetryMetaData do
Method start_listen_thread
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def start_listen_thread(port, listen_write = false, listen_read = false)
# Create a socket to accept connections from clients
addr = Socket.pack_sockaddr_in(port, @listen_address)
if RUBY_ENGINE == 'ruby'
listen_socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
Method protocol_cmd
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def protocol_cmd(cmd_name, *cmd_args, read_write: :READ_WRITE, index: -1)
read_write = read_write.to_s.upcase.intern
raise "Unknown protocol descriptor: #{read_write}. Must be :READ, :WRITE, or :READ_WRITE." unless [:READ, :WRITE, :READ_WRITE].include?(read_write)
handled = false
Method initialize
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(write_port,
read_port,
write_timeout,
read_timeout,
protocol_type = nil,
Method write_item
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def write_item(item, value, buffer)
item_name = item.name
case item_name
when 'HTTP_STATUS'
@packet.extra ||= {}
Method call
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(log, _appender = nil)
#<SemanticLogger::Log:0x0000ffffa5002b20 @level=:info, @thread_name="puma srv tp 001", @name="MicroservicesController",
# @time=2024-09-22 18:04:27.955490052 +0000, @tags=[], @named_tags={}, @level_index=2, @message="Completed #traefik",
# @payload={:controller=>"MicroservicesController", :action=>"traefik", :format=>"HTML", :method=>"GET",
# :path=>"/openc3-api/traefik", :status=>200, :view_runtime=>0.41, :allocations=>1438, :status_message=>"OK",
Method _limits_group
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _limits_group(group_name, action:, manual:, scope:, token:)
authorize(permission: 'tlm_set', manual: manual, scope: scope, token: token)
group_name.upcase!
group = get_limits_groups(scope: scope, token: token)[group_name]
raise "LIMITS_GROUP #{group_name} undefined. Ensure your telemetry definition contains the line: LIMITS_GROUP #{group_name}" unless group
Method multi_create
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def multi_create
return unless authorization('script_run')
input_activities = params.to_unsafe_h.slice(:multi).to_h['multi']
unless input_activities.is_a?(Array)
render json: { status: 'error', message: 'invalid input, must be json list/array' }, status: 400
Method file_thread_body
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def file_thread_body(objects)
topics, offsets, item_objects_by_topic, packet_objects_by_topic = @collection.topics_offsets_and_objects
results = []
# This will read out packets until nothing is left
Function patch_addPadding
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff_match_patch.prototype.patch_addPadding = function (patches) {
var paddingLength = this.Patch_Margin
var nullPadding = ''
for (var x = 1; x <= paddingLength; x++) {
nullPadding += String.fromCharCode(x)
Function getSingleDiffInfo
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getSingleDiffInfo(editor, offset, diffString) {
const info = {
startLine: 0,
startChar: 0,
endLine: 0,
Function diff_linesToChars_
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff_match_patch.prototype.diff_linesToChars_ = function (text1, text2) {
var lineArray = [] // e.g. lineArray[4] == 'Hello\n'
var lineHash = {} // e.g. lineHash['Hello\n'] == 4
// '\x00' is a valid character, but various debuggers don't like it.
Function diff_main
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff_match_patch.prototype.diff_main = function (
text1,
text2,
opt_checklines,
opt_deadline,
Method identify
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def identify(packet_data, target_names = nil)
identified_packet = nil
target_names = target_names() unless target_names