reactrb/reactrb

View on GitHub
lib/react/ext/string.rb

Summary

Maintainability
A
0 mins
Test Coverage

Use %x around command string.
Open

    `#{self}.replace(/(^|_)([^_]+)/g, function(match, pre, word, index) {
      var capitalize = true;
      return capitalize ? word.substr(0,1).toUpperCase()+word.substr(1) : word;
    })`
Severity: Minor
Found in lib/react/ext/string.rb by rubocop

This cop enforces using `` or %x around command literals.

Example: EnforcedStyle: backticks (default)

# bad
folders = %x(find . -type d).split

# bad
%x(
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
)

# good
folders = `find . -type d`.split

# good
`
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
`

Example: EnforcedStyle: mixed

# bad
folders = %x(find . -type d).split

# bad
`
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
`

# good
folders = `find . -type d`.split

# good
%x(
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
)

Example: EnforcedStyle: percent_x

# bad
folders = `find . -type d`.split

# bad
`
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
`

# good
folders = %x(find . -type d).split

# good
%x(
  ln -s foo.example.yml foo.example
  ln -s bar.example.yml bar.example
)

Example: AllowInnerBackticks: false (default)

# If `false`, the cop will always recommend using `%x` if one or more
# backticks are found in the command string.

# bad
`echo \`ls\``

# good
%x(echo `ls`)

Example: AllowInnerBackticks: true

# good
`echo \`ls\``

There are no issues that match your filters.

Category
Status