### Install Clean Architecture Gem Source: https://github.com/udn/clean-architecture/blob/main/README.md This snippet shows how to add the 'clean-architecture' gem to your application's Gemfile and execute the necessary bundle commands to install it and its binstubs. ```ruby gem 'clean-architecture' ``` ```bash $ bundle install $ bundle binstubs clean-architecture ``` -------------------------------- ### General Naming Conventions and Static Initialization Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet addresses general 'wrong constant name' issues and references to '' across the project. It includes examples related to file fixtures, setup/teardown callbacks, and time manipulation methods like freeze_time, travel, travel_back, travel_to, and unfreeze_time. This indicates a need for consistent and clear naming practices throughout the codebase. ```ruby # wrong constant name file_fixture # wrong constant name # wrong constant name after_teardown # wrong constant name before_setup # wrong constant name # wrong constant name prepended # wrong constant name before_setup # wrong constant name tagged_logger= # wrong constant name # wrong constant name after_teardown # wrong constant name freeze_time # wrong constant name travel # wrong constant name travel_back # wrong constant name travel_to # wrong constant name unfreeze_time # wrong constant name ``` -------------------------------- ### Sorbet: Undefined Singleton Method Examples Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Details 'undefined singleton method' errors in Sorbet, indicating that a specified method does not exist on a singleton class or object. ```ruby # undefined singleton method `header1' for `Sorbet::Private::Serialize' # undefined singleton method `header2' for `Sorbet::Private::Serialize' # undefined singleton method `say1' for `Sorbet::Private::Status' ``` -------------------------------- ### Handle Specific Errors with Fail Message in Ruby Source: https://github.com/udn/clean-architecture/blob/main/README.md This example demonstrates how to use `fail_with_error_message` to return a specific error message wrapped in an `Errors` instance. It includes conditional logic to return an error under certain circumstances, allowing the controller to react differently based on the error type. ```ruby module MyBusinessDomain module UseCases class UserUpdatesChristmasWishlist < CleanArchitecture::UseCases::AbstractUseCase contract do option :required_gateway_object params do required(:user_id).filled(:int) required(:most_wanted_gift).filled(:str) end end include Dry::Monads::Do.for(:result) CHRISTMAS_DAY = Date.new('2019', '12', '25') def result valid_params = yield result_of_validating_params if Date.today == CHRISTMAS_DAY return fail_with_error_message('Uh oh, Santa has already left the North Pole!') end context(:required_gateway_object).change_most_wanted_gift(user_id, most_wanted_gift) end end end end ``` -------------------------------- ### Sorbet: Uninitialized Constant Examples Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Addresses 'uninitialized constant' errors in Sorbet, which occur when a constant is referenced before it has been assigned a value. ```ruby # uninitialized constant Sorbet::Private::Static # uninitialized constant Sorbet::Private::Static # uninitialized constant SortedSet::InspectKey ``` -------------------------------- ### Sorbet: Undefined Method Examples Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Highlights 'undefined method' errors in Sorbet, signaling that a method call is being made on an object for which the method is not defined. ```ruby # undefined method `initialize1' for class `StackProf::Middleware' # undefined method `truncate_bytes1' for class `String' # undefined method `close1' for class `Tempfile' # undefined method `initialize1' for class `Tempfile' ``` -------------------------------- ### Validate Parameters and Return Success with Dry-Monads in Ruby Source: https://github.com/udn/clean-architecture/blob/main/README.md This example shows a use case that validates parameters and returns a successful result using `dry-monads`. The `result_of_validating_params` method is used within a `Do` block to handle the Result monad, transforming valid parameters into a desired output. ```ruby module MyBusinessDomain module UseCases class UserUpdatesAge < CleanArchitecture::UseCases::AbstractUseCase contract do params do required(:user_id).filled(:int) required(:age).filled(:int) end end include Dry::Monads::Do.for(:result) def result valid_params = yield result_of_validating_params Dry::Monads::Success(valid_params[:age] * 365) end end end end ``` -------------------------------- ### Sorbet: Wrong Constant Name Examples Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Illustrates common 'wrong constant name' errors in Sorbet, which occur when identifiers do not follow Ruby's constant naming conventions or are reserved keywords. ```ruby # wrong constant name class_or_module # wrong constant name comparable? # wrong constant name constant # wrong constant name from_method # wrong constant name initialize # wrong constant name serialize_method1 # wrong constant name serialize_method2 # wrong constant name serialize_method # wrong constant name serialize_sig # wrong constant name to_sig # wrong constant name valid_class_name # wrong constant name valid_method_name # wrong constant name # wrong constant name header1 # wrong constant name header2 # wrong constant name header # wrong constant name done # wrong constant name say1 # wrong constant name say # wrong constant name # wrong constant name main # wrong constant name output_file # wrong constant name suggest_typed # wrong constant name main # wrong constant name output_file # wrong constant name initialize # wrong constant name setup # wrong constant name # wrong constant name call # wrong constant name initialize1 # wrong constant name initialize # wrong constant name # wrong constant name enabled # wrong constant name enabled= # wrong constant name enabled? # wrong constant name interval # wrong constant name interval= # wrong constant name metadata # wrong constant name metadata= # wrong constant name mode # wrong constant name mode= # wrong constant name path # wrong constant name path= # wrong constant name raw # wrong constant name raw= # wrong constant name save # wrong constant name result # wrong constant name []= # wrong constant name casecmp? # wrong constant name each_grapheme_cluster # wrong constant name encode! # wrong constant name grapheme_clusters # wrong constant name reverse! # wrong constant name shellescape # wrong constant name shellsplit # wrong constant name succ! # wrong constant name to_d # wrong constant name truncate_bytes1 # wrong constant name truncate_bytes # wrong constant name undump # wrong constant name unicode_normalize # wrong constant name unicode_normalize! # wrong constant name unicode_normalized? # wrong constant name unpack1 # wrong constant name length # wrong constant name truncate # wrong constant name << # wrong constant name [] # wrong constant name beginning_of_line? # wrong constant name bol? # wrong constant name captures # wrong constant name charpos # wrong constant name check # wrong constant name check_until # wrong constant name clear # wrong constant name concat # wrong constant name empty? # wrong constant name exist? # wrong constant name get_byte # wrong constant name getbyte # wrong constant name initialize # wrong constant name match? # wrong constant name matched # wrong constant name matched? # wrong constant name matched_size # wrong constant name peek # wrong constant name peep # wrong constant name pointer # wrong constant name pointer= # wrong constant name pos # wrong constant name pos= # wrong constant name post_match # wrong constant name pre_match # wrong constant name reset # wrong constant name rest # wrong constant name rest? # wrong constant name rest_size # wrong constant name restsize # wrong constant name scan_full # wrong constant name scan_until # wrong constant name search_full # wrong constant name size # wrong constant name skip # wrong constant name skip_until # wrong constant name string # wrong constant name string= # wrong constant name terminate # wrong constant name unscan # wrong constant name values_at # wrong constant name must_C_version # wrong constant name [] # wrong constant name []= # wrong constant name dig # wrong constant name each_pair # wrong constant name filter # wrong constant name length # wrong constant name members # wrong constant name select # wrong constant name size # wrong constant name to_a # wrong constant name to_h # wrong constant name values # wrong constant name values_at # wrong constant name # wrong constant name errno # wrong constant name status # wrong constant name success? # wrong constant name T.noreturn # wrong constant name T.noreturn # wrong constant name T.untyped ``` -------------------------------- ### Fixing Uninitialized Constants in REXML Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet addresses errors related to uninitialized constants within the REXML library. These issues typically arise when a constant is referenced before it has been assigned a value, often due to typos or incorrect usage. The provided examples highlight specific uninitialized constants within REXML::Attribute, REXML::CData, REXML::DocType, REXML::Document, REXML::Element, and REXML::Entity. Correcting these requires ensuring the constants are properly defined and initialized before use. ```ruby # Example of potential fix (conceptual): # Ensure constants like REXML::Attribute::NAME are properly defined and initialized # For instance, if NAME should represent an attribute's name, ensure it's assigned a string or symbol value. # Original problematic lines: # uninitialized constant REXML::Attribute::NAME # uninitialized constant REXML::CData::EREFERENCE # ... and many others listed in the input. ``` -------------------------------- ### Instantiate Use Case Input Port Source: https://github.com/udn/clean-architecture/blob/main/README.md Illustrates creating a use case input port object, recommending the BaseParameters interface and its extensions like AuthorizationParameters and TargetedParameters for handling inputs, authorization, and specific object operations. ```ruby input_port = CleanArchitecture::Entities::TargetedParameters.new( use_case_actor, TargetActiveRecordClass.find(params[:id]), strong_params, gateway, other_settings_hash ) ``` -------------------------------- ### Instantiate Use Case Object Source: https://github.com/udn/clean-architecture/blob/main/README.md Shows how to instantiate a use case object, emphasizing the recommendation to implement the UseCase interface for managing application-specific use cases. ```ruby use_case = MyBankingApplication::UseCases::RetailCustomerMakesADeposit.new(input_port) ``` -------------------------------- ### Instantiate Use Case Actor Source: https://github.com/udn/clean-architecture/blob/main/README.md Demonstrates the instantiation of a use case actor object, suggesting adherence to the UseCaseActor interface for managing inputs in a Rails controller. ```ruby use_case_actor = MyUseCaseActorAdapter.new(devise_current_user) ``` -------------------------------- ### Haskell Do Notation Comparison Source: https://github.com/udn/clean-architecture/blob/main/README.md Compares the functional programming style of chaining multiple bind operations in Haskell, demonstrating the transformation from a complex nested structure to a more readable 'do' notation. ```haskell action1 >>= (\ x1 -> action2 >>= (\ x2 -> mk_action3 x1 x2 )) ``` ```haskell do x1 <- action1 x2 <- action2 mk_action3 x1 x2 ``` -------------------------------- ### Transaction Steps with dry-transaction (Ruby) Source: https://github.com/udn/clean-architecture/blob/main/README.md Demonstrates how to define a transaction with multiple steps using the dry-transaction gem. It abstracts the wiring between success/failure objects, allowing developers to define steps and handle input/output flow. ```ruby require "dry/transaction" class CreateUser include Dry::Transaction step :validate step :create private def validate(input) # returns Success(valid_data) or Failure(validation) end def create(input) # returns Success(user) end end ``` -------------------------------- ### Identify Undefined Methods in CodeRay::Duo Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Reports undefined method calls on the `CodeRay::Duo` class. These errors suggest that the methods called either do not exist or are not accessible in the current context, potentially due to version mismatches or incorrect usage. ```text # undefined method `call1' for class `CodeRay::Duo' # undefined method `encode1' for class `CodeRay::Duo' # undefined method `highlight1' for class `CodeRay::Duo' # undefined method `initialize1' for class `CodeRay::Duo' ``` -------------------------------- ### Handle Use Case Execution in a Rails Controller Action (Ruby) Source: https://github.com/udn/clean-architecture/blob/main/README.md This Ruby code demonstrates a Rails controller action for updating a user's nickname. It uses the previously defined Form to build the parameter object for the use case. It then uses Dry::Matcher::ResultMatcher to handle the success or failure outcome of the use case, rendering either a success message or re-rendering the edit form with errors. ```ruby module MyWebApp class NicknamesController < ApplicationController def update Dry::Matcher::ResultMatcher.call(user_updates_nickname.result) do |matcher| matcher.success do |_| flash[:success] = 'Nickname successfully updated' redirect_to action: :edit end matcher.failure do |errors| @form = nickname_update_form.with_errors(errors) render :edit end end end private def user_updates_nickname MyBusinessDomain::UseCases::UserUpdatesNickname.new(nickname_update_form.to_parameter_object) end def nickname_update_form @nickname_update_form ||= NicknameUpdateForm.new( params: params.permit(:user_id, :nickname), context: { my_gateway_object: MyGateway.new } ) end end end ``` -------------------------------- ### Correcting Wrong Constant Names in Ruby Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet focuses on identifying and rectifying errors where Ruby constants have incorrect names. This can lead to `NameError` exceptions, as the interpreter cannot find the intended constant. The examples show common patterns of incorrect constant naming, including issues with default arguments and specific keywords. The solution involves ensuring that all referenced constants adhere to Ruby's naming conventions and accurately reflect their intended purpose. ```ruby # Example of potential fix (conceptual): # Replace 'safe_load5' with the correct constant name, e.g., 'SAFE_LOAD' # Replace 'to_json' with the correct method or constant if it's intended to be a constant. # Original problematic lines: # wrong constant name safe_load5 # wrong constant name to_json # wrong constant name boolean1 # wrong constant name get_namespace1 # ... and many others listed in the input. ``` -------------------------------- ### Handle Uninitialized Constants in Bundler Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Addresses issues related to uninitialized constants within the Bundler gem, specifically concerning 'Bundler::SpecSet::Elem', 'Bundler::VersionRanges::NEq::Elem', 'Bundler::VersionRanges::ReqR::Elem', and 'Bundler::VersionRanges::ReqR::Endpoint::Elem'. This might involve ensuring proper initialization or defining these constants if they are intended to be used. ```ruby # Example of how to handle uninitialized constants: # Ensure that all necessary constants are defined before use. # For instance, if Bundler::SpecSet::Elem should exist, it needs to be declared. # If it's a typo, correct the constant name. # Consider adding checks or default values if appropriate: # begin # constant_value = Bundler::SpecSet::Elem # rescue NameError # constant_value = nil # or some default value # end ``` -------------------------------- ### Create a Form for Use Case Parameter Mapping (Ruby) Source: https://github.com/udn/clean-architecture/blob/main/README.md This Ruby code defines a Form class that acts as a bridge between HTTP parameters and the parameters required by a specific use case (UserUpdatesNickname). This decouples the web application's form logic from the business logic, allowing them to evolve independently. ```ruby module MyWebApp class NicknameUpdateForm < CleanArchitecture::UseCases::Form acts_as_form_for MyBusinessDomain::UseCases::UserUpdatesNickname end end ``` -------------------------------- ### Handle Constant and Method Issues in Bundler::VersionRanges Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet covers 'wrong constant name' and 'uninitialized constant' issues within 'Bundler::VersionRanges', specifically for 'NEq' and 'ReqR'. It includes problems with 'Elem', 'version', and 'version='. The solution involves correcting constant names and defining or fixing methods. ```ruby # Example of fixing constant/method issues in Bundler::VersionRanges: # Ensure 'Bundler::VersionRanges::NEq::Elem' is properly defined. # If 'version' is intended as a method, define it: # def version # # implementation # end ``` -------------------------------- ### Detect Uninitialized Constants in Clean Architecture Entities Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Highlights instances where constants within `ExampleEntity`, `ExampleInterest`, and `FailureDetails` modules are uninitialized. This indicates potential issues with constant definitions or module loading. ```text # uninitialized constant CleanArchitecture::Builders::ExampleEntity::EMPTY_ARRAY # uninitialized constant CleanArchitecture::Builders::ExampleEntity::EMPTY_HASH # uninitialized constant CleanArchitecture::Builders::ExampleEntity::EMPTY_OPTS # uninitialized constant CleanArchitecture::Builders::ExampleEntity::EMPTY_SET # uninitialized constant CleanArchitecture::Builders::ExampleEntity::EMPTY_STRING # uninitialized constant CleanArchitecture::Builders::ExampleEntity::Self # uninitialized constant CleanArchitecture::Builders::ExampleEntity::Undefined # uninitialized constant CleanArchitecture::Builders::ExampleEntity::VERSION # uninitialized constant CleanArchitecture::Builders::ExampleInterest::EMPTY_ARRAY # uninitialized constant CleanArchitecture::Builders::ExampleInterest::EMPTY_HASH # uninitialized constant CleanArchitecture::Builders::ExampleInterest::EMPTY_OPTS # uninitialized constant CleanArchitecture::Builders::ExampleInterest::EMPTY_SET # uninitialized constant CleanArchitecture::Builders::ExampleInterest::EMPTY_STRING # uninitialized constant CleanArchitecture::Builders::ExampleInterest::Self # uninitialized constant CleanArchitecture::Builders::ExampleInterest::Undefined # uninitialized constant CleanArchitecture::Builders::ExampleInterest::VERSION # uninitialized constant CleanArchitecture::Entities::FailureDetails::EMPTY_ARRAY # uninitialized constant CleanArchitecture::Entities::FailureDetails::EMPTY_HASH # uninitialized constant CleanArchitecture::Entities::FailureDetails::EMPTY_OPTS # uninitialized constant CleanArchitecture::Entities::FailureDetails::EMPTY_SET # uninitialized constant CleanArchitecture::Entities::FailureDetails::EMPTY_STRING # uninitialized constant CleanArchitecture::Entities::FailureDetails::Self # uninitialized constant CleanArchitecture::Entities::FailureDetails::Undefined # uninitialized constant CleanArchitecture::Entities::FailureDetails::VERSION # uninitialized constant CleanArchitecture::UseCases::ExampleFormUseCase::DEFAULT_FAILURE_TYPE ``` -------------------------------- ### Address Constant and Method Issues in Bundler::VersionRanges::ReqR Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This addresses 'wrong constant name' and 'uninitialized constant' errors within 'Bundler::VersionRanges::ReqR'. It includes specific issues like 'Elem', 'Endpoint', 'cover?', 'empty?', 'left', 'right', 'single?', 'inclusive', and 'version'. The solution involves correcting constant definitions and implementing missing methods. ```ruby # Example of fixing constant/method issues in Bundler::VersionRanges::ReqR: # Ensure 'Bundler::VersionRanges::ReqR::Elem' is initialized or correctly named. # If 'cover?' is intended as a method, define it: # def cover?(version) # # implementation # end ``` -------------------------------- ### Static Initialization and Initialization Method Errors in Ruby Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet groups Ruby errors related to static initialization blocks and initialization methods. Errors like 'wrong constant name ' suggest issues within class or module initialization processes. 'undefined method `initialize1'' points to problems with how the 'initialize' method is being called or defined, possibly with incorrect arguments or in a context where it's not expected. Review constructor logic and initialization sequences. ```ruby # wrong constant name # undefined method `initialize1' for class `Net::ReadTimeout' # wrong constant name initialize1 # wrong constant name initialize ``` -------------------------------- ### Resolve Undefined Methods in Bundler::UI::Shell Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet addresses the 'undefined method' errors encountered in the 'Bundler::UI::Shell' class. It lists various methods that are being called but not defined, such as 'confirm', 'debug', 'error', 'info', 'initialize', 'level', 'trace', and 'warn'. The solution would involve defining these methods within the class or ensuring they are correctly inherited. ```ruby # Example of defining missing methods in Bundler::UI::Shell: # class Bundler::UI::Shell # def confirm(message) # # implementation for confirm # end # # def debug(message) # # implementation for debug # end # # # ... and so on for other undefined methods ... # # def warn(message) # # implementation for warn # end # end ``` -------------------------------- ### General Object Method and Constant Errors in Ruby Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet consolidates various Ruby errors related to undefined methods and constants on general Object types. It includes errors for common serialization methods like 'as_json' and 'to_yaml', as well as method calls on collections (e.g., [], each, keys). The 'uninitialized constant RUBYGEMS_ACTIVATION_MONITOR' is also included. These errors suggest issues with method availability, incorrect method calls, or missing top-level constants. Verify method definitions and constant existence. ```ruby # wrong constant name initialize # wrong constant name io # wrong constant name to_d # wrong constant name to_i # wrong constant name args # wrong constant name private_call? # undefined method `as_json1' for class `Object' # undefined method `to_yaml1' for class `Object' # uninitialized constant RUBYGEMS_ACTIVATION_MONITOR # wrong constant name as_json1 # wrong constant name as_json # wrong constant name html_safe? # wrong constant name to_yaml1 # wrong constant name to_yaml # wrong constant name yaml_tag # wrong constant name # wrong constant name [] # wrong constant name []= # wrong constant name each # wrong constant name each_key # wrong constant name each_pair # wrong constant name each_value # wrong constant name key? # wrong constant name keys # wrong constant name length # wrong constant name size # wrong constant name values # wrong constant name count_objects ``` -------------------------------- ### RuboCop Style Cops Regex and Constant Configuration Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Configuration details for various RuboCop Style cops, including issues with LITERAL_REGEX, BYTE_ORDER_MARK, and other specific constants like ALIGN_WITH, END_ALIGNMENT, EQUAL, and KEYWORD for ConditionalAssignment. ```ruby # uninitialized constant RuboCop::Cop::Style::AccessModifierDeclarations::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::Alias::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::AndOr::BYTE_ORDER_MARK # uninitialized constant RuboCop::Cop::Style::AndOr::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::ArrayJoin::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::AsciiComments::BYTE_ORDER_MARK # uninitialized constant RuboCop::Cop::Style::AsciiComments::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::Attr::BYTE_ORDER_MARK # uninitialized constant RuboCop::Cop::Style::Attr::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::AutoResourceCleanup::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::BarePercentLiterals::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::BeginBlock::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::BlockComments::BYTE_ORDER_MARK # uninitialized constant RuboCop::Cop::Style::BlockComments::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::BlockDelimiters::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::CaseEquality::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::CharacterLiteral::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::ClassAndModuleChildren::BYTE_ORDER_MARK # uninitialized constant RuboCop::Cop::Style::ClassAndModuleChildren::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::ClassCheck::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::ClassMethods::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::ClassVars::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::CollectionMethods::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::ColonMethodCall::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::ColonMethodDefinition::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::CommandLiteral::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::CommentAnnotation::BYTE_ORDER_MARK # uninitialized constant RuboCop::Cop::Style::CommentAnnotation::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::CommentedKeyword::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::ConditionalAssignment::ALIGN_WITH # uninitialized constant RuboCop::Cop::Style::ConditionalAssignment::END_ALIGNMENT # uninitialized constant RuboCop::Cop::Style::ConditionalAssignment::EQUAL # uninitialized constant RuboCop::Cop::Style::ConditionalAssignment::KEYWORD # uninitialized constant RuboCop::Cop::Style::ConditionalAssignment::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::ConstantVisibility::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::Copyright::BYTE_ORDER_MARK # uninitialized constant RuboCop::Cop::Style::Copyright::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::DateTime::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::DefWithParentheses::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::Dir::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Style::Documentation::LITERAL_REGEX ``` -------------------------------- ### Execute Use Case Directly with Manual Parameters for API (Ruby) Source: https://github.com/udn/clean-architecture/blob/main/README.md This Ruby code shows an alternative controller action for updating a nickname, suitable for API endpoints where forms are not used. It manually constructs the parameter object for the use case, bypassing the Form class. It returns a JSON response indicating success or failure with error messages. ```ruby module MyWebApp class NicknamesController < ApplicationController def update Dry::Matcher::ResultMatcher.call(user_updates_nickname.result) do |matcher| matcher.success do |_| render json: { success: true } end matcher.failure do |errors| render json: { errors: errors.full_messages } end end end private def user_updates_nickname MyBusinessDomain::UseCases::UserUpdatesNickname.new(user_updates_nickname_parameters) end def user_updates_nickname_parameters MyBusinessDomain::UseCases::UserUpdatesNickname.parameters( context: { my_gateway_object: MyGateway.new }, user_id: params[:user_id], nickname: params[:nickname] ) end end end ``` -------------------------------- ### Ruby Undefined Methods in Forwardable Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet covers undefined method errors for `def_delegator` and `def_instance_delegator` within the `Forwardable` module in Ruby. These errors suggest that the delegation methods, used for creating proxy methods, are either not available or are being called incorrectly. ```Ruby # undefined method `def_delegator1' for module `Forwardable' # undefined method `def_instance_delegator1' for module `Forwardable' ``` -------------------------------- ### Ruby Undefined Singleton Method in Find Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet addresses an error where a singleton method `find` is called on the `Find` module in Ruby, but the method is not defined. This could be due to incorrect usage or a missing implementation of the search functionality. ```Ruby # undefined singleton method `find1' for `Find' # wrong constant name find1 # wrong constant name find ``` -------------------------------- ### Access Context Variables in Use Case with Ruby Source: https://github.com/udn/clean-architecture/blob/main/README.md This snippet illustrates how to access context variables, such as a gateway object, within a use case. The `option` keyword is used in the contract to define required context, and the `context` method is used to retrieve these variables for use in the business logic. ```ruby module MyBusinessDomain module UseCases class UserUpdatesAge < CleanArchitecture::UseCases::AbstractUseCase contract do option :required_gateway_object params do required(:user_id).filled(:int) required(:age).filled(:int) end end include Dry::Monads::Do.for(:result) def result valid_params = yield result_of_validating_params context(:required_gateway_object).update_user_age_result( valid_params[:user_id], valid_params[:age] ) end end end end ``` -------------------------------- ### Define Missing Methods for CGI::HtmlExtension Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This addresses the 'undefined method' errors for various HTML generation methods within the 'CGI::HtmlExtension' module. It lists methods like 'checkbox_group', 'div', 'head', 'hr', 'html', 'i', 'image', 'input_field', 'label', 'li', 'link', 'meta', 'ol', 'option', 'p', 'pre', 'script', 'select', 'span', 'strong', 'style', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'ul'. The solution requires implementing these methods. ```ruby # Example of defining missing methods in CGI::HtmlExtension: # module CGI::HtmlExtension # def div(options = {}, &block) # content = block.call if block_given? # "
#{content}
" # end # # def head(&block) # content = block.call if block_given? # "#{content}" # end # # # ... and so on for other undefined methods ... # # def ul(options = {}, &block) # content = block.call if block_given? # "
    #{content}
" # end # end ``` -------------------------------- ### RuboCop SpaceBeforePunctuation Configuration Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Configuration for RuboCop's SpaceBeforePunctuation cop, indicating an issue with the BYTE_ORDER_MARK constant, likely related to punctuation spacing rules. ```ruby # uninitialized constant RuboCop::Cop::SpaceBeforePunctuation::BYTE_ORDER_MARK ``` -------------------------------- ### Implement Methods for Bundler::VersionRanges::ReqR::Endpoint Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet focuses on the 'wrong constant name' errors related to 'Bundler::VersionRanges::ReqR::Endpoint', including issues with '[]', 'members', and method-like constants. It suggests that these might be intended as methods or require proper constant definition and usage. ```ruby # Example of implementing potential methods or correcting constant usage: # class Bundler::VersionRanges::ReqR::Endpoint # def self.[](*args) # # implementation for [] # end # # def members # # implementation for members # end # end ``` -------------------------------- ### Ruby Undefined Methods in Hash Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet identifies errors related to undefined methods `to_param` and `to_query` for the `Hash` class in Ruby. These methods are commonly used for formatting hash data into URL query strings or parameters, and their absence indicates a potential problem with the core `Hash` functionality or associated libraries. ```Ruby # undefined method `to_param1' for class `Hash' # undefined method `to_query1' for class `Hash' ``` -------------------------------- ### Uninitialized Net::FTPError Constants in Ruby Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet highlights 'uninitialized constant' errors related to Net::FTPError and its subclasses. These errors indicate that the Ruby interpreter cannot find the specified constants, likely due to incorrect naming or missing definitions within the Net::FTP module. Ensure correct constant names and that the Net::FTP library is properly included. ```ruby # uninitialized constant Net::FTPError # uninitialized constant Net::FTPPermError # uninitialized constant Net::FTPProtoError # uninitialized constant Net::FTPReplyError # uninitialized constant Net::FTPTempError ``` -------------------------------- ### RuboCop RSpec VoidExpect Configuration Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Configuration details for RuboCop's RSpec::VoidExpect cop. This includes default configurations, patterns, and regex literals for void expectations in RSpec. ```ruby # uninitialized constant RuboCop::Cop::RSpec::VoidExpect::ALL # uninitialized constant RuboCop::Cop::RSpec::VoidExpect::DEFAULT_CONFIGURATION # uninitialized constant RuboCop::Cop::RSpec::VoidExpect::DEFAULT_PATTERN_RE # uninitialized constant RuboCop::Cop::RSpec::VoidExpect::LITERAL_REGEX # uninitialized constant RuboCop::Cop::RSpec::VoidExpect::RSPEC ``` -------------------------------- ### Resolving Undefined Singleton Methods in REXML::Functions Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet addresses errors arising from attempts to call undefined singleton methods on the `REXML::Functions` module in Ruby. These errors indicate that methods like `boolean`, `get_namespace`, `local_name`, etc., are being called as class methods (singleton methods) but have not been defined within the `REXML::Functions` class. The fix typically involves either defining these methods as singleton methods on `REXML::Functions` or calling them on an instance of a class that implements them, depending on the intended functionality. ```ruby # Example of potential fix (conceptual): # If 'boolean' is intended as a utility function, it might need to be defined as a singleton method: # module REXML::Functions # def self.boolean(value) # # implementation # end # end # Original problematic lines: # undefined singleton method `boolean1' for `REXML::Functions' # undefined singleton method `get_namespace1' for `REXML::Functions' # ... and many others listed in the input. ``` -------------------------------- ### Active Record Entity Builder Usage (Ruby) Source: https://github.com/udn/clean-architecture/blob/main/README.md Illustrates using `CleanArchitecture::Builders::AbstractActiveRecordEntityBuilder` to create entity objects from Active Record models. It shows how to define relations and override attribute mapping for complex scenarios. ```ruby class Person < ApplicationRecord has_many :interests, autosave: true, dependent: :destroy belongs_to :father end class Entities::Person < Dry::Struct attribute :forename, Types::Strict::String attribute :surname, Types::Strict::String attribute :father, Types.Instance(Person) attribute :interests, Types.Array(Types.Instance(Interest)) attribute :birth_month, Types::Strict::String end class PersonBuilder < CleanArchitecture::Builders::AbstractActiveRecordEntityBuilder acts_as_builder_for_entity Entities::Person has_many :interests, use: InterestBuilder belongs_to :father, use: PersonBuilder def attributes_for_entity { birth_month: @ar_model_instance.birth_date.month } end end ``` -------------------------------- ### Ruby Uninitialized Constants in FileUtils Modules Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet details uninitialized constant errors within various `FileUtils` submodules (`DryRun`, `NoWrite`, `Verbose`) in Ruby. These errors indicate that expected constants, likely related to file operation support or versioning, are not defined within these modules. ```Ruby # uninitialized constant FileUtils::DryRun::LN_SUPPORTED # uninitialized constant FileUtils::DryRun::RUBY # uninitialized constant FileUtils::DryRun::VERSION # uninitialized constant FileUtils::NoWrite::LN_SUPPORTED # uninitialized constant FileUtils::NoWrite::RUBY # uninitialized constant FileUtils::NoWrite::VERSION # uninitialized constant FileUtils::Verbose::LN_SUPPORTED # uninitialized constant FileUtils::Verbose::RUBY # uninitialized constant FileUtils::Verbose::VERSION ``` -------------------------------- ### Uninitialized Net::HTTP Constants in Ruby Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet lists 'uninitialized constant' errors concerning Net::HTTP and its associated classes like DigestAuth and Persistent. It also includes errors for specific HTTP status code classes (e.g., HTTPAlreadyReported, HTTPEarlyHints). These errors suggest that the constants within Net::HTTP are not defined or accessible. Check for proper require statements and library versions. ```ruby # uninitialized constant Net::HTTP::DigestAuth # uninitialized constant Net::HTTP::Persistent # uninitialized constant Net::HTTPAlreadyReported::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPAlreadyReported::CODE_TO_OBJ # uninitialized constant Net::HTTPEarlyHints::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPEarlyHints::CODE_TO_OBJ # uninitialized constant Net::HTTPGatewayTimeout::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPGatewayTimeout::CODE_TO_OBJ # uninitialized constant Net::HTTPLoopDetected::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPLoopDetected::CODE_TO_OBJ # uninitialized constant Net::HTTPMisdirectedRequest::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPMisdirectedRequest::CODE_TO_OBJ # uninitialized constant Net::HTTPNotExtended::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPNotExtended::CODE_TO_OBJ # uninitialized constant Net::HTTPPayloadTooLarge::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPPayloadTooLarge::CODE_TO_OBJ # uninitialized constant Net::HTTPProcessing::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPProcessing::CODE_TO_OBJ # uninitialized constant Net::HTTPRangeNotSatisfiable::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPRangeNotSatisfiable::CODE_TO_OBJ # uninitialized constant Net::HTTPRequestTimeout::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPRequestTimeout::CODE_TO_OBJ # uninitialized constant Net::HTTPURITooLong::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPURITooLong::CODE_TO_OBJ # uninitialized constant Net::HTTPVariantAlsoNegotiates::CODE_CLASS_TO_OBJ # uninitialized constant Net::HTTPVariantAlsoNegotiates::CODE_TO_OBJ ``` -------------------------------- ### Ruby Undefined Singleton Method in File Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet addresses an error where a singleton method `atomic_write` is called on the `File` class in Ruby, but the method is not defined. This suggests an attempt to use a file operation that is not supported or incorrectly invoked. ```Ruby # undefined singleton method `atomic_write1' for `File' # wrong constant name atomic_write1 # wrong constant name atomic_write ``` -------------------------------- ### Uninitialized Net::SMTP Constants in Ruby Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet details 'uninitialized constant' errors specific to Ruby's Net::SMTP library. It covers errors for the base Net::SMTP class, as well as various error types like SMTPAuthenticationError, SMTPError, and SMTPFatalError. These indicate that the necessary components of the Net::SMTP library are not loaded or accessible. Ensure the Net::SMTP library is correctly required and configured. ```ruby # uninitialized constant Net::SMTP # uninitialized constant Net::SMTPAuthenticationError # uninitialized constant Net::SMTPError # uninitialized constant Net::SMTPFatalError # uninitialized constant Net::SMTPServerBusy # uninitialized constant Net::SMTPSyntaxError # uninitialized constant Net::SMTPUnknownError # uninitialized constant Net::SMTPUnsupportedCommand ``` -------------------------------- ### Fix Wrong Constant Names in Bundler::VersionRanges Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This addresses 'wrong constant name' issues within 'Bundler::VersionRanges', including specific cases like 'NEq', 'ReqR', and 'Endpoint'. It also covers general constant issues and method-like constant names. The fix involves correcting the naming of these constants or ensuring they are correctly defined and used. ```ruby # Example of fixing wrong constant names in Bundler::VersionRanges: # Ensure constants like 'Bundler::VersionRanges::NEq::Elem' are correctly defined. # If 'version' or 'version=' are intended as methods, they should not be flagged as constant names. # Correcting a constant definition: # Before: # WRONG_VERSION_CONSTANT = '1.0.0' # After: # CORRECT_VERSION_CONSTANT = '1.0.0' ``` -------------------------------- ### Define a User Username Update Use Case with Contract Validation (Ruby) Source: https://github.com/udn/clean-architecture/blob/main/README.md This Ruby code defines a use case for updating a user's nickname. It uses a contract to define parameters and includes a validation rule to check if the username is available via a gateway object. It returns either a success with parameters or a failure with errors. ```ruby module MyBusinessDomain module UseCases class UserUpdatesNickname < CleanArchitecture::UseCases::AbstractUseCase contract do option :my_gateway_object params do required(:user_id).filled(:id) required(:nickname).filled(:str) end rule(:nickname).validate(:not_already_taken) register_macro(:not_already_taken) do unless my_gateway_object.username_is_available?(values[key_name]) key.failure('is already taken') end end end extend Forwardable include Dry::Monads::Do.for(:result) def result valid_params = yield result_of_validating_params context(:my_gateway_object).result_of_updating_nickname( valid_params[:id], valid_params[:nickname] ) end end end end ``` -------------------------------- ### RuboCop Security Cops Literal Regex Configuration Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Configuration for various RuboCop Security cops, specifically focusing on the LITERAL_REGEX constant used in detecting potentially insecure code patterns like eval, JSON load, Marshal load, open, and YAML load. ```ruby # uninitialized constant RuboCop::Cop::Security::Eval::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Security::JSONLoad::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Security::MarshalLoad::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Security::Open::LITERAL_REGEX # uninitialized constant RuboCop::Cop::Security::YAMLLoad::LITERAL_REGEX ``` -------------------------------- ### RuboCop RSpec VerifiedDoubles Configuration Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Configuration details for RuboCop's RSpec::VerifiedDoubles cop. It outlines default patterns and regex literals related to verified doubles in RSpec. ```ruby # uninitialized constant RuboCop::Cop::RSpec::VerifiedDoubles::ALL # uninitialized constant RuboCop::Cop::RSpec::VerifiedDoubles::DEFAULT_CONFIGURATION # uninitialized constant RuboCop::Cop::RSpec::VerifiedDoubles::DEFAULT_PATTERN_RE # uninitialized constant RuboCop::Cop::RSpec::VerifiedDoubles::LITERAL_REGEX # uninitialized constant RuboCop::Cop::RSpec::VerifiedDoubles::RSPEC ``` -------------------------------- ### Ruby Uninitialized Constant in Gem::Resolver Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet addresses an uninitialized constant error within the `Gem::Resolver::Molinillo::DependencyGraph::Log` hierarchy in Ruby. The missing constant `Elem` suggests an issue with the dependency resolution or logging mechanism. ```Ruby # uninitialized constant Gem::Resolver::Molinillo::DependencyGraph::Log::Elem ``` -------------------------------- ### Define a Shared Contract for Reusable Logic (Ruby) Source: https://github.com/udn/clean-architecture/blob/main/README.md This Ruby code defines a shared contract that can be reused across multiple use cases. It includes an option for a gateway object and a validation macro for checking if a username is already taken. This promotes code reuse and makes validation logic testable independently. ```ruby module MyBusinessDomain module UseCases class SharedContract < CleanArchitecture::UseCases::Contract option :my_gateway_object register_macro(:not_already_taken?) do unless not_already_taken?(values[key_name]) key.failure('is already taken') end end private def not_already_taken?(username) ``` -------------------------------- ### Ruby Uninitialized Constants in Float Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt This snippet highlights errors related to uninitialized constants within the `Float` class in Ruby. These constants, such as `EXABYTE`, `GIGABYTE`, etc., represent numerical units and their absence indicates a potential issue with the numeric library or its configuration. ```Ruby # uninitialized constant Float::EXABYTE # uninitialized constant Float::GIGABYTE # uninitialized constant Float::KILOBYTE # uninitialized constant Float::MEGABYTE # uninitialized constant Float::PETABYTE # uninitialized constant Float::TERABYTE ``` -------------------------------- ### RuboCop RSpec UnspecifiedException Configuration Source: https://github.com/udn/clean-architecture/blob/main/sorbet/rbi/hidden-definitions/errors.txt Configuration details for RuboCop's RSpec::UnspecifiedException cop. It includes default patterns and regular expressions used for detecting unspecified exceptions in RSpec tests. ```ruby # uninitialized constant RuboCop::Cop::RSpec::UnspecifiedException::DEFAULT_PATTERN_RE # uninitialized constant RuboCop::Cop::RSpec::UnspecifiedException::LITERAL_REGEX # uninitialized constant RuboCop::Cop::RSpec::UnspecifiedException::RSPEC ```