Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-7948

selmodversion_loaded lines variable broken

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 5.2.0
    • Fix Version/s: PUP 5.3.4, PUP 5.4.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Sub-team:
    • Team:
      Platform Core
    • Story Points:
      1
    • Sprint:
      Platform Core KANBAN
    • Method Found:
      Inspection
    • Release Notes:
      Not Needed
    • QA Risk Assessment:
      No Action

      Description

      I was playing with rubocop when it complained about:

      == lib/puppet/provider/selmodule/semodule.rb ==
      W:121: 13: Lint/EmptyExpression: Avoid empty expressions.
      

      Looking at the code its complaining about the "lines = ()" assignment:

        def selmodversion_loaded
          lines = ()
          begin
            execpipe("#{command(:semodule)} --list") do |output|
              output.each_line do |line|
                line.chomp!
                bits = line.split
                if bits[0] == @resource[:name]
                  self.debug "load version #{bits[1]}"
                  return bits[1]
                end
              end
            end
          rescue Puppet::ExecutionFailure
            raise Puppet::ExecutionFailure, "Could not list policy modules: #{lines.join(' ').chomp!}", $!.backtrace
          end
          nil
        end
      

      Looking at the code, lines will be assigned "nil" which doesn't have a .join method. So the exception will fail. We also fail to do anything with the lines variable in the method so if it was intended to be an array, it never gets changed from an empty array which is kind of pointless.

      We should enable "Lint/EmptyExpression" in the .robocop.yml if when this is fixed and we're on 0.49 or greater.

      Branch off of 5.3.x

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                eric.delaney Eric Delaney
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support