theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

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

    def self.lookup(query, options = {})
      return nil unless query.present?

      proxy = options.fetch(:proxy, nil)
      resolver = options.fetch(:resolver, Resolv::DNS.new)
Severity: Minor
Found in app/lib/net/dns.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 notify_on_report_error has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def notify_on_report_error(mail_error_state)
    if report.error?
      # found a report with errors
      # notify via email IF enabled is set to true

Severity: Minor
Found in app/services/report_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 suggest_key_type has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def self.suggest_key_type(value, default = nil, detect_json_or_yaml = false)
    case value
    when String
      if detect_json_or_yaml
        begin
Severity: Minor
Found in app/services/foreman/importer_puppetclass.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 process_role has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def process_role(name, permissions, description = '')
        role = Role.find_by :name => name
        if role
          role.update_column(:description, description) if role.description != description

Severity: Minor
Found in app/services/foreman/plugin/role_lock.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 start_proxy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def start_proxy
    # randomly preselect free tcp port from the range
    port = 0
    Timeout.timeout(5) do
      until free_port?(port = rand(PORTS)); end
Severity: Minor
Found in lib/ws_proxy.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 add_child_node has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function add_child_node(item) {
  // Setup
  var assoc = $(item).attr('data-association'); // Name of child
  var template_class = '.' + assoc + '_fields_template';
  var content = $(item)
Severity: Minor
Found in app/assets/javascripts/lookup_keys.js - About 1 hr to fix

    Function update_provisioning_image has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function update_provisioning_image() {
      var compute_id = $('[name$="[compute_resource_id]"]').val();
      var arch_id = $('[name$="[architecture_id]"]').val();
      var os_id = $('[name$="[operatingsystem_id]"]').val();
      if (
    Severity: Minor
    Found in app/assets/javascripts/host_edit.js - About 1 hr to fix

      Method try_to_login has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.try_to_login(login, password, api_request = false)
          # Make sure no one can sign in with an empty password
          return nil if password.to_s.empty?
      
          # user is already in local database
      Severity: Minor
      Found in app/models/user.rb - About 1 hr to fix

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

        export function imageSelected(item) {
          const template = $(item).val();
        
          if (template) {
            const url = $(item).attr('data-url');
        Severity: Minor
        Found in webpack/assets/javascripts/compute_resource/libvirt.js - About 1 hr to fix

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

            renderControllers(controllers) {
              const {
                addDisk,
                updateController,
                removeDisk,

            Method operatingsystem has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def operatingsystem
                orel = os_release.dup
            
                if orel.present?
                  if os_name =~ /ubuntu/i
            Severity: Minor
            Found in app/services/puppet_fact_parser.rb - About 1 hr to fix

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

              function expireLogs(item, from) {
                table_url = item.getAttribute('data-url');
                errors_url = item.getAttribute('data-url-errors');
                modules_url = item.getAttribute('data-url-modules');
                if (table_url && errors_url && modules_url) {
              Severity: Minor
              Found in app/assets/javascripts/proxy_status/logs.js - About 1 hr to fix

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

                  get: async (url, header, params) => {
                    if (url === 'model/auto_complete_search') {
                      if (!params?.search) {
                        return { data: mockModelsEmptyAutocomplete };
                      }

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

                    render() {
                      const { addController, controllers, volumes, cluster, config } = this.props;
                      const paramsScope = config && config.paramsScope;
                      const enableAddControllerBtn =
                        config && config.addControllerEnabled && !config.vmExists;

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

                    function selectRelatedNetwork(subnetElement) {
                      var subnet_select = $(subnetElement);
                      var vlanId = subnet_select.find(':selected').attr('data-vlan_id');
                      var network_select = subnet_select
                        .closest('fieldset')
                    Severity: Minor
                    Found in app/assets/javascripts/host_edit.js - About 1 hr to fix

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

                      function multiSelectToolTips(){
                        $('select[multiple]').each(function(i,item){
                          var mismatches = $(item).attr('data-mismatches');
                          var inheriteds = $(item).attr('data-inheriteds');
                          var descendants = $(item).attr('data-descendants');
                      Severity: Minor
                      Found in app/assets/javascripts/jquery.multi-select.js - About 1 hr to fix

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

                        const cardExpansionReducer = (state, action) => {
                          // A React reducer, not a Redux one!
                          switch (action.type) {
                            case 'expand':
                              return {

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

                          export function templateSelected(item) {
                            const template = $(item).val();
                          
                            if (template === null) {
                              return;
                          Severity: Minor
                          Found in webpack/assets/javascripts/compute_resource/ovirt.js - About 1 hr to fix

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

                            export const makeOnHover = (getIndex, getMoveFnc, direction) => (
                              props,
                              monitor,
                              component
                            ) => {

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

                                render() {
                                  const { locale, weekStartsOn, toggleDateView } = this.props;
                                  const { date, selectedDate } = this.state;
                                  const calendar = this.calendarArray(date);
                                  return (
                                Severity
                                Category
                                Status
                                Source
                                Language