CLOSER-Cohorts/archivist

View on GitHub

Showing 219 of 2,584 total issues

Function AdminInstrumentDatasetForm has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AdminInstrumentDatasetForm = (props) => {
  const {datasets, instrument} = props;

  const [selectedDatasets, setSelectedDatasets] = React.useState([]);

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

Function AdminInstrumentImportMappings has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AdminInstrumentImportMappings = (props) => {
  const dispatch = useDispatch()
  const type = "Instrument"
  const hint = "You can import multiple Q-V and T-Q mapping files. Only TXT files are accepted."
  const instrumentId = get(props, "match.params.instrumentId", "")
Severity: Minor
Found in react/src/pages/AdminInstrumentImportMappings.js - About 1 hr to fix

Function TopicList has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TopicList = (props) => {
  const {topicId, datasetId, variableId} = props

  const dispatch = useDispatch()

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

Function AdminDatasetImportMappings has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AdminDatasetImportMappings = (props) => {
  const dispatch = useDispatch()
  const type = "Dataset"
  const hint = "You can import multiple T-V and DV mapping files. Only TXT files are accepted."
  const datasetId = get(props, "match.params.datasetId", "")
Severity: Minor
Found in react/src/pages/AdminDatasetImportMappings.js - About 1 hr to fix

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

  def import(options = {})
    Map.where(id: @object.maps.pluck(:id)).delete_all
    set_import_to_running
    @doc.each do |control_construct_scheme, q, dataset, v|
      log :input, "#{control_construct_scheme},#{q},#{dataset},#{v}"
Severity: Minor
Found in lib/importers/txt/mapper/mapping.rb - About 1 hr to fix

Method copy has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def copy(new_prefix, other_vals = {})
    new_i = self.dup
    new_i.prefix = new_prefix
    other_vals.select { |key, val| new_i[key] = val }

Severity: Minor
Found in app/models/instrument.rb - About 1 hr to fix

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

  def import(options = {})
    set_import_to_running
    vars = @object.variables.includes(:questions, :src_variables, :der_variables, :topic)
    begin
        @doc.each do |variable_dataset, v, source_dataset, s|
Severity: Minor
Found in lib/importers/txt/mapper/dv.rb - About 1 hr to fix

Function ObjectFinder has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ObjectFinder = (instrumentId) => {
  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/InstrumentConstructBuild.js - About 1 hr to fix

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

const ObjectFinder = (instrumentId) => {
  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/InstrumentConstructBuild.js - 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 import has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def import(options = {})
      options.symbolize_keys!

      if options.has_key? :import_id
        @import = Import.find_by_id(options[:import_id])
Severity: Minor
Found in lib/importers/xml/ddi/instrument.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 QuestionGridListItem has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const QuestionGridListItem = (props) => {
  const {item} = props;
  const classes = useStyles();

  if(isNil(item) || isNil(item.question)){
Severity: Minor
Found in react/src/pages/InstrumentView.js - About 1 hr to fix

Function render has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {

    const email = this.props.email;
    const password = this.props.password;
    return (
Severity: Minor
Found in react/src/components/Login.js - About 1 hr to fix

Method safe_params has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def safe_params
    # The params from Angular use :codes in the params array, we
    # tranform these into params that comply with the params expected
    # by nested attributes using accepts_nested_attributes for the codes
    # and their nested categories.
Severity: Minor
Found in app/controllers/code_lists_controller.rb - About 1 hr to fix

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

  def import(options = {})
    variable_ids_to_delete = @object.variables.pluck(:id)
    set_import_to_running
    vars = @object.variables.includes(:questions, :src_variables, :der_variables, :topic)
    @doc.each do |dataset, v, t|
Severity: Minor
Found in lib/importers/txt/mapper/topic_v.rb - About 1 hr to fix

Method update_rds has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def update_rds(rds)
      if rds.nil?
        self.response_domain_codes =
        self.response_domain_datetimes =
        self.response_domain_numerics =
Severity: Minor
Found in lib/question.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 read_question has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def read_question(node)
      question_item = @instrument.question_items.new(
          label: node['name'],
          literal: node.at_xpath('./qt_properties/label')&.content
      )
Severity: Minor
Found in lib/importers/xml/qsrx/parental_importer.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 format_output_hash has a Cognitive Complexity of 13 (exceeds 5 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

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 InstrumentCcQuestions has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const InstrumentCcQuestions = (props) => {

  const dispatch = useDispatch()
  const instrumentId = get(props, "match.params.instrument_id", "")

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

Function UsedByQuestions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const UsedByQuestions = (props) => {
  const {item, instrumentId} = props;

  const classes = useStyles();

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

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

const ObjectTypeLookup = (objectType, instrumentId) => {
    switch(objectType) {
      case('ResponseDomainNumeric'):
        return {
          path: url(routes.instruments.instrument.build.responseDomains.show, { instrument_id: instrumentId, responseDomainType: objectType, responseDomainId: 'new' }),
Severity: Minor
Found in react/src/components/CreateNewBuildObjectButtons.js - About 1 hr to fix
Severity
Category
Status
Source
Language