Showing 177 of 177 total issues
File website_agent.rb
has 655 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'nokogiri'
require 'date'
module Agents
class WebsiteAgent < Agent
Method validate_extract_options!
has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring. Open
def validate_extract_options!
extraction_type = begin
extraction_type()
rescue StandardError
extraction_type(options)
- 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 import
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def import(options = {})
success = true
guid = parsed_data['guid']
description = parsed_data['description']
name = parsed_data['name']
- 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 extract_xml
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def extract_xml(doc)
extract_each { |extraction_details, values|
case
when css = extraction_details['css']
nodes = doc.css(css)
- 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 control!
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def control!
control_targets.each do |target|
interpolate_with('target' => target) do
case action = control_action
when 'run'
- 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 validate_options
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def validate_options
# Check for required fields
begin
if !options['url'].include?('{{')
url = interpolated['url']
- 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 validate_extract_options!
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate_extract_options!
extraction_type = begin
extraction_type()
rescue StandardError
extraction_type(options)
Method convert_hash
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def self.convert_hash(hash, options={})
options = {:merge_path_attributes => false, :leading_dollarsign_is_jsonpath => false}.merge options
keys_to_remove = []
hash.tap do |hash|
hash.each_pair do |key, value|
- 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
Function handleDryRunButton
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
static handleDryRunButton(button, data) {
if (data == null) {
data = button.form
? $(':input[name!="_method"]', button.form).serialize()
: "";
Similar blocks of code found in 2 locations. Consider refactoring. Open
return graph.vis
.append("svg:line")
.attr("x1", graph.x(minX))
.attr("x2", graph.x(maxX))
.attr("y1", graph.y(mean + 3 * standard_deviation))
- 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 106.
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
graph.vis
.append("svg:line")
.attr("x1", graph.x(minX))
.attr("x2", graph.x(maxX))
.attr("y1", graph.y(mean + 2 * standard_deviation))
- 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 106.
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
File agent-edit-page.js
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
(function () {
let formatAgentForSelect = undefined;
const Cls = (this.AgentEditPage = class AgentEditPage {
static initClass() {
formatAgentForSelect = function (agent) {
Function initializeFormCompletable
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
return (window.initializeFormCompletable = function () {
$("input[role~=validatable], select[role~=validatable]").on(
"change",
(e) => {
const form_data = getFormData(e.currentTarget);
Function check
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
var check = function () {
const query = sinceId != null ? "?since_id=" + sinceId : "";
return $.getJSON("/worker_status" + query, function (json) {
for (var method of ["pending", "awaiting_retry", "recent_failures"]) {
var count = json[method];
Class AgentsController
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class AgentsController < ApplicationController
include DotHelper
include ActionView::Helpers::TextHelper
include SortableTable
Method validate_options
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def validate_options
unless options['post_url'].present?
errors.add(:base, "post_url is a required field")
end
- 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
Function constructor
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
this.invokeDryRun = this.invokeDryRun.bind(this);
$("#agent_source_ids").on("change", this.showEventDescriptions);
this.showCorrectRegionsOnStartup();
$("form.agent-form").on("submit", () => this.updateFromEditors());
Class WebsiteAgent
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class WebsiteAgent < Agent
include WebRequestConcern
can_dry_run!
can_order_created_events!
Method receive_web_request
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def receive_web_request(request)
# check the secret
secret = request.path_parameters[:secret]
return ["Not Authorized", 401] unless secret == interpolated['secret']
- 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 receive
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def receive(incoming_events)
incoming_events.each do |event|
interpolate_with(event) do
post_params = {}
- 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"