Showing 10 of 10 total issues
Method action_enable
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def action_enable
notifying_block do
# Create user
poise_service_user new_resource.user
# Install Packages
Access node attributes in a consistent manner Open
case node.platform_family
- Read upRead up
- Exclude checks
Node attributes can be accessed in multiple ways in Chef. This warning is shown when a cookbook is not consistent in the approach it uses to access attributes. It is not displayed for variations between cookbooks.
Access node attributes in a consistent manner Open
service.options :sysvinit, template: "opentsdb:etc/init.d/opentsdb_#{node.platform_family}.erb"
- Read upRead up
- Exclude checks
Node attributes can be accessed in multiple ways in Chef. This warning is shown when a cookbook is not consistent in the approach it uses to access attributes. It is not displayed for variations between cookbooks.
Access node attributes in a consistent manner Open
if node.platform_family == 'rhel'
- Read upRead up
- Exclude checks
Node attributes can be accessed in multiple ways in Chef. This warning is shown when a cookbook is not consistent in the approach it uses to access attributes. It is not displayed for variations between cookbooks.
Method action_enable
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def action_enable
notifying_block do
# Create user
poise_service_user new_resource.user
# Install Packages
- 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
Prefer conditional attributes Open
if node.platform_family == 'rhel'
- Read upRead up
- Exclude checks
This warning means you have surrounded a resource with an if
or unless
rather than defining the condition directly on the resource itself. Note
that this warning is only raised for single resources as you could
reasonably enclose multiple resources in a condition like this for
brevity.
Jay Feldblum has expressed criticism of this rule because the effect is that resources are defined unnecessarily and ignored only at run-time. His view is that it is cleaner to use standard Ruby conditionals to avoid defining them in the first place.
Use file_cache_path rather than hard-coding tmp paths Open
remote_file "#{new_resource.instance} :create opentsdb-#{new_resource.version}#{distro_ext}" do
- Read upRead up
- Exclude checks
This warning means that you have hard-coded a file download path in your
cookbook to a temporary directory. This can be a problem on boxes built
with a small /tmp
mount point. Chef has its own configuration option
file_cache_path
you should use instead:
Ensure source_url is set in metadata Open
name 'opentsdb'
- Read upRead up
- Exclude checks
This warning is shown if a cookbook does not include the source_url property in its metadata file. source_url is used to point to the source location for the cookbook and is currently parsed by Supermarket to add links to community cookbooks. Note: source_url is a Chef 12 only feature that will cause cookbook failures in Chef 11 so it should be properly gated if the code will be run on Chef 11 hosts.
Use 0o for octal literals. Open
mode 0644
- Read upRead up
- Exclude checks
This cop checks for octal, hex, binary and decimal literals using
uppercase prefixes and corrects them to lowercase prefix
or no prefix (in case of decimals).
eg. for octal use 0o
instead of 0
or 0O
.
Can be configured to use 0
only for octal literals using
EnforcedOctalStyle
=> zero_only
Ensure issues_url is set in metadata Open
name 'opentsdb'
- Read upRead up
- Exclude checks
This warning is shown if a cookbook does not include the issues_url property in its metadata file. issues_url is used to point to the location for submitting issues (bugs) for the cookbook and is currently parsed by Supermarket to add links to community cookbooks. Note: issues_url is a Chef 12 only feature that will cause cookbook failures in Chef 11 so it should be properly gated if the code will be run on Chef 11 hosts.