opf/openproject

View on GitHub

Showing 610 of 1,650 total issues

Method rollback_attachment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def rollback_attachment(attachment)
        return unless attachment.file.path

        old_file = rolled_back_file_name attachment

Severity: Minor
Found in lib/tasks/shared/legacy_attachment.rb - About 25 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 parse_context has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

            def parse_context
              context = ::API::Utilities::ResourceLinkParser.parse(params[:context])

              if context.nil?
                fail ::API::Errors::InvalidRenderContext.new(
Severity: Minor
Found in lib/api/v3/render/render_api.rb - About 25 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 existing_rate_attributes= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def existing_rate_attributes=(rate_attributes)
    rates.reject(&:new_record?).each do |rate|
      attributes = rate_attributes[rate.id.to_s]

      has_rate = false
Severity: Minor
Found in modules/costs/app/models/cost_type.rb - About 25 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 ifc_attachment_is_ifc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def ifc_attachment_is_ifc
        return unless model.ifc_attachment&.new_record? || model.ifc_attachment&.pending_direct_upload?

        file_path = model.ifc_attachment.file.local_file.path

Severity: Minor
Found in modules/bim/app/contracts/bim/ifc_models/base_contract.rb - About 25 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 searchable_column_conditions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

          def searchable_column_conditions
            searchable_options[:columns].map do |column|
              name, scope = column.is_a?(Hash) ? column.values_at(:name, :scope) : column
              match_condition = "(#{Arel.sql(name)} ILIKE ?)"

Severity: Minor
Found in lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rb - About 25 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 drop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async drop(el:Element, _target:Element|null, _source:Element|null, _sibling:Element|null) {
    const id = el.getAttribute('data-id');
    const url = el.getAttribute('data-drop-url');
    const data = new FormData();
    const newIndex = Array.from(this.containerTarget.children).indexOf(el);

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

        def to_ar_name(attribute, context:, refer_to_ids: false, collapse_cf_name: true)
          attribute = underscore_attribute attribute.to_s.underscore
          attribute = collapse_custom_field_name(attribute) if collapse_cf_name

          special_conversion = Constants::ARToAPIConversions.api_to_ar_conversions[attribute]
Severity: Minor
Found in lib/api/utilities/property_name_converter.rb - About 25 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 triggerLimitWarningIfReached has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  triggerLimitWarningIfReached(evt:CustomEvent) {
    this.selectedValues = evt.detail as IUserAutocompleteItem[];

    if (this.hasLimitWarningTarget && this.hasOpenSeatsValue) {
      if (this.numberOfNewUsers > 0 && this.numberOfNewUsers > this.openSeatsValue) {
Severity: Minor
Found in frontend/src/stimulus/controllers/dynamic/user-limit.controller.ts - About 25 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 render_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def render_options(group_by_ary)
    group_by_ary.sort_by(&:label).map do |group_by|
      next unless group_by.selectable?

      label_text = CGI::escapeHTML(h(group_by.label)).to_s
Severity: Minor
Found in modules/reporting/lib/widget/group_bys.rb - About 25 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_demo_xkt_models has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update_demo_xkt_models
    project = Project.find_by(identifier: "demo-bcf-management-project")
    return unless project

    ifc_models = project.ifc_models.joins(:attachments)
Severity: Minor
Found in modules/bim/db/migrate/20210521080035_update_xkt_to_version8.rb - About 25 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 recognize_route has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.recognize_route(path)
      return nil unless path.present?

      # Remove relative URL root
      if (relative_url = OpenProject::Configuration.rails_relative_url_root)
Severity: Minor
Found in lib/open_project/static_routing.rb - About 25 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 code_block_transformer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def code_block_transformer
        lambda { |env|
          name = env[:node_name]
          code = env[:node]

Severity: Minor
Found in lib/open_project/text_formatting/filters/sanitization_filter.rb - About 25 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 icons has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def icons(result)
    icons = ""
    with_project(result.fields["project_id"]) do
      if entry_for(result).editable_by? User.current
        if controller_for(result.fields["type"]) == "costlog"
Severity: Minor
Found in modules/reporting/lib/widget/table/entry_table.rb - About 25 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 state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  get state() {

    if (this.mergeRequest.state === 'opened') {
      return (this.mergeRequest.draft ? 'open' : 'ready');
    } else {

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

      def view_permissions?
        return false unless user_allowed_on_view?(:view_ifc_models)
        return false unless user_allowed_on_view?(:save_bcf_queries)
        if model.query.public && !user_allowed_on_view?(:manage_public_bcf_queries)
          return false
Severity: Minor
Found in modules/bim/app/contracts/bim/views/contract_strategy.rb - About 25 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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def call
        return html unless applicable?

        html.gsub(self.class.regexp) do |matched_string|
          variable = ($1.presence || $2.presence).dup
Severity: Minor
Found in lib/open_project/text_formatting/filters/setting_macros_filter.rb - About 25 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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def call
        attachments = get_attachments

        rewriter = ::OpenProject::TextFormatting::Helpers::LinkRewriter.new context

Severity: Minor
Found in lib/open_project/text_formatting/filters/attachment_filter.rb - About 25 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 toggleMultiSelect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  toggleMultiSelect({ params: { filterName } }:{ params:{ filterName:string } }) {
    const valueContainer = this.filterValueContainerTargets.find((filterValueContainer) => filterValueContainer.getAttribute('data-filter-name') === filterName);
    const singleSelect = this.filterValueSelectTargets.find((selectField) => !selectField.multiple && selectField.getAttribute('data-filter-name') === filterName);
    const multiSelect = this.filterValueSelectTargets.find((selectField) => selectField.multiple && selectField.getAttribute('data-filter-name') === filterName);
    if (valueContainer && singleSelect && multiSelect) {
Severity: Minor
Found in frontend/src/stimulus/controllers/dynamic/filters.controller.ts - About 25 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 set_rate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def set_rate
    today = Date.today

    rate = @user.rate_at(today, @project)
    rate = HourlyRate.new if rate.nil? || rate.valid_from != today
Severity: Minor
Found in modules/costs/app/controllers/hourly_rates_controller.rb - About 25 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 restructured has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def restructured
    rows = []
    columns = []
    current = query.chain
    @all_fields = []
Severity: Minor
Found in modules/reporting/lib/report/transformer.rb - About 25 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