lib/ldap_helper.rb
Method update_institutional_groups_from_ldap_localfile
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def update_institutional_groups_from_ldap_localfile
JSON.parse(File.read("db/ldap.json")).each do |entry|
entry = entry["myhash"]
begin
next unless (entry["name"] and entry["extensionattribute1"] and entry["extensionattribute3"])
- Read upRead up
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 fetch_from_ldap
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def fetch_from_ldap
ldap_config ||= YAML::load_file("#{Rails.root}/tmp/ldap.yml")
ldap = Net::LDAP.new :host => ldap_config[Rails.env]["host"],
:port => ldap_config[Rails.env]["port"].to_i,
- Read upRead up
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"