CLOSER-Cohorts/archivist

View on GitHub

Showing 219 of 2,584 total issues

Function ListPagination has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ListPagination = props => {
  if (props.articlesCount <= 10) {
    return null;
  }

Severity: Minor
Found in react/src/components/ListPagination.js - About 1 hr to fix

Method build_instrument has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.build_instrument(doc, options= {}, instrument_importer=nil)
      save = defined?(options[:save]) ? true : options[:save]
      duplicate = defined?(options[:duplicate]) ? :do_nothing : options[:duplicate]

      i = ::Instrument.new
Severity: Minor
Found in lib/importers/xml/ddi/instrument.rb - About 1 hr to fix

Method run has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run(dataset)
      documents = Document.where(item: dataset).order(created_at: :asc)
      unless documents.empty?
        document = documents.first
        @doc = Nokogiri::XML document.file_contents
Severity: Minor
Found in lib/exporters/xml/ddi/dataset.rb - About 1 hr to fix

Function ObjectFinder has 36 lines of code (exceeds 25 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 1 hr to fix

Function ObjectFinder has 36 lines of code (exceeds 25 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 1 hr to fix

Function AdminInstrumentImportMappingView has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AdminInstrumentImportMappingView = (props) => {

  const dispatch = useDispatch()
  const instrumentId = get(props, "match.params.instrumentId", "")
  const importMappingId = get(props, "match.params.id", "")
Severity: Minor
Found in react/src/pages/AdminInstrumentImportMappingView.js - About 1 hr to fix

Function AdminDatasetImportMappingView has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AdminDatasetImportMappingView = (props) => {

  const dispatch = useDispatch()
  const datasetId = get(props, "match.params.datasetId", "")
  const importMappingId = get(props, "match.params.id", "")
Severity: Minor
Found in react/src/pages/AdminDatasetImportMappingView.js - About 1 hr to fix

Method no_circular_references has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def no_circular_references
    if parent_id.present?
      sql = <<-SQL
      WITH RECURSIVE ancestry_check AS (
          SELECT
Severity: Minor
Found in app/models/control_construct.rb - About 1 hr to fix

Method V3_2 has 36 lines of code (exceeds 25 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 1 hr to fix

Method update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    self.resource = resource_class.reset_password_by_token(resource_params)
    yield resource if block_given?

    if resource.errors.empty?
Severity: Minor
Found in app/controllers/users/passwords_controller.rb - About 1 hr 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_categories has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def create_categories(categories=[])
      categories.reverse.each do | category_hash |
        urn = category_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 1 hr 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 run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def run(dataset)
      documents = Document.where(item: dataset).order(created_at: :asc)
      unless documents.empty?
        document = documents.first
        @doc = Nokogiri::XML document.file_contents
Severity: Minor
Found in lib/exporters/xml/ddi/dataset.rb - About 1 hr 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 AdminUsers has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AdminUsers = () => {

  const dispatch = useDispatch()

  const deleteUser = (instrumentId) => {
Severity: Minor
Found in react/src/pages/AdminUsers.js - About 1 hr to fix

Function InstrumentBuildResponseDomains has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const InstrumentBuildResponseDomains = (props) => {
  const dispatch = useDispatch()
  const instrumentId = get(props, "match.params.instrument_id", "")
  const responseDomainId = get(props, "match.params.responseDomainId", null)
  const responseDomainType = get(props, "match.params.responseDomainType", null)
Severity: Minor
Found in react/src/pages/InstrumentBuildResponseDomains.js - About 1 hr to fix

Method import has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def import(options = {})
    cc_question_ids_to_delete = @object.cc_questions.pluck(:id)
    set_import_to_running
    @doc.each do |control_construct_scheme, q, t|
      log :input, "#{control_construct_scheme},#{q},#{t}"
Severity: Minor
Found in lib/importers/txt/mapper/topic_q.rb - About 1 hr to fix

Function InstrumentView has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const InstrumentView = (props) => {

  const dispatch = useDispatch()
  const instrumentId = get(props, "match.params.instrument_id", "")
  const instrument = useSelector(state => get(state.instruments, instrumentId));
Severity: Minor
Found in react/src/pages/InstrumentView.js - About 1 hr to fix

Function Instruments has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Instruments = () => {

  const dispatch = useDispatch()

  const actions = (row) => {
Severity: Minor
Found in react/src/pages/Instruments.js - About 1 hr to fix

Function AdminImportView has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AdminImportView = (props) => {

  const dispatch = useDispatch()
  const importId = get(props, "match.params.importId", "")
  const imports = useSelector(state => state.imports);
Severity: Minor
Found in react/src/pages/AdminImportView.js - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

    if (get(variable.topic, 'id') !== 0 && (!isEmpty(variable.topic) || !isEmpty(variable.sources_topic))) {
      sourceOptions = Object.values(sourceOptions).filter(opt => {
        return (
          get(opt.topic, 'id') == get(variable.topic, 'id') ||
          get(opt.resolved_topic, 'id') == get(variable.topic, 'id') ||
Severity: Critical
Found in react/src/pages/DatasetView.js - About 1 hr to fix

Method add_variables has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def add_variables
    variable_names = params[:variable_names].is_a?(Array) ? params[:variable_names] : [params[:variable_names]]

    variables = @object.instrument.variables.where(name: variable_names)
    variables.to_a.compact!
Severity: Minor
Found in app/controllers/cc_questions_controller.rb - About 1 hr to fix
Severity
Category
Status
Source
Language