{"record":{"id":"99a70b1e16241176","repo":"sds/overcommit","slug":"hook-must-define-run","errorCode":null,"errorMessage":"Hook must define `run`","messagePattern":"Hook must define `run`","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"lib/overcommit/hook/base.rb","lineNumber":34,"sourceCode":"  MESSAGE_TYPES = [:error, :warning].freeze\n\n  # Functionality common to all hooks.\n  class Base # rubocop:disable Metrics/ClassLength\n    extend Forwardable\n\n    def_delegators :@context, :all_files, :modified_files\n    attr_reader :config\n\n    # @param config [Overcommit::Configuration]\n    # @param context [Overcommit::HookContext]\n    def initialize(config, context)\n      @config = config.for_hook(self)\n      @context = context\n    end\n\n    # Runs the hook.\n    def run\n      raise NotImplementedError, 'Hook must define `run`'\n    end\n\n    # Runs the hook and transforms the status returned based on the hook's\n    # configuration.\n    #\n    # Poorly named because we already have a bunch of hooks in the wild that\n    # implement `#run`, and we needed a wrapper step to transform the status\n    # based on any custom configuration.\n    def run_and_transform\n      if output = check_for_requirements\n        status = :fail\n      else\n        result = Overcommit::Utils.with_environment(@config.fetch('env') { {} }) { run }\n        status, output = process_hook_return_value(result)\n      end\n\n      [transform_status(status), output]\n    end","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/sds/overcommit/blob/fee0cd74b26eb81f64b43b7fab17bbb541575cc4/lib/overcommit/hook/base.rb#L16-L52","documentation":"Error \"Hook must define `run`\" thrown in sds/overcommit.","triggerScenarios":"Thrown at lib/overcommit/hook/base.rb:34 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define a `run` method in your custom hook class that returns :pass, :fail, or :warn (via the `pass`/`fail`/`warn` helpers or Message objects).","Ensure your hook inherits from the correct Overcommit hook base class (e.g. Overcommit::Hook::PreCommit::Base) so the run contract applies."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fee0cd74b26eb81f64b43b7fab17bbb541575cc4","analyzedAt":"2026-08-23T04:07:28.153Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}