ElMassimo/vite_ruby

View on GitHub

Showing 22 of 22 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

createServer(page => createInertiaApp({
  page,
  render: renderToString,
  resolve: name => pages[`../Pages/${name}.vue`],
  setup ({ app, props, plugin }) {
Severity: Major
Found in vite-plugin-rails/example/app/frontend/ssr/ssr.ts and 1 other location - About 3 hrs to fix
vite-plugin-ruby/example/app/frontend/ssr/ssr.ts on lines 10..19

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 102.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

createServer(page => createInertiaApp({
  page,
  render: renderToString,
  resolve: name => pages[`../Pages/${name}.vue`],
  setup ({ app, props, plugin }) {
Severity: Major
Found in vite-plugin-ruby/example/app/frontend/ssr/ssr.ts and 1 other location - About 3 hrs to fix
vite-plugin-rails/example/app/frontend/ssr/ssr.ts on lines 8..17

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 102.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Class Config has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

class ViteRuby::Config
  def origin
    "#{ protocol }://#{ host_with_port }"
  end

Severity: Minor
Found in vite_ruby/lib/vite_ruby/config.rb - About 2 hrs to fix

    Class Manifest has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class ViteRuby::Manifest
      def initialize(vite_ruby)
        @vite_ruby = vite_ruby
        @build_mutex = Mutex.new if config.auto_build
      end
    Severity: Minor
    Found in vite_ruby/lib/vite_ruby/manifest.rb - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          {
            text: 'FAQs',
            items: [
              { text: 'Troubleshooting', link: '/guide/troubleshooting' },
              { text: 'Motivation', link: '/motivation' },
      Severity: Major
      Found in docs/.vitepress/config.ts and 1 other location - About 1 hr to fix
      docs/.vitepress/config.ts on lines 54..63

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 73.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            {
              text: 'Changelogs',
              items: [
                { text: 'vite-plugin-ruby', link: 'https://github.com/ElMassimo/vite_ruby/blob/main/vite-plugin-ruby/CHANGELOG.md' },
                { text: 'Vite Ruby', link: 'https://github.com/ElMassimo/vite_ruby/blob/main/vite_ruby/CHANGELOG.md' },
      Severity: Major
      Found in docs/.vitepress/config.ts and 1 other location - About 1 hr to fix
      docs/.vitepress/config.ts on lines 93..102

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 73.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function config has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function config (userConfig: UserConfig, env: ConfigEnv): UserConfig {
        const config = loadConfiguration(env.mode, projectRoot, userConfig)
        const { assetsDir, base, outDir, server, root, entrypoints, ssrBuild } = config
      
        const isLocal = config.mode === 'development' || config.mode === 'test'
      Severity: Minor
      Found in vite-plugin-ruby/src/index.ts - About 1 hr to fix

        Function assetsManifestPlugin has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function assetsManifestPlugin (): Plugin {
          let config: ResolvedConfig
          let viteRubyConfig: UnifiedConfig
        
          // Internal: Vite ignores some entrypoint assets, so we need to manually
        Severity: Minor
        Found in vite-plugin-ruby/src/manifest.ts - About 1 hr to fix

          Method run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def run(argv, exec: false)
              config.within_root {
                cmd = command_for(argv)
                return Kernel.exec(*cmd) if exec
          
          
          Severity: Minor
          Found in vite_ruby/lib/vite_ruby/runner.rb - About 45 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

          Function coerceConfigurationValues has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function coerceConfigurationValues (config: ResolvedConfig, projectRoot: string, userConfig: UserConfig): UnifiedConfig {
            // Coerce the values to the expected types.
            const port = config.port = parseInt(config.port as unknown as string)
            const https = config.https = userConfig.server?.https || booleanOption(config.https)
          
          
          Severity: Minor
          Found in vite-plugin-ruby/src/config.ts - About 45 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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            def vite_image_tag(name, **options)
              if options[:srcset] && !options[:srcset].is_a?(String)
                options[:srcset] = options[:srcset].map do |src_name, size|
                  "#{ vite_asset_path(src_name) } #{ size }"
                end.join(', ')
          Severity: Minor
          Found in vite_rails_legacy/lib/vite_rails_legacy/tag_helpers.rb and 1 other location - About 35 mins to fix
          vite_rails/lib/vite_rails/tag_helpers.rb on lines 72..79

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            def vite_image_tag(name, **options)
              if options[:srcset] && !options[:srcset].is_a?(String)
                options[:srcset] = options[:srcset].map do |src_name, size|
                  "#{ vite_asset_path(src_name) } #{ size }"
                end.join(', ')
          Severity: Minor
          Found in vite_rails/lib/vite_rails/tag_helpers.rb and 1 other location - About 35 mins to fix
          vite_rails_legacy/lib/vite_rails_legacy/tag_helpers.rb on lines 61..68

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Method call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def call(mode:, args: [], clobber: false, node_options: nil, inspect: nil, trace_deprecation: nil, **boolean_opts)
              ViteRuby.env['VITE_RUBY_MODE'] = mode
              ViteRuby.commands.clobber if clobber
          
              node_options = [
          Severity: Minor
          Found in vite_ruby/lib/vite_ruby/cli/vite.rb - About 35 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 log_build_result has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def log_build_result(_stdout, stderr, status)
              if status.success?
                logger.info "Build with Vite complete: #{ config.build_output_dir }"
                logger.error stderr unless stderr.empty?
              else
          Severity: Minor
          Found in vite_ruby/lib/vite_ruby/builder.rb - About 35 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 parse_metadata has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_metadata(pathname)
                return default_metadata unless pathname.exist?
          
                JSON.parse(pathname.read.to_s).transform_keys(&:to_sym).slice(*members)
              rescue JSON::JSONError, Errno::ENOENT, Errno::ENOTDIR
          Severity: Minor
          Found in vite_ruby/lib/vite_ruby/build.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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            initializer 'vite_rails.bootstrap' do
              if defined?(Rails::Server) || defined?(Rails::Console)
                ViteRuby.bootstrap
                if defined?(Spring)
                  require 'spring/watcher'
          Severity: Minor
          Found in vite_rails_legacy/lib/vite_rails_legacy/engine.rb and 1 other location - About 25 mins to fix
          vite_rails/lib/vite_rails/engine.rb on lines 26..34

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 30.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          export function assetsManifestPlugin (): Plugin {
            let config: ResolvedConfig
            let viteRubyConfig: UnifiedConfig
          
            // Internal: Vite ignores some entrypoint assets, so we need to manually
          Severity: Minor
          Found in vite-plugin-ruby/src/manifest.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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            initializer 'vite_rails.bootstrap' do
              if defined?(Rails::Server) || defined?(Rails::Console)
                ViteRuby.bootstrap
                if defined?(Spring)
                  require 'spring/watcher'
          Severity: Minor
          Found in vite_rails/lib/vite_rails/engine.rb and 1 other location - About 25 mins to fix
          vite_rails_legacy/lib/vite_rails_legacy/engine.rb on lines 26..34

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 30.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            def config_defaults
              require 'rails'
              asset_host = Rails.application&.config&.action_controller&.asset_host
              super(
                asset_host: asset_host.is_a?(Proc) ? nil : asset_host,
          Severity: Minor
          Found in vite_rails/lib/vite_rails/config.rb and 1 other location - About 25 mins to fix
          vite_rails_legacy/lib/vite_rails_legacy/config.rb on lines 5..12

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 29.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            def config_defaults
              require 'rails'
              asset_host = Rails.application&.config&.action_controller&.asset_host
              super(
                asset_host: asset_host.is_a?(Proc) ? nil : asset_host,
          Severity: Minor
          Found in vite_rails_legacy/lib/vite_rails_legacy/config.rb and 1 other location - About 25 mins to fix
          vite_rails/lib/vite_rails/config.rb on lines 7..14

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 29.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language