flood-io/ruby-jmeter

View on GitHub

Showing 173 of 173 total issues

Method run has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def run(params = {})
      file(params)
      logger.warn 'Test executing locally ...'

      cmd = "#{params[:path] ? File.join(params[:path], 'jmeter') : 'jmeter'} #{"-n" unless params[:gui] } -t #{params[:file]} -j #{params[:log] ? params[:log] : 'jmeter.log' } -l #{params[:jtl] ? params[:jtl] : 'jmeter.jtl' } #{build_properties(params[:properties]) if params[:properties]}"
Severity: Minor
Found in lib/ruby-jmeter/dsl.rb - About 2 hrs 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def thread_group(*args, &block)
      params = args.shift || {}
      params = { count: params }.merge(args.shift || {}) if params.class == Fixnum
      params[:num_threads] = params[:count] || 1
      params[:ramp_time] = params[:rampup] || (params[:num_threads]/2.0).ceil
Severity: Major
Found in lib/ruby-jmeter/extend/threads/thread_group.rb and 1 other location - About 2 hrs to fix
lib/ruby-jmeter/extend/threads/setup_thread_group.rb on lines 3..15

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 93.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def setup_thread_group(*args, &block)
      params = args.shift || {}
      params = { count: params }.merge(args.shift || {}) if params.class == Fixnum
      params[:num_threads] = params[:count] || 1
      params[:ramp_time] = params[:rampup] || (params[:num_threads]/2.0).ceil
Severity: Major
Found in lib/ruby-jmeter/extend/threads/setup_thread_group.rb and 1 other location - About 2 hrs to fix
lib/ruby-jmeter/extend/threads/thread_group.rb on lines 3..14

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 93.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method initialize has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def initialize(params={})
        testname = params.kind_of?(Array) ? 'CompositeGraph' : (params[:name] || 'CompositeGraph')
        graphNodes = params.collect { |g| "<stringProp name=\"\">#{g[:graph]}</stringProp>"}
        metricNodes = params.collect { |m| "<stringProp name=\"\">#{m[:metric]}</stringProp>"}

Severity: Major
Found in lib/ruby-jmeter/plugins/composite_graph.rb - About 2 hrs to fix

    Method initialize has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize(params={})
          testname = params.kind_of?(Array) ? 'JavaRequestDefaults' : (params[:name] || 'JavaRequestDefaults')
          @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
    <JavaConfig guiclass="JavaConfigGui" testclass="JavaConfig" testname="#{testname}" enabled="true">
      <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
    Severity: Major
    Found in lib/ruby-jmeter/dsl/java_request_defaults.rb - About 2 hrs to fix

      Method initialize has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(params={})
            testname = params.kind_of?(Array) ? 'JavaRequest' : (params[:name] || 'JavaRequest')
            @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
      <JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="#{testname}" enabled="true">
        <elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
      Severity: Major
      Found in lib/ruby-jmeter/dsl/java_request.rb - About 2 hrs to fix

        Method parse_url has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_url(params)
              return if params[:url].empty?
              if params[:url] =~ /https?:\/\/\$/ || params[:url][0] == '$'
                params[:path] = params[:url] # special case for named expressions
              else
        Severity: Minor
        Found in lib/ruby-jmeter/helpers/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

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

            def initialize(params={})
              testname = params.kind_of?(Array) ? 'MailerVisualizer' : (params[:name] || 'MailerVisualizer')
              @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
        <MailerResultCollector guiclass="MailerVisualizer" testclass="MailerResultCollector" testname="#{testname}" enabled="true">
          <boolProp name="ResultCollector.error_logging">false</boolProp>
        Severity: Minor
        Found in lib/ruby-jmeter/dsl/mailer_visualizer.rb - About 1 hr to fix

          Method initialize has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def initialize(params={})
                  testname = params.kind_of?(Array) ? 'ActiveThreadsOverTime' : (params[:name] || 'ActiveThreadsOverTime')
                  @doc = Nokogiri::XML(<<-XML.strip_heredoc)
                    <kg.apc.jmeter.vizualizers.CorrectedResultCollector guiclass="kg.apc.jmeter.vizualizers.ThreadsStateOverTimeGui" testclass="kg.apc.jmeter.vizualizers.CorrectedResultCollector" testname="#{testname}" enabled="true">
                      <boolProp name="ResultCollector.error_logging">false</boolProp>
          Severity: Minor
          Found in lib/ruby-jmeter/plugins/active_threads_over_time.rb - About 1 hr to fix

            Method initialize has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def initialize(params = {})
                    @doc = Nokogiri::XML(<<-XML.strip_heredoc)
                      <kg.apc.jmeter.perfmon.PerfMonCollector guiclass="kg.apc.jmeter.vizualizers.PerfMonGui" testclass="kg.apc.jmeter.perfmon.PerfMonCollector" testname="#{params[:name] || 'PerfmonCollector'}" enabled="true">
                        <boolProp name="ResultCollector.error_logging">false</boolProp>
                        <objProp>
            Severity: Minor
            Found in lib/ruby-jmeter/plugins/perfmon_collector.rb - About 1 hr to fix

              Method flood has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def flood(token, params = {})
                    RestClient.proxy = params[:proxy] if params[:proxy]
                    begin
                      file = Tempfile.new(['ruby-jmeter', '.jmx'])
                      file.write(doc.to_xml(indent: 2))
              Severity: Minor
              Found in lib/ruby-jmeter/extend/misc/flood.rb - About 1 hr to fix

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

                      def initialize(params={})
                        testname = params.kind_of?(Array) ? 'ResponseTimesPercentiles' : (params[:name] || 'ResponseTimesPercentiles')
                        @doc = Nokogiri::XML(<<-EOF.strip_heredoc)
                          <kg.apc.jmeter.vizualizers.CorrectedResultCollector guiclass="kg.apc.jmeter.vizualizers.ResponseTimesPercentilesGui" testclass="kg.apc.jmeter.vizualizers.CorrectedResultCollector" testname="#{testname}" enabled="#{enabled(params)}">
                            <boolProp name="ResultCollector.error_logging">false</boolProp>
                Severity: Minor
                Found in lib/ruby-jmeter/plugins/response_times_percentiles.rb - About 1 hr to fix

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

                        def initialize(params={})
                          testname = params.kind_of?(Array) ? 'ResponseTimesOverTime' : (params[:name] || 'ResponseTimesOverTime')
                          @doc = Nokogiri::XML(<<-EOF.strip_heredoc)
                            <kg.apc.jmeter.vizualizers.CorrectedResultCollector guiclass="kg.apc.jmeter.vizualizers.ResponseTimesOverTimeGui" testclass="kg.apc.jmeter.vizualizers.CorrectedResultCollector" testname="#{testname}" enabled="#{enabled(params)}">
                              <boolProp name="ResultCollector.error_logging">false</boolProp>
                  Severity: Minor
                  Found in lib/ruby-jmeter/plugins/response_times_over_time.rb - About 1 hr to fix

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

                          def initialize(params={})
                            testname = params.kind_of?(Array) ? 'TransactionsPerSecond' : (params[:name] || 'TransactionsPerSecond')
                            @doc = Nokogiri::XML(<<-EOF.strip_heredoc)
                              <kg.apc.jmeter.vizualizers.CorrectedResultCollector guiclass="kg.apc.jmeter.vizualizers.TransactionsPerSecondGui" testclass="kg.apc.jmeter.vizualizers.CorrectedResultCollector" testname="#{testname}" enabled="#{enabled(params)}">
                                <boolProp name="ResultCollector.error_logging">false</boolProp>
                    Severity: Minor
                    Found in lib/ruby-jmeter/plugins/transactions_per_second.rb - About 1 hr to fix

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

                            def initialize(params={})
                              testname = params.kind_of?(Array) ? 'ResponseCodesPerSecond' : (params[:name] || 'ResponseCodesPerSecond')
                              @doc = Nokogiri::XML(<<-EOF.strip_heredoc)
                                <kg.apc.jmeter.vizualizers.CorrectedResultCollector guiclass="kg.apc.jmeter.vizualizers.ResponseCodesPerSecondGui" testclass="kg.apc.jmeter.vizualizers.CorrectedResultCollector" testname="#{testname}" enabled="#{enabled(params)}">
                                  <boolProp name="ResultCollector.error_logging">false</boolProp>
                      Severity: Minor
                      Found in lib/ruby-jmeter/plugins/response_codes_per_second.rb - About 1 hr to fix

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

                              def initialize(params={})
                                testname = params.kind_of?(Array) ? 'LatenciesOverTime' : (params[:name] || 'LatenciesOverTime')
                                @doc = Nokogiri::XML(<<-EOF.strip_heredoc)
                                  <kg.apc.jmeter.vizualizers.CorrectedResultCollector guiclass="kg.apc.jmeter.vizualizers.LatenciesOverTimeGui" testclass="kg.apc.jmeter.vizualizers.CorrectedResultCollector" testname="#{testname}" enabled="#{enabled(params)}">
                                    <boolProp name="ResultCollector.error_logging">false</boolProp>
                        Severity: Minor
                        Found in lib/ruby-jmeter/plugins/latencies_over_time.rb - About 1 hr to fix

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

                                def initialize(params={})
                                  testname = params.kind_of?(Array) ? 'ResponseTimesDistribution' : (params[:name] || 'ResponseTimesDistribution')
                                  @doc = Nokogiri::XML(<<-EOF.strip_heredoc)
                                    <kg.apc.jmeter.vizualizers.CorrectedResultCollector guiclass="kg.apc.jmeter.vizualizers.ResponseTimesDistributionGui" testclass="kg.apc.jmeter.vizualizers.CorrectedResultCollector" testname="#{testname}" enabled="#{enabled(params)}">
                                      <boolProp name="ResultCollector.error_logging">false</boolProp>
                          Severity: Minor
                          Found in lib/ruby-jmeter/plugins/response_times_distribution.rb - About 1 hr to fix

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

                                def initialize(params={})
                                  testname = params.kind_of?(Array) ? 'SimpleDataWriter' : (params[:name] || 'SimpleDataWriter')
                                  @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
                            <ResultCollector guiclass="SimpleDataWriter" testclass="ResultCollector" testname="#{testname}" enabled="true">
                              <boolProp name="ResultCollector.error_logging">false</boolProp>
                            Severity: Minor
                            Found in lib/ruby-jmeter/dsl/simple_data_writer.rb - About 1 hr to fix

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

                                  def initialize(params={})
                                    testname = params.kind_of?(Array) ? 'AggregateReport' : (params[:name] || 'AggregateReport')
                                    @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
                              <ResultCollector guiclass="StatVisualizer" testclass="ResultCollector" testname="#{testname}" enabled="true">
                                <boolProp name="ResultCollector.error_logging">false</boolProp>
                              Severity: Minor
                              Found in lib/ruby-jmeter/dsl/aggregate_report.rb - About 1 hr to fix

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

                                    def initialize(params={})
                                      testname = params.kind_of?(Array) ? 'ResponseTimeGraph' : (params[:name] || 'ResponseTimeGraph')
                                      @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
                                <ResultCollector guiclass="RespTimeGraphVisualizer" testclass="ResultCollector" testname="#{testname}" enabled="true">
                                  <boolProp name="ResultCollector.error_logging">false</boolProp>
                                Severity: Minor
                                Found in lib/ruby-jmeter/dsl/response_time_graph.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language