theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

Method setBuild has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def setBuild
    forward_url_options
    if @host.setBuild
      if (params[:host] && params[:host][:build] == '1')
        begin
Severity: Minor
Found in app/controllers/hosts_controller.rb - About 2 hrs to fix

    Function interface_domain_selected has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function interface_domain_selected(element) {
      // mark the selected value to preserve it for form hiding
      preserve_selected_options($(element));
    
      var domain_id = element.value;
    Severity: Minor
    Found in app/assets/javascripts/host_edit.js - About 1 hr to fix

      Function onContentLoad has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function onContentLoad() {
        if ($('input[focus_on_load=true]').length > 0) {
          $('input[focus_on_load]')
            .first()
            .focus();
      Severity: Minor
      Found in app/assets/javascripts/application.js - About 1 hr to fix

        Method clean_puppet has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def clean_puppet
              if Foreman::Plugin.find(:foreman_puppet)
                warn('You have the Puppet plugin installed, uninstall it first to purge puppet data')
                return false
              end
        Severity: Minor
        Found in lib/cleanup_helper.rb - About 1 hr to fix

          Function ConfigReports has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const ConfigReports = props => {
            const {
              metricsChartData,
              statusChartData,
              metricsData: { tableData, tableClasses, total },

            Function DefaultEmptyState has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const DefaultEmptyState = props => {
              const {
                icon,
                iconType,
                header,

              Function Pagination has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              const Pagination = ({
                itemCount,
                onSetPage,
                onPerPageSelect,
                onChange,
              Severity: Minor
              Found in webpack/assets/javascripts/react_app/components/Pagination/index.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

              Function interface_subnet_selected has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              function interface_subnet_selected(element, ip_field, skip_mac) {
                // mark the selected value to preserve it for form hiding
                preserve_selected_options($(element));
              
                if ($(element).attr('disabled')) return;
              Severity: Minor
              Found in app/assets/javascripts/host_edit.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

              Function ReportsTab has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              const ReportsTab = ({ hostName, origin }) => {
                const dispatch = useDispatch();
                const history = useHistory();
                const API_KEY = `get-reports-${hostName}`;
                const { reports, itemCount, response } = useSelector(state =>

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

                  def create_interfaces(vm, attrs, cluster_id)
                    # first remove all existing interfaces
                    vm.interfaces&.each do |interface|
                      # The blocking true is a work-around for ovirt bug, it should be removed.
                      vm.destroy_interface(:id => interface.id, :blocking => true)
              Severity: Minor
              Found in app/models/compute_resources/foreman/model/ovirt.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 useSelectionSet has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              export const useSelectionSet = ({
                results,
                metadata,
                defaultArry = [],
                initialArry = [],

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

                def authenticate
                  return true if (User.current && Rails.env.test? && api_request?) ||
                                 session[:user] && (User.current = User.unscoped.find_by(id: session[:user]))
              
                  user = sso_authentication
              Severity: Minor
              Found in app/controllers/concerns/foreman/controller/authentication.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 preview has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                def preview
                  # Not using before_action :find_resource method because we have enabled preview to work for unsaved templates hence no resource could be found in those cases
                  if params[:id]
                    find_resource
                  else
              Severity: Minor
              Found in app/controllers/templates_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 operatingsystem has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def operatingsystem
                    os_name = facts['lsb::id'] || facts['platform']
                    release = facts['lsb::release'] || facts['platform_version']
                    # if we have no release information we can't assign OS properly (e.g. missing redhat-lsb)
                    if release.nil?
              Severity: Minor
              Found in app/services/foreman_chef/fact_parser.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 submit has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const submit = async () => {
                  const params = {
                    filter: {
                      role_id: role,
                      search: isUnlimited ? null : autocompleteQuery,

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

                export function activateDatatables() {
                  const language = {
                    searchPlaceholder: __('Filter...'),
                    emptyTable: __('No data available in table'),
                    info: sprintf(__('Showing %(start)s to %(end)s of %(total)s entries'), {
                Severity: Minor
                Found in webpack/assets/javascripts/foreman_tools.js - About 1 hr to fix

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

                  export const ErrorsTreePrimaryRow = props => {
                    const { isExpanded } = props;
                    const { isDetailsExpanded } = props;
                  
                    const treeRow = {

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

                      render() {
                        const {
                          notifications,
                          isDrawerOpen,
                          toggleDrawer,

                      Function deleteHost has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      ) => dispatch => {
                        const successToast = () => sprintf(__('Host %s deleted'), hostName);
                        const errorToast = ({ message }) => message;
                        const url = foremanUrl(`/api/hosts/${hostName}`);
                      
                      

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

                          render() {
                            const { date, selectedDate } = this.state;
                            const [currMonth, currYear] = [date.getMonth(), date.getFullYear()];
                            const selectedYear = selectedDate.getFullYear();
                            const monthArray = this.getMonthArray();
                          Severity
                          Category
                          Status
                          Source
                          Language