rubocop:enable Metrics/CyclomaticComplexity
 rubocop:enable Metrics/PerceivedComplexity
336417
def display_backtrace_for_query_type?(payload)
      case ActiveRecordQueryTrace.query_type
      when :all then true
      when :read then db_read_query?(payload)
      when :write then !db_read_query?(payload)
      else
        raise 'Invalid ActiveRecordQueryTrace.query_type value ' \
          "#{ActiveRecordQueryTrace.level}. Should be :all, :read, or :write."
      end
    end
221360
def create
      @discussion = Discussion.includes(:posts => :user).find(params[:discussion_id])
      existing_posts = @discussion.posts.dup
      @post = @discussion.posts.new(params[:post])

      # assign user if signed in
      if current_cornerstone_user
        @post.user = current_cornerstone_user
      end
            
      respond_with(@discussion, @post) do |format|
        if @post.save
          # close discussion if commit param dictates
          unless params[:comment_close].nil?
            @discussion.update_attribute(:status, Discussion::STATUS.last)
          else
            # re-open discussion if discussion is closed
            if @discussion.closed?
              @discussion.update_attribute(:status, Discussion::STATUS.first)
            end
          end

          flash[:notice] = 'Comment was successfully created.'
          format.html {redirect_to category_discussion_path(@discussion.category, @discussion)}
        else
          @new_post = @post
          @posts = existing_posts
          format.html {render :template => "cornerstone/discussions/show"}
        end
      end
    end
706644
def execute!
      show_help if options.empty?
      show_version if options[:version]
      run_sketch if options[:run]
      watch_sketch if options[:watch]
      live if options[:live]
      create if options[:create]
      check if options[:check]
      install if options[:install]
    end
1351703
def new
      @faq = Cmtool::Faq.new

      respond_to do |format|
        format.html # new.html.erb
        format.xml  { render :xml => @faq }
      end
    end
900170
def set_autoload_paths
      # Rails 3 master support
      if ActiveSupport::Dependencies.respond_to?(:autoload_paths)
        ActiveSupport::Dependencies.autoload_paths      = configuration.autoload_paths.uniq
        ActiveSupport::Dependencies.autoload_once_paths = configuration.autoload_once_paths.uniq
      else
        ActiveSupport::Dependencies.load_paths      = configuration.autoload_paths.uniq
        ActiveSupport::Dependencies.load_once_paths = configuration.autoload_once_paths.uniq        
      end
    end
870418
def adapt_scenario!(parsed_scenario, gathered_comments)
      # Saving off the original data
      parsed_scenario['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_scenario))

      # Removing parsed data for child elements in order to avoid duplicating data
      parsed_scenario['cuke_modeler_parsing_data']['tags'] = nil
      parsed_scenario['cuke_modeler_parsing_data']['steps'] = nil

      if parsed_scenario['comments']
        parsed_scenario['cuke_modeler_parsing_data']['comments'] = nil
        gathered_comments.concat(parsed_scenario['comments'])
      end

      if parsed_scenario['tags']
        parsed_scenario['tags'].each do |tag|
          adapt_tag!(tag)
        end
      end

      if parsed_scenario['steps']
        parsed_scenario['steps'].each do |step|
          adapt_step!(step, gathered_comments)
        end
      end
    end
205357
def inspect
      cp_config.lockfile.to_hash['PODS'].map do |pod|
        pod.is_a?(Hash) ? pod.keys.first : pod
      end.inspect
    end
410486
def report_missing_steps(steps)
      puts "\nMissing steps:".colorize(:light_cyan)
      steps.each do |step|
        puts Generators::StepGenerator.new(step).generate.gsub(/^/, '  ')
          .colorize(:cyan)
      end
    end
361376
def feature(name = nil)
      if !name
        self.class.features.keys
      else
        if self.class.features.key?(name)
          self.class.features[name]
        else
          fail "Feature #{name} does not exist!"
        end
      end
    end
414756
def method_missing(method_name, *args, &block)
      if observer.respond_to?(method_name.to_sym)
        observer.public_send(method_name.to_sym, *args, &block)
      elsif env.aliases.include?(method_name.to_sym)
        env.send(:target, *args, &block)
      else
        super
      end
    end
1198625
function( context, target ) {
    var target   = target || 'ruby'
    var $target  = $.qsa( target, context )

    $.qsa( 'rtc', context )
    .concat( $target ).map( simplifyRubyClass )

    $target
    .forEach(function( $ruby ) {
      var clazz = $ruby.classList
      var $new

      if      ( clazz.contains( 'complex' ))  $new = renderComplexRuby( $ruby )
      else if ( clazz.contains( 'zhuyin' ))   $new = SUPPORT_IC ? renderInterCharRuby( $ruby ) : renderSimpleRuby( $ruby )

      // Finally, replace it
      if ( $new )  $ruby.parentNode.replaceChild( $new, $ruby )
    })
  }
238398
def create_parser(ruby_version)
      builder = RuboCop::AST::Builder.new

      parser_class(ruby_version).new(builder).tap do |parser|
        # On JRuby there's a risk that we hang in tokenize() if we
        # don't set the all errors as fatal flag. The problem is caused by a bug
        # in Racc that is discussed in issue #93 of the whitequark/parser
        # project on GitHub.
        parser.diagnostics.all_errors_are_fatal = (RUBY_ENGINE != 'ruby')
        parser.diagnostics.ignore_warnings = false
        parser.diagnostics.consumer = lambda do |diagnostic|
          @diagnostics << diagnostic
        end
      end
    end
168021
function renderComplexRuby( $ruby ) {
  var frag = $.create( '!' )
  var clazz = $ruby.classList
  var $cloned, $rb, $ru, maxspan

  frag.appendChild( $.clone( $ruby ))
  $cloned = frag.firstChild

  $rb = $ru = $.tag( 'rb', $cloned )
  maxspan = $rb.length

  // First of all, deal with Zhuyin containers
  // individually
  //
  // Note that we only support one single Zhuyin
  // container in each complex ruby
  void function( $rtc ) {
    if ( !$rtc )  return

    $ru = $
      .tag( 'rt', $rtc )
      .map(function( $rt, i ) {
        if ( !$rb[ i ] )  return
        var ret = createZhuyinRu( $rb[ i ], $rt )

        try {
          $rb[ i ].parentNode.replaceChild( ret, $rb[ i ] )
        } catch ( e ) {}
        return ret
      })

    // Remove the container once it's useless
    $.remove( $rtc )
    $cloned.setAttribute( 'rightangle', 'true' )
  }( $cloned.querySelector( 'rtc.zhuyin' ))

  // Then, normal annotations other than Zhuyin
  $
  .qsa( 'rtc:not(.zhuyin)', $cloned )
  .forEach(function( $rtc, order ) {
    var ret
    ret = $
      .tag( 'rt', $rtc )
      .map(function( $rt, i ) {
        var rbspan = Number( $rt.getAttribute( 'rbspan' ) || 1 )
        var span = 0
        var aRb = []
        var $rb, ret

        if ( rbspan > maxspan )  rbspan = maxspan

        do {
          try {
            $rb = $ru.shift()
            aRb.push( $rb )
          } catch (e) {}

          if ( typeof $rb === 'undefined' )  break
          span += Number( $rb.getAttribute( 'span' ) || 1 )
        } while ( rbspan > span )

        if ( rbspan < span ) {
          if ( aRb.length > 1 ) {
            console.error( 'An impossible `rbspan` value detected.', ruby )
            return
          }
          aRb  = $.tag( 'rb', aRb[0] )
          $ru  = aRb.slice( rbspan ).concat( $ru )
          aRb  = aRb.slice( 0, rbspan )
          span = rbspan
        }

        ret = createNormalRu( aRb, $rt, {
          'class': clazz,
          span: span,
          order: order
        })

        try {
          aRb[0].parentNode.replaceChild( ret, aRb.shift() )
          aRb.map( $.remove )
        } catch (e) {}
        return ret
      })
    $ru = ret
    if ( order === 1 )  $cloned.setAttribute( 'doubleline', 'true' )

    // Remove the container once it's useless
    $.remove( $rtc )
  })
  return createCustomRuby( frag )
}
198508
def understand?(name, arity = nil)
      name = name.to_s
      !!find { |m| m.name == name && (!arity || m.arity == arity) }
    end
871189
function (next, started, err, actuallyRan) {
    /* jshint maxcomplexity: 11 */
    var code = 0;
    var now = new Date();

    if (err) {
      if (err.type === 'exitCode') code = err.code;
      if ('number' === typeof err) code = err;

      this.status('phase.errored', {
        time: now,
        exitCode: code
      });

      if (code === 0) {
        this.error(err);
        return this.done(err, next);
      }
    }
    // Complain if no plugins actually did anything during testing?
    // XXX: should this be a fail hard?
    if (['deploy', 'test'].indexOf(this.phase) !== -1 && utils.sum(actuallyRan) === 0) {
      this.out(`Phase ${this.phase} didn't actually run anything. Check your plugin configuration`, 'warn');
    }

    if (this.phase === 'test') {
      this.status('tested', {time: now, exitCode: code});
    }

    if (this.phase === 'deploy') {
      this.status('deployed', {time: now, exitCode: code});
    }

    var nextPhase = PHASES[PHASES.indexOf(this.phase) + 1];

    if (code !== 0) {
      nextPhase = 'cleanup';
    } else if (nextPhase === 'deploy' && this.job.type !== 'TEST_AND_DEPLOY') {
      nextPhase = 'cleanup';
    }

    this.status('phase.done', {
      phase: this.phase,
      time: now,
      exitCode: code,
      next: nextPhase,
      elapsed: now.getTime() - started.getTime()
    });

    if (this.phase === 'cleanup') {
      return this.done(null, next);
    }

    this.phase = nextPhase;
    this.runPhase(next);
  }
1134344
private void cyclicConsistency() {
		for( int i = 0; i < detector.getNumberOfSets(); i++ ) {
			FastQueue<Point2D_F64> obs0 = featsLeft0.location[i];
			FastQueue<Point2D_F64> obs1 = featsRight0.location[i];
			FastQueue<Point2D_F64> obs2 = featsLeft1.location[i];
			FastQueue<Point2D_F64> obs3 = featsRight1.location[i];

			SetMatches matches = setMatches[i];

			if( matches.match0to1.size != matches.match0to2.size )
				throw new RuntimeException("Failed sanity check");

			for( int j = 0; j < matches.match0to1.size; j++ ) {
				int indexIn1 = matches.match0to1.data[j];
				int indexIn2 = matches.match0to2.data[j];

				if( indexIn1 < 0 || indexIn2 < 0 )
					continue;

				int indexIn3a = matches.match1to3.data[indexIn1];
				int indexIn3b = matches.match2to3.data[indexIn2];

				if( indexIn3a < 0 || indexIn3b < 0 )
					continue;

				// consistent association to new right camera image
				if( indexIn3a == indexIn3b ) {
					QuadView v = quadViews.grow();
					v.v0 = obs0.get(j);
					v.v1 = obs1.get(indexIn1);
					v.v2 = obs2.get(indexIn2);
					v.v3 = obs3.get(indexIn3a);
				}
			}
		}
	}
780013
def mentions_erb
      retdict = {
        enabled: @config[:mentions][:enabled],
        top: [],
        nottop: []
      }

      if @config[:mentions][:enabled]
        top = @parsed[:mentions].slice(0, @config[:mentions][:top]) # top X mentions
        top.each do |mention|
          retdict[:top] << mention[1]
        end

        nottop = @parsed[:mentions].slice(@config[:mentions][:top], @config[:mentions][:notop]) # not in the top X
        unless nottop.nil?
          nottop.each do |mention|
            mention[1].delete(:example)
            retdict[:nottop] << mention[1]
          end
        end
      end

      retdict
    end