diff --git a/bin/console b/bin/console index b2d50d5..69f61f9 100644 --- a/bin/console +++ b/bin/console @@ -1,4 +1,3 @@ -#!/usr/bin/env ruby # frozen_string_literal: true require "bundler/setup" diff --git a/lib/un_used_methods.rb b/lib/un_used_methods.rb index efa03c4..714b05e 100644 --- a/lib/un_used_methods.rb +++ b/lib/un_used_methods.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require_relative "un_used_methods/version" -require 'un_used_methods/cli' +require "un_used_methods/cli" module UnUsedMethods class Error < StandardError; end diff --git a/lib/un_used_methods/analyzer.rb b/lib/un_used_methods/analyzer.rb index d32d698..2652a18 100644 --- a/lib/un_used_methods/analyzer.rb +++ b/lib/un_used_methods/analyzer.rb @@ -1,3 +1,13 @@ +# frozen_string_literal: true + +# This class analyzes code to find unused methods within specific directories +# such as models, controllers, and helpers. +# +# It performs the following tasks: +# - Searches for method definitions in the specified directories. +# - Checks if these methods are used elsewhere in the codebase. +# - Reports methods that are not used. + module UnUsedMethods class Analyzer def analyze @@ -11,13 +21,13 @@ def find_un_used_methods un_used_methods = [] # Analyze Models - un_used_methods += find_in_directory('app/models') + un_used_methods += find_in_directory("app/models") # Analyze Controllers - un_used_methods += find_in_directory('app/controllers') + un_used_methods += find_in_directory("app/controllers") # Analyze Helpers - un_used_methods += find_in_directory('app/helpers') + un_used_methods += find_in_directory("app/helpers") un_used_methods end diff --git a/lib/un_used_methods/cli.rb b/lib/un_used_methods/cli.rb index 946eccf..da210d6 100644 --- a/lib/un_used_methods/cli.rb +++ b/lib/un_used_methods/cli.rb @@ -1,10 +1,17 @@ -require 'thor' +# frozen_string_literal: true + +# The CLI class provides the command-line interface for the UnUsedMethods gem. + +# This class is responsible for handling command-line arguments and executing +# the appropriate tasks. It uses the Thor gem to define commands and options +# that users can run from the command line. + +require "thor" module UnUsedMethods class CLI < Thor desc "find_unused", "Find unused methods in models, controllers and helpers" def find_unused - # Core functionality here UnUsedMethods::Analyzer.new.analyze end end diff --git a/un_used_methods.gemspec b/un_used_methods.gemspec index 6ed6ea4..1535aee 100644 --- a/un_used_methods.gemspec +++ b/un_used_methods.gemspec @@ -9,7 +9,9 @@ Gem::Specification.new do |spec| spec.email = ["dhamodharansathish4533@gmail.com"] spec.summary = "A gem to identify and list unused methods in your Rails application." - spec.description = "The un_used_methods gem scans your Rails application to find methods defined in models, controllers and helpers that are not used anywhere else in the application. This helps you clean up your codebase by identifying dead code." + spec.description = "The un_used_methods gem scans your Rails application to find methods defined in models, + controllers and helpers that are not used anywhere else in the application. This helps + you clean up your codebase by identifying dead code." spec.homepage = "https://github.com/Dhamo1107/un_used_methods" spec.license = "MIT" spec.required_ruby_version = ">= 3.0.0"