CLOSER-Cohorts/archivist

View on GitHub

Showing 219 of 2,583 total issues

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

    def read_response_domain(node)
      if node.name == 'CodeDomain'
      cl = ::CodeList.find_by_identifier(
        'urn',
        extract_urn_identifier(node.at_xpath('./CodeListReference'))
Severity: Minor
Found in lib/importers/xml/ddi/question.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

          rescue
            cc_c.logic = ''
Severity: Major
Found in lib/importers/xml/ddi/instrument.rb - About 45 mins to fix

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

    def parse
      hash = {}
      matchers = { question_item: './QuestionItem', category: './Category', code_list: './CodeList', instruction: './Instruction'}

      @node.xpath('//Fragment').each do | n |
Severity: Minor
Found in lib/importers/xml/ddi/fragment_instance.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

        elsif child.name == 'Loop'

          cc_l = CcLoop.new(urn: extract_urn_identifier(child))
          @instrument.cc_loops << cc_l
          start_node = child.at_xpath('./InitialValue/Command/CommandContent')
Severity: Major
Found in lib/importers/xml/ddi/instrument.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

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

Avoid deeply nested control flow statements.
Open

          rescue
            cc_c.literal = 'Missing text'
Severity: Major
Found in lib/importers/xml/ddi/instrument.rb - About 45 mins to fix

Consider simplifying this complex logical expression.
Open

  if(!isEmpty(topicId)) {
    variableOptions = variableOptions.filter(opt => {
      return (
        get(opt.topic, 'id') == topicId ||
        get(opt.resolved_topic, 'id') == topicId ||
Severity: Major
Found in react/src/pages/InstrumentMap.js - About 40 mins to fix

Function ObjectStatusBar has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const ObjectStatusBar = (props) => {
  const {id, type} = props
  const status = ObjectStatus(id, type)

  if(!isEmpty(status) && !isNil(status.error)){
Severity: Minor
Found in react/src/components/ObjectStatusBar.js - About 35 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 BuildContainer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const BuildContainer = (props) => {
  let history = useHistory();

  const { instrumentId, selectionPath = () => { }, heading = "Code Lists", itemId, itemType, objectType = "CodeList", stateKey = "codeLists", fetch = [], formRenderer = () => { }, defaultValues = { used_by: [], min_responses: 1, max_responses: 1 }} = props;
  const { findSelectedItem = (items, itemId, itemType) => { return get(items, itemId, {}) }, listItemLabel = (item) => { return item.label }, listItemValue = (item) => { return item.used_by.length }, headingContent = (instrumentId) => { return '' } } = props;
Severity: Minor
Found in react/src/components/BuildContainer.js - About 35 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 member_imports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def member_imports
        imports = params[:imports].nil? ? [] : params[:imports]
        head :ok, format: :json if imports.empty?
        begin
          imports.each do |import|
Severity: Minor
Found in lib/importers.rb - About 35 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 build_loop_while has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def build_loop_while(cc)
      command = ''
      unless cc.end_val.nil?
        command += cc.loop_var + ' < ' + cc.end_val
      end
Severity: Minor
Found in lib/exporters/xml/ddi/cc_loop.rb - About 35 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 import has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def import
    files = params[:files].nil? ? [] : params[:files]
    options = {}
    options[:prefix] = params[:instrument_prefix] if params.has_key? :instrument_prefix
    options[:agency] = params[:instrument_agency] if params.has_key? :instrument_agency
Severity: Minor
Found in app/controllers/importable_controller.rb - About 35 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 find_by_identifier has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.find_by_identifier(id_type, value)
      cache_result = $redis.hget 'identifiers', id_type + ':' + value.to_s
      if cache_result.nil?
        Identifier.includes(:item).where(item_type: self.class.name).find_by_id_type_and_value(id_type, value)&.item
      else
Severity: Minor
Found in lib/identifiable.rb - About 35 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 create_codes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def create_codes(codes, code_list)
      codes.reverse.each do | code_hash |
        code_hash[:code_list_id] = code_list.id
        urn = code_hash.fetch(:urn, '')
        category_urn = code_hash.delete(:category_urn)
Severity: Minor
Found in lib/importers/xml/ddi/fragment_instance.rb - About 35 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 member_imports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def member_imports
    imports = params[:imports].nil? ? [] : params[:imports]
    head :ok, format: :json if imports.empty?
    begin
      imports.each do |import|
Severity: Minor
Found in app/controllers/datasets_controller.rb - About 35 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 create_instructions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def create_instructions(instructions=[])
      instructions.each do | instruction_hash |
        urn = instruction_hash.fetch(:urn, '')
        parsed_urn = parse_urn(urn)
        if @instrument.prefix != parsed_urn[:instrument_prefix]
Severity: Minor
Found in lib/importers/xml/ddi/fragment_instance.rb - About 35 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 create_code_lists has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def create_code_lists(code_lists=[])
      code_lists.reverse.each do | code_list_hash |
        urn = code_list_hash.fetch(:urn, '')
        codes = code_list_hash.delete(:codes)
        parsed_urn = parse_urn(urn)
Severity: Minor
Found in lib/importers/xml/ddi/fragment_instance.rb - About 35 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 too many return statements within this function.
Open

  return <Route {...props} />;
Severity: Major
Found in react/src/AuthRoute.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

          return { ...state, ...{ [key]: { error: true, errors: action.payload.error, errorMessage: '' } } }
Severity: Major
Found in react/src/reducers/index.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return {...state, ...{[key]: {error: true, errorMessage: action.payload.error}}}
Severity: Major
Found in react/src/reducers/index.js - About 30 mins to fix
Severity
Category
Status
Source
Language