Showing 56 of 88 total issues
Function EditableInput
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
const EditableInput = props => {
const [editing, setEditing] = useState(false);
const [submitting, setSubmitting] = useState(false);
const [inputValue, setInputValue] = useState(props.value);
const [error, setError] = useState('');
Function withLoading
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
const withLoading = Component => {
const Subcomponent = ({
fetchFn,
resultPath,
renameData,
Method create_arf
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self.create_arf(asset, proxy, params)
arf_report = nil
policy = Policy.find_by :id => params[:policy_id]
return unless policy
- 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
Class ArfReport
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class ArfReport < ::Report
include Taxonomix
include OpenscapProxyExtensions
# attr_accessible :host_id, :reported_at, :status, :metrics
Method prepended
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.prepended(base)
base.has_one :asset, :as => :assetable, :class_name => "::ForemanOpenscap::Asset", :dependent => :destroy
base.has_many :asset_policies, :through => :asset, :class_name => "::ForemanOpenscap::AssetPolicy"
base.has_many :policies, :through => :asset_policies, :class_name => "::ForemanOpenscap::Policy"
base.has_many :arf_reports, :class_name => '::ForemanOpenscap::ArfReport', :foreign_key => :host_id
Method process_policy
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def process_policy(policy)
reports_of_policy = ForemanOpenscap::ArfReport.unscoped
.of_policy(policy)
.order("#{ForemanOpenscap::ArfReport.table_name}.created_at DESC")
latest = reports_of_policy.first
- 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 upload_from_files
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def upload_from_files(files_array, from_scap_guide = false)
unless files_array.is_a? Array
@result.errors.push(_("Expected an array of files to upload, got: %s.") % files_array)
return @result
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
Method create_arf
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_arf(asset, proxy, params)
arf_report = nil
policy = Policy.find_by :id => params[:policy_id]
return unless policy
Method find_multiple
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def find_multiple
if params.key?(:host_names) || params.key?(:host_ids) || multiple_with_filter?
@hosts = Host.search_for(params[:search]) if multiple_with_filter?
@hosts ||= Host.merge(Host.where(id: params[:host_ids]).or(Host.where(name: params[:host_names])))
if @hosts.empty?
- 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 withDelete
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
const withDelete = Component => {
const Subcomponent = ({
confirmDeleteTitle,
submitDelete,
prepareMutation,
Function EditableInput
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
const EditableInput = props => {
const [editing, setEditing] = useState(false);
const [submitting, setSubmitting] = useState(false);
const [inputValue, setInputValue] = useState(props.value);
const [error, setError] = useState('');
- 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 ConfirmModal
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
const ConfirmModal = props => {
const [callMutation, { loading }] = props.prepareMutation();
const actions = [
<Button
Method find_resources_before_create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def find_resources_before_create
policy_id = params[:policy_id].to_i
unless ForemanOpenscap::Policy.where(:id => policy_id).any?
upload_fail(_("Policy with id %s not found.") % policy_id)
- 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 fieldWithHandlers
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const fieldWithHandlers = Component => {
const Subcomponent = ({ label, form, field, isRequired, ...rest }) => {
const fieldProps = wrapFieldProps(field);
const valid = shouldValidate(form, field.name);
Method upload_from_files
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upload_from_files(files_array, from_scap_guide = false)
unless files_array.is_a? Array
@result.errors.push(_("Expected an array of files to upload, got: %s.") % files_array)
return @result
end
Method validate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate(data_stream_content)
return unless data_stream_content.scap_file_changed?
content_type = data_type(data_stream_content)
- 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 withLoading
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const withLoading = Component => {
const Subcomponent = ({
fetchFn,
resultPath,
renameData,
- 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 find_resources_before_create
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_resources_before_create
policy_id = params[:policy_id].to_i
unless ForemanOpenscap::Policy.where(:id => policy_id).any?
upload_fail(_("Policy with id %s not found.") % policy_id)
Method validate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate(data_stream_content)
return unless data_stream_content.scap_file_changed?
content_type = data_type(data_stream_content)
Method submit_or_cancel_policy
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def submit_or_cancel_policy(form, overwrite = nil, args = {})
args[:cancel_path] ||= send("#{controller_name}_path")
content_tag(:div, :class => "clearfix") do
content_tag(:div, :class => "form-actions") do
text = overwrite ? overwrite : _("Submit")
- 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"