Showing 176 of 176 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
def exec_prepared(*args, &blk)
return exec_prepared_without_profiling(*args, &blk) unless SqlPatches.should_measure?
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
result = exec_prepared_without_profiling(*args, &blk)
- 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 53.
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 send_query_prepared(*args, &blk)
return send_query_prepared_without_profiling(*args, &blk) unless SqlPatches.should_measure?
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
result = send_query_prepared_without_profiling(*args, &blk)
- 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 53.
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 getClientTimings
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
getClientTimings: function getClientTimings(clientTimings) {
var list = [];
var t;
if (!clientTimings.timings) return [];
Function f
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function f(c) {
if (c.charAt(0) !== "\\") return c.charCodeAt(0);
switch (c.charAt(1)) {
case "b":
Method push_snapshot
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def push_snapshot(page_struct, group_name, config)
@snapshots_lock.synchronize do
group = @snapshot_groups[group_name]
if !group
@snapshot_groups[group_name] = {
Function f
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function f(c) {
if (c.charAt(0) !== "\\") return c.charCodeAt(0);
switch (c.charAt(1)) {
case "b":
Method initialize
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(args = nil)
args ||= {}
@path = args[:path]
@expires_in_seconds = args[:expires_in] || EXPIRES_IN_SECONDS
raise ArgumentError.new :path unless @path
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (timing.children) {
for (var i = 0; i < timing.children.length; i++) {
countSql(timing.children[i]);
}
}
- 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 57.
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
if (timing.children) {
for (var i = 0; i < timing.children.length; i++) {
addToResults(timing.children[i]);
}
}
- 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 57.
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 allowed_tokens
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def allowed_tokens
token_info = @client.get("#{@prefix}-tokens")
key1, key2, cycle_at = nil
- 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 get_profile_script
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_profile_script(env, response_headers = {})
path = public_base_path(env)
version = MiniProfiler::ASSET_VERSION
if @config.assets_url
url = @config.assets_url.call('rack-mini-profiler.js', version, env)
- 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 flamegraph
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def flamegraph(graph, path, env)
headers = { 'Content-Type' => 'text/html' }
iframe_src = "#{public_base_path(env)}speedscope/index.html"
html = <<~HTML
<!DOCTYPE html>
Function send
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
XMLHttpRequest.prototype.send = function(data) {
ajaxStartTime = new Date();
this.addEventListener("load", function() {
// responseURL isn't available in IE11
if (
Method cleanup_corrupt_snapshots
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cleanup_corrupt_snapshots(corrupt_snapshots_ids, group_name)
group_hash_key = group_snapshot_hash_key(group_name)
group_zset_key = group_snapshot_zset_key(group_name)
overview_zset_key = snapshot_overview_zset_key
lua = <<~LUA
Function l
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function l(c) {
for (var d = c.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)", "g")), a = d.length, k = [], e = 0, h = 0; e < a; ++e) {
var g = d[e];
if (g === "(") ++h;else if ("\\" === g.charAt(0)) if ((g = +g.substring(1)) && g <= h) k[g] = -1;
}
Method take_snapshot
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def take_snapshot(env, start)
MiniProfiler.create_current(env, @config)
Thread.current[:mp_ongoing_snapshot] = true
results = @app.call(env)
status = results[0].to_i
Function l
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function l(c) {
for (var d = c.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)", "g")), a = d.length, k = [], e = 0, h = 0; e < a; ++e) {
var g = d[e];
if (g === "(") ++h;else if ("\\" === g.charAt(0)) if ((g = +g.substring(1)) && g <= h) k[g] = -1;
}
Consider simplifying this complex logical expression. Open
} else if (popup.style.display === "block") {
hidePopup =
isEscPress ||
(e.type == "click" &&
!(popup !== e.target && popup.contains(e.target)) &&
Consider simplifying this complex logical expression. Open
if (bg && bg.style.display === "block") {
hideQueries =
isEscPress ||
(e.type == "click" &&
!(queries !== e.target && queries.contains(e.target)) &&
Method serve_profile_memory
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def serve_profile_memory(env, client_settings)
return tool_disabled_message(client_settings) if !advanced_debugging_enabled?
unless defined?(MemoryProfiler) && MemoryProfiler.respond_to?(:report)
message = "Please install the memory_profiler gem and require it: add gem 'memory_profiler' to your Gemfile"
- 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"