CLOSER-Cohorts/archivist

View on GitHub

Showing 219 of 2,583 total issues

Method V3_2 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def V3_2(seq_id)
      if seq_id.is_a? ::CcSequence
        cc = seq_id
      else
        cc = ::CcSequence.find seq_id
Severity: Minor
Found in lib/exporters/xml/ddi/cc_sequence.rb - About 1 hr to fix

Method all has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def all
    instruments = Rails.cache.fetch('instruments.json&#{auth_token}', version: Instrument.maximum(:updated_at).to_i) do
      connection = ActiveRecord::Base.connection
      sql = %|
              SELECT instruments.id, instruments.agency, instruments.version, instruments.prefix, instruments.label, instruments.slug, instruments.study, instruments.signed_off, COUNT(DISTINCT(control_constructs.id)) as ccs, COUNT(DISTINCT(qv_mappings.id)) as qvs
Severity: Minor
Found in app/services/instruments/serializer.rb - About 1 hr to fix

Method perform has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def perform(id)
    begin
      exp = Exporters::XML::DDI::InstrumentComplete.new
      exp.add_root_attributes
      i = ::Instrument.find(id)
Severity: Minor
Found in app/jobs/export_job.rb - About 1 hr to fix

Function generateButtons has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const generateButtons = (node, path) => {
    var buttons = []
    if (canHaveChildren(node)) {
      const newNode = {
        title: `Click to select construct type`,
Severity: Minor
Found in react/src/pages/InstrumentConstructBuild.js - About 1 hr to fix

Method perform has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def perform(id)
    begin
      exp = Exporters::XML::DDI::Instrument.new
      exp.add_root_attributes
      i = ::Instrument.find(id)
Severity: Minor
Found in app/jobs/export_job.rb - About 1 hr to fix

Method find_nearest_parent has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def find_nearest_parent(target_class)
    columns = ['id', 'parent_id', 'construct_id', 'construct_type']
    columns_joined = columns.join(',')
    sql =
      <<-SQL
Severity: Minor
Found in app/models/control_construct.rb - About 1 hr to fix

Function find has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    find: (type, id) => {
      if (type === 'CcLoop') {
        item = get(cc_loops, id.toString(), {})
        item.type = 'loop'
      }
Severity: Minor
Found in react/src/pages/InstrumentConstructBuild.js - About 1 hr to fix

Method V3_2 has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def V3_2(qc_id)
      if qc_id.is_a? ::CcQuestion
        cc = qc_id
      else
        cc = ::CcQuestion.find qc_id
Severity: Minor
Found in lib/exporters/xml/ddi/cc_question.rb - About 1 hr to fix

Method format_output_hash has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def format_output_hash(variables)
    vars = get_variables
    questions = get_questions(variables.map{|v|v["questions"]}.flatten.uniq)
    topics = get_topics(variables.map{|v|v["sources_topic"]}.flatten.uniq + variables.map{|v|v["topic"]}.flatten.uniq)

Severity: Minor
Found in app/services/variables/serializer.rb - About 1 hr to fix

Function statuses has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const statuses = (state = {}, action) => {

  var key;

  switch (action.type) {
Severity: Minor
Found in react/src/reducers/index.js - About 55 mins to fix

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 V3_2 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def V3_2(qitem_id)
      @klass = ::QuestionItem

      super do |qitem, qi|
        build_response_domain = lambda do |rd|
Severity: Minor
Found in lib/exporters/xml/ddi/question_item.rb - About 55 mins to fix

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 update_question has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def update_question(object, &block)
    if block.call object
      if params.has_key? :instruction
        object.instruction = params[:instruction]
        object.save!
Severity: Minor
Found in app/controllers/question_controller.rb - About 55 mins to fix

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 ObjectFinder has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const ObjectFinder = (instrumentId, type, id) => {
  const sequences = useSelector(state => state.cc_sequences);
  const cc_sequences = get(sequences, instrumentId, {})
  const statements = useSelector(state => state.cc_statements);
  const cc_statements = get(statements, instrumentId, {})
Severity: Minor
Found in react/src/pages/InstrumentView.js - About 45 mins to fix

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

Avoid deeply nested control flow statements.
Open

              if(params.subtype === 'question_items'){
                  crumbs.push(
                      {
                        text: 'Question Items',
                        link: url(routes.instruments.instrument.build.questionItems.all, { instrument_id: instrumentId })
Severity: Major
Found in react/src/components/BreadcrumbBar.js - About 45 mins to fix

Function ObjectFinder has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const ObjectFinder = (instrumentId, type, id) => {
  const sequences = useSelector(state => state.cc_sequences);
  const cc_sequences = get(sequences, instrumentId, {})
  const statements = useSelector(state => state.cc_statements);
  const cc_statements = get(statements, instrumentId, {})
Severity: Minor
Found in react/src/pages/InstrumentMap.js - About 45 mins to fix

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 CcQuestionForm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const CcQuestionForm = (props) => {
  const {ccQuestion, instrumentId, onChange, path, onDelete, onCreate} = props;

  const questions = useSelector(state => state.cc_questions);
  const cc_questions = get(questions, instrumentId, {})
Severity: Minor
Found in react/src/components/CcQuestionForm.js - About 45 mins to fix

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 AuthButton has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const AuthButton = (props)  => {

  const isAuthUser = useSelector(state => state.auth.isAuthUser);
  const user = useSelector(state => get(state.auth, 'user'));

Severity: Minor
Found in react/src/components/AuthButton.js - About 45 mins to fix

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 association_stats has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def association_stats
    key = self.class.name + self.id.to_s + 'counts'
    begin
      counts = $redis.get key
    rescue Redis::CannotConnectError
Severity: Minor
Found in app/models/application_record.rb - About 45 mins to fix

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

Avoid deeply nested control flow statements.
Open

            if (label = child.at_xpath('./Label/Content')).nil?
              cc_q.label = label
            else
              cc_q.label = 'Missing label'
            end
Severity: Major
Found in lib/importers/xml/ddi/instrument.rb - About 45 mins to fix

Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(thing, options)
      if thing.is_a? String
        @doc = open(thing) { |f| Importers::TXT::TabDelimited.new(f) }
      else
        document = ::Document.find thing
Severity: Minor
Found in lib/importers/txt.rb - About 45 mins to fix

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

Severity
Category
Status
Source
Language