rubocop:enable Metrics/PerceivedComplexity,Style/ConditionalAssignment
10668
def read_symbol
      logger.debug "  read symbol"
      skip_whitespace
      r = ""
      while !empty? && (c = text[position]) =~ /[-a-zA-Z_0-9]/
        r << c
        increase
      end
      s = STRING_TO_TOKEN[r]
      s = r.to_sym unless s
      s = true if s == :true
      s = false if s == :false
      logger.debug "  resulting symbol: #{s}"
      s
    end
467844
def auto_correct_incomplete?(rule)
      todo_reader = Rubocop::TodoReader.new(options[:file_path])
      todo_reader.all_rules.include?(rule)
    end
821095
def options_for_render(options = {})
      style = options_for_style(options[:style] || DEFAULT_OPTIONS[:style])
      DEFAULT_OPTIONS.merge(style).merge(options)
    end
1252439
private void mergeStatus(Hints hints) {
        if (status != null) {
            if (hints.getStatus() != null && !status.equals(hints.getStatus())) {
                switch (hints.getStatus()) {
                    case GONE:
                        status = Status.GONE;
                        break;
                    case DEPRECATED:
                        if (status != Status.GONE) {
                            status = Status.DEPRECATED;
                        }
                        break;
                }
            }
        } else {
            this.status = hints.getStatus();
        }
    }
940175
function (cfg, callback) {
        results = {};

        // Generate a test targeting any CSS
        var all = {
            name : "__baseline__",
            cfg : cfg,
            selector : null,
            callback : {
                fn : allTests,
                scope : this,
                args : [cfg, callback]
            }
        };

        runTest(all);
    }
794206
function setupStyleguide(options) {
  let cwd = !!options && !!options.cwd ? options.cwd : process.cwd()
  success('Styleguide.new:', 'initialize styleguide ...')
  return new Styleguide()
    .initialize(cwd)
    .then(function (styleguide) {
      success('Styleguide.new:', 'initialize finished')
      if (!options || !options.prepare) {
        success('Styleguide.prepare:', 'preparing the styleguide target ...')
        return styleguide.prepare()
      } else {
        return Promise.resolve(styleguide)
      }
    })
}
1176010
def new
      # raise params.inspect
      @questions = "Qe::#{params[:element_type]}".constantize.active.order('label')
      params[:element] ||= {}
      if params[:element][:style]
        @questions = @questions.where(:style => params[:element][:style]).all.uniq
      end
    end
1158724
def cli(yaml_paths, pptx_template_path, font_size, master_slide_idx, slide_layout_idx, dst_dir, font_name,
        slide_txt_alignment, validate):
    

    dst_dir = Path(dst_dir)

    pptx_template_path = Path(pptx_template_path)
    pptx_template = pick_master_slide(pptx_template_path)

    yamlfiles = []
    for yaml_path in yaml_paths:
        yaml_path = Path(yaml_path)
        if yaml_path.is_dir():
            yamlfiles.extend([yml for yml in yaml_path.iterdir()])
        else:
            yamlfiles.append(yaml_path)

    if validate:
        exit_fail = False
        for yamlfile in yamlfiles:
            try:
                validate_yaml_file(SCHEMA_FOR_YAML, Path(yamlfile))
                msg = f"VALIDATE: Validation of {yamlfile} passed"
                click.echo(click.style(msg, fg="blue"))
            except jsonschema.exceptions.ValidationError as err:
                msg = f"ERR: {yamlfile} {str(err.message)} {err.path}"
                click.echo(click.style(msg, fg="red"), nl=True)
                exit_fail = True
            except Exception:
                raise
        if exit_fail:
            sys.exit(1)

    for yamlfile in yamlfiles:
        try:
            r = build_slide(
                    Path(yamlfile),
                    pptx_template,
                    master_slide_idx,
                    slide_layout_idx,
                    font_size,
                    dst_dir,
                    font_name,
                    slide_txt_alignment
                )
            msg = f"PPTX: {r}"
            click.echo(click.style(msg, fg="green"))
        except Exception:
            raise
914748
def remember_validation_metadata(validation_type, *attr_names)
        configuration = attr_names.last.is_a?(::Hash) ? attr_names.pop : {}
        self.validations ||= []
        attr_names.flatten.each do |attr_name|
          self.validations << ::ActiveRecord::Reflection::MacroReflection.new(validation_type, attr_name.to_sym, configuration, self)
        end
      end
968588
def compile_scss
        puts "\nCompiling assets for stylestats...".color(:blue)
        if is_rails?

          # Get rake tasks
          Rails.application.load_tasks unless @config.is_dev?
          compile_scss_rails
        else

          load_compass

          compile_scss
        end
      end
725462
def method_missing(method_name, *args, &block)
      config = Loquacious::Configuration.for method_name, &block
      raise Adhearsion::Configuration::ConfigurationError.new "Invalid plugin #{method_name}" if config.nil?
      config
    end
1058425
def params
      {}.
      merge!(measurable_params).
      merge!(custom_dimensions).
      merge!(custom_metrics).
      reject {|_,v| v.nil?}
    end
1351604
def on_ok(self):
        
        # ensure user didn't have any syntactical errors
        input_is_good, trimmed_input = self.valid_input(self.edit_space.value)
        if not input_is_good:
            return
        self.edit_space.value = trimmed_input

        # get the number of instances and ensure user didn't malform that
        if re.search(r'instances\ *=', self.edit_space.value):
            try:
                # split out spaces
                instances_val = re.split(r'instances\ *=\ *',
                                         self.edit_space.value)[1]
                instances_val = instances_val.split('\n')[0]
                new_instances = int(re.match(r'\d+$', instances_val).group())
            except AttributeError:
                npyscreen.notify_confirm("You didn't specify a valid number"
                                         ' for instances.', title='Invalid'
                                         ' instance number')
                return
            # user can't change instances when configuring new instnaces
            if (self.instance_cfg and
                    self.settings['new_instances'] != new_instances):
                npyscreen.notify_confirm("You can't change the number of"
                                         ' instnaces while configuring new'
                                         ' instances!', title='Illegal change')
                return
            # get old number of instances
            try:
                if 'old_instances' in self.settings:
                    old_instances = self.settings['old_instances']
                else:
                    settings_dict = json.loads(
                        self.manifest.option(self.section,
                                             'settings')[1])
                    old_instances = int(settings_dict['instances'])
            except Exception:
                old_instances = 1
        else:
            new_instances = 1
            old_instances = 1

        # save changes and update manifest we're looking at with changes
        if self.vent_cfg:
            save_args = {'main_cfg': True,
                         'config_val': self.edit_space.value}
            self.manifest = self.settings['save_configure'](**save_args)[1]
        else:
            save_args = copy.deepcopy(self.tool_identifier)
            save_args.update({'config_val': self.edit_space.value})
            if self.registry_tool:
                save_args.update({'from_registry': True})
            if self.instance_cfg:
                save_args.update({'instances': new_instances})
            self.manifest = self.settings['save_configure'](**save_args)[1]

        # restart tools, if necessary
        if not self.just_downloaded and not self.instance_cfg:
            restart_kargs = {'main_cfg': self.vent_cfg,
                             'old_val': self.config_val,
                             'new_val': self.edit_space.value}
            if self.vent_cfg:
                wait_str = 'Restarting tools affected by changes...'
            else:
                wait_str = 'Restarting this tool with new settings...'
                restart_kargs.update(self.tool_identifier)
            npyscreen.notify_wait(wait_str,
                                  title='Restarting with changes')
            self.settings['restart_tools'](**restart_kargs)

        # start new instances if user wanted to
        if self.instance_cfg and self.settings['start_new']:
            npyscreen.notify_wait('Starting new instances...',
                                  title='Start')
            tool_d = {}
            for i in range(self.settings['old_instances'] + 1,
                           self.settings['new_instances'] + 1):
                # create section by scrubbing instance number out of names
                # and adding new instance number
                i_section = self.section.rsplit(':', 2)
                i_section[0] = re.sub(r'[0-9]', '', i_section[0]) + str(i)
                i_section = ':'.join(i_section)
                t_name = self.manifest.option(i_section, 'name')[1]
                t_id = {'name': t_name}
                tool_d.update(self.settings['prep_start'](**t_id)[1])
            if tool_d:
                self.settings['start_tools'](tool_d)

        # prompt user for instance changes, as necessary
        if not self.instance_cfg and not self.vent_cfg:
            if new_instances > old_instances:
                try:
                    diff = str(new_instances - old_instances)
                    res = npyscreen.notify_yes_no('You will be creating ' +
                                                  diff + ' additional'
                                                  ' instance(s) is that okay?',
                                                  title='Confirm new'
                                                  ' instance(s)')
                    if res:
                        if self.manifest.option(self.section,
                                                'built')[1] == 'yes':
                            run = npyscreen.notify_yes_no('Do you want to'
                                                          ' start these new'
                                                          ' tools upon'
                                                          ' creation?',
                                                          title='Run new'
                                                          ' instance(s)')
                        else:
                            run = False
                        # get clean name (no instance numbers in it)
                        new_name = self.settings['tool_name']
                        new_name = re.sub(r'[0-9]+$', '', new_name)
                        self.settings['tool_name'] = new_name
                        npyscreen.notify_wait('Pulling up default settings'
                                              ' for ' +
                                              self.settings['tool_name'] +
                                              '...',
                                              title='Gathering settings')
                        Repository(System().manifest)._clone(
                            self.settings['repo'])
                        self.settings['new_instances'] = new_instances
                        self.settings['old_instances'] = old_instances
                        self.settings['start_new'] = run
                        self.settings['new_instance'] = True
                        self.settings['name'] = 'Configure new instance(s)' + \
                            ' for ' + self.settings['tool_name']
                        self.parentApp.addForm('INSTANCEEDITOR' +
                                               self.settings['tool_name'],
                                               EditorForm, **self.settings)
                        self.parentApp.change_form('INSTANCEEDITOR' +
                                                   self.settings['tool_name'])
                    else:
                        return
                except Exception:
                    npyscreen.notify_confirm('Trouble finding tools to add,'
                                             ' exiting', title='Error')
                    self.on_cancel()
            elif new_instances < old_instances:
                try:
                    diff = str(old_instances - new_instances)
                    res = npyscreen.notify_yes_no('You will be deleting ' +
                                                  diff + ' instance(s), is'
                                                  ' that okay?',
                                                  title='Confirm delete'
                                                  ' instance(s)')
                    if res:
                        form_name = 'Delete instances for ' + \
                            re.sub(r'\d+$', '',
                                   self.settings['tool_name']) + '\t'*8 + \
                            '^E to exit configuration process'
                        clean_section = self.section.rsplit(':', 2)
                        clean_section[0] = re.sub(r'\d+$', '',
                                                  clean_section[0])
                        clean_section = ':'.join(clean_section)
                        d_args = {'name': form_name,
                                  'new_instances': new_instances,
                                  'old_instances': old_instances,
                                  'next_tool': self.settings['next_tool'],
                                  'manifest': self.manifest,
                                  'section': clean_section,
                                  'clean': self.settings['clean'],
                                  'prep_start': self.settings['prep_start'],
                                  'start_tools': self.settings['start_tools']}
                        self.parentApp.addForm('DELETER' +
                                               self.settings['tool_name'],
                                               DeleteForm, **d_args)
                        self.parentApp.change_form('DELETER' +
                                                   self.settings['tool_name'])
                except Exception:
                    npyscreen.notify_confirm('Trouble finding instances to'
                                             ' delete, exiting', title='Error')
                    self.on_cancel()

        if (new_instances == old_instances or
                self.instance_cfg or self.vent_cfg):
            npyscreen.notify_confirm('Done configuring ' +
                                     self.settings['tool_name'],
                                     title='Configurations saved')
            self.change_screens()
1236678
def process_styles (out)
      out.gsub /(<style\b[^>]*?>([\s\S]*?)<\/style>)\s*/i do
        css = $2
        m = $1.gsub /^<style\s([^>]+)>/i do |m|
          attrs(m, 'style', true)
        end
        begin
          css_compressed = MultiCss.min css
          m.gsub!(css, css_compressed)
        rescue Exception => e
          log e.message
        end
        reserve m
      end
    end
1231492
def run
      results = { }
      keyboards.each do |keyboard|
        # set up container vars
        prev_hand = nil
        alternation_effort = 0
        reach_effort = 0
        open_and_process(filename,'r') do |file|
          while line = file.gets
            line.each_char do |char|
              if effort = keyboard::MAP[char]

                # measure alternation efficiency
                hand = keyboard::LEFT_KEYS.include?(char) ? 'l' : 'r'
                if prev_hand
                  alternation_effort += (hand == prev_hand) ? 1 : 0
                end
                prev_hand = hand

                # measure reach efficiency
                reach_effort += effort
              end

            end
          end
        end

        results[keyboard::NAME.to_sym] = {
          :alternation_effort => alternation_effort,
          :reach_effort => reach_effort,
          :raw_score => (alternation_effort + reach_effort)
        }
      end
      results
    end
451080
function metrics(context) {
  //x-height
  context.fillStyle = 'blue'
  context.fillRect(0, -layout.height + layout.baseline, 15, -layout.xHeight)

  //ascender
  context.fillStyle = 'pink'
  context.fillRect(27, -layout.height, 36, layout.ascender)

  //cap height
  context.fillStyle = 'yellow'
  context.fillRect(110, -layout.height + layout.baseline , 18, -layout.capHeight)

  //baseline
  context.fillStyle = 'orange'
  context.fillRect(140, -layout.height, 36, layout.baseline)

  //descender
  context.fillStyle = 'green'
  context.fillRect(0, 0, 30, layout.descender)

  //line height
  context.fillStyle = 'red'
  context.fillRect(0, -layout.height + layout.baseline, 52, layout.lineHeight)
  
  //bounds
  context.strokeRect(0, 0, layout.width, -layout.height)
}
73036
def size
      size = {
        width:  @width,
        height: @height
      }

      # Specific size
      unless @options[:width].nil? && @options[:height].nil?
        size[:width]  = @options[:width].nil?  ? calculate_width(@options[:height]) : @options[:width]
        size[:height] = @options[:height].nil? ? calculate_height(@options[:width]) : @options[:height]
      end

      size
    end