Showing 208 of 212 total issues
The = symbol should have one space separating it from code Open
%span.badge.badge-secondary=variable.value_type.name
- Read upRead up
- Exclude checks
HamlLint/SpaceBeforeScript
Separate Ruby script indicators (-
/=
) from their code with a single space.
Bad: no space between =
and some_expression
haml
=some_expression
Good
haml
= some_expression
Good
haml
- some_value = 'Hello World'
Ensuring space after -
/=
enforces a consistency that all HAML tags/script
indicators are separated from their inline content by a space. Since it is
optional to add a space after -
/=
but required when writing %tag
or
similar, the consistency is best enforced via a linter.
The - symbol should have one space separating it from code Open
-if @variable.description
- Read upRead up
- Exclude checks
HamlLint/SpaceBeforeScript
Separate Ruby script indicators (-
/=
) from their code with a single space.
Bad: no space between =
and some_expression
haml
=some_expression
Good
haml
= some_expression
Good
haml
- some_value = 'Hello World'
Ensuring space after -
/=
enforces a consistency that all HAML tags/script
indicators are separated from their inline content by a space. Since it is
optional to add a space after -
/=
but required when writing %tag
or
similar, the consistency is best enforced via a linter.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
%meta{content: "text/html; charset=utf-8", "http-equiv" => "Content-Type"}/
- Read upRead up
- Exclude checks
HamlLint/RuboCop
Option | Description |
---|---|
ignored_cops |
Array of RuboCop cops to ignore. |
This linter integrates with RuboCop
(a static code analyzer and style enforcer) to check the actual Ruby code in
your templates. It will respect any RuboCop-specific configuration you have
set in .rubocop.yml
files, but will explicitly ignore some checks that
don't make sense in the context of HAML documents (like
Style/BlockAlignment
).
-# example.haml
- name = 'James Brown'
- unused_variable = 42
%p Hello #{name}!
Output from haml-lint
example.haml:3 [W] Useless assignment to variable - unused_variable
You can customize which RuboCop warnings you want to ignore by modifying
the ignored_cops
option (see config/default.yml
for the full list of ignored cops).
You can also explicitly set which RuboCop configuration to use via the
HAML_LINT_RUBOCOP_CONF
environment variable. This is intended to be used
by external tools which run the linter on files in temporary directories
separate from the directory where the HAML template originally resided (and
thus where the normal .rubocop.yml
would be picked up).
Displaying Cop Names
You can display the name of the cop by adding the following to your
.rubocop.yml
configuration:
AllCops:
DisplayCopNames: true
Hash attribute should end with one space before the closing brace Open
%li.breadcrumb-item.active{"aria-current" => "page"}= @variable.name
- Read upRead up
- Exclude checks
HamlLint/SpaceInsideHashAttributes
Check the style of hash attributes against one of two possible preferred
styles, space
(default) or no_space
:
Bad: inconsistent spacing inside hash attributes braces
haml
%tag{ foo: bar}
%tag{foo: bar }
%tag{ foo: bar }
With default space
style option: require a single space inside
hash attributes braces
haml
%tag{ foo: bar }
With no_space
style option: require no space inside
hash attributes braces
haml
%tag{foo: bar}
This offers the ability to ensure consistency of Haml hash attributes style with ruby hash literal style (compare with the Style/SpaceInsideHashLiteralBraces cop in Rubocop).
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
%meta{content: "width=device-width, initial-scale=1, shrink-to-fit=no", name: "viewport"}/
- Read upRead up
- Exclude checks
HamlLint/RuboCop
Option | Description |
---|---|
ignored_cops |
Array of RuboCop cops to ignore. |
This linter integrates with RuboCop
(a static code analyzer and style enforcer) to check the actual Ruby code in
your templates. It will respect any RuboCop-specific configuration you have
set in .rubocop.yml
files, but will explicitly ignore some checks that
don't make sense in the context of HAML documents (like
Style/BlockAlignment
).
-# example.haml
- name = 'James Brown'
- unused_variable = 42
%p Hello #{name}!
Output from haml-lint
example.haml:3 [W] Useless assignment to variable - unused_variable
You can customize which RuboCop warnings you want to ignore by modifying
the ignored_cops
option (see config/default.yml
for the full list of ignored cops).
You can also explicitly set which RuboCop configuration to use via the
HAML_LINT_RUBOCOP_CONF
environment variable. This is intended to be used
by external tools which run the linter on files in temporary directories
separate from the directory where the HAML template originally resided (and
thus where the normal .rubocop.yml
would be picked up).
Displaying Cop Names
You can display the name of the cop by adding the following to your
.rubocop.yml
configuration:
AllCops:
DisplayCopNames: true
Hash attribute should end with one space before the closing brace Open
%img{alt: "OpenFisca", height: "24", src: "https://openfisca.org/img/logo-openfisca.svg"}/
- Read upRead up
- Exclude checks
HamlLint/SpaceInsideHashAttributes
Check the style of hash attributes against one of two possible preferred
styles, space
(default) or no_space
:
Bad: inconsistent spacing inside hash attributes braces
haml
%tag{ foo: bar}
%tag{foo: bar }
%tag{ foo: bar }
With default space
style option: require a single space inside
hash attributes braces
haml
%tag{ foo: bar }
With no_space
style option: require no space inside
hash attributes braces
haml
%tag{foo: bar}
This offers the ability to ensure consistency of Haml hash attributes style with ruby hash literal style (compare with the Style/SpaceInsideHashLiteralBraces cop in Rubocop).
Line is too long. [121/100] Open
= link_to 'More info on formulas', 'https://openfisca.org/doc/coding-the-legislation/10_basic_example.html'
- Read upRead up
- Exclude checks
HamlLint/LineLength
Option | Description |
---|---|
max |
Maximum number of columns a single line can have. (default 80 ) |
Wrap lines at 80 characters. You can configure this amount via the max
option on the linter, e.g. by adding the following to your .haml-lint.yml
:
linters:
LineLength:
max: 100
Long lines are harder to read and usually indicative of complexity. You can avoid them by splitting long attribute hashes on a comma, for example:
%tag{ attr1: 1,
attr2: 2,
attr3: 3 }
This significantly improves readability.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
%li.breadcrumb-item.active{"aria-current" => "page"}= @variable.name
- Read upRead up
- Exclude checks
HamlLint/RuboCop
Option | Description |
---|---|
ignored_cops |
Array of RuboCop cops to ignore. |
This linter integrates with RuboCop
(a static code analyzer and style enforcer) to check the actual Ruby code in
your templates. It will respect any RuboCop-specific configuration you have
set in .rubocop.yml
files, but will explicitly ignore some checks that
don't make sense in the context of HAML documents (like
Style/BlockAlignment
).
-# example.haml
- name = 'James Brown'
- unused_variable = 42
%p Hello #{name}!
Output from haml-lint
example.haml:3 [W] Useless assignment to variable - unused_variable
You can customize which RuboCop warnings you want to ignore by modifying
the ignored_cops
option (see config/default.yml
for the full list of ignored cops).
You can also explicitly set which RuboCop configuration to use via the
HAML_LINT_RUBOCOP_CONF
environment variable. This is intended to be used
by external tools which run the linter on files in temporary directories
separate from the directory where the HAML template originally resided (and
thus where the normal .rubocop.yml
would be picked up).
Displaying Cop Names
You can display the name of the cop by adding the following to your
.rubocop.yml
configuration:
AllCops:
DisplayCopNames: true