Giter Site home page Giter Site logo

Comments (5)

Confusion avatar Confusion commented on June 28, 2024

I think that is a bit too much. I removed some newlines and the resulting version seems more coherent to me:

def enforce_ssl?(req)
  enforce = false
  keys_by_type = { 
    :hosts => [:only_hosts, :except_hosts], :path => [:only, :except], 
    :methods => [:only_methods, :except_methods] 
  }

  if !keys_by_type.values.flatten.compact.any? { |option| @options[option] }
    return true
  end

  keys_by_type.keys.each do |type|
    enforce = enforce_ssl_for?(keys_by_type[type], req)
    next unless enforce

    keys_by_type.each do |other_type,sub_keys|
      next if type == other_type || !sub_keys.any? { |option| @options[option] }
      enforce = enforce_ssl_for?(sub_keys, req)
      break unless enforce
    end

    break if enforce
  end

  enforce   
end

from ruby-style-guide.

volontarian avatar volontarian commented on June 28, 2024

Looks good for me, too :-)

from ruby-style-guide.

calebhearth avatar calebhearth commented on June 28, 2024

I like to organize code into logical blocks like @Confusion's example. Lines can still belong together even if they aren't in the same control block.

from ruby-style-guide.

mikecmpbll avatar mikecmpbll commented on June 28, 2024

this is the single biggest problem with code style consistency across our codebases and we don't have the power to do anything about it with rubocop atm. i know this is closed but it's a huge +1 from me :).

from ruby-style-guide.

pirj avatar pirj commented on June 28, 2024

@mikecmpbll I suggest you contribute a cop to RuboCop that would take care of this.
There doesn't seem to be enough feedback to add this as a guideline to the style guide yet.

from ruby-style-guide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.