shakacode/react_on_rails

View on GitHub

Showing 44 of 44 total issues

Avoid too many return statements within this function.
Open

  return React.createElement(component as ReactComponent, props);
Severity: Major
Found in node_package/src/createReactOutput.ts - About 30 mins to fix

    Function renderInit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function renderInit(): void {
      // Install listeners when running on the client (browser).
      // We must do this check for turbolinks AFTER the document is loaded because we load the
      // Webpack bundles first.
      if ((!turbolinksInstalled() || !turbolinksSupported()) && !turboInstalled()) {
    Severity: Minor
    Found in node_package/src/clientStartup.ts - About 25 mins to fix

    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 json_safe_and_pretty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def json_safe_and_pretty(hash_or_string)
          return "{}" if hash_or_string.nil?
    
          unless hash_or_string.is_a?(String) || hash_or_string.is_a?(Hash)
            raise ReactOnRails::Error, "#{__method__} only accepts String or Hash as argument " \
    Severity: Minor
    Found in lib/react_on_rails/helper.rb - About 25 mins to fix

    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 server_bundle_js_file_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.server_bundle_js_file_path
          # Either:
          # 1. Using same bundle for both server and client, so server bundle will be hashed in manifest
          # 2. Using a different bundle (different Webpack config), so file is not hashed, and
          #    bundle_js_path will throw so the default path is used without a hash.
    Severity: Minor
    Found in lib/react_on_rails/utils.rb - About 25 mins to fix

    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

    Severity
    Category
    Status
    Source
    Language