Skip to content

Commit

Permalink
Fixed Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhamo1107 committed Aug 16, 2024
1 parent fa63fff commit 4b16092
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
1 change: 0 additions & 1 deletion bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
Expand Down
2 changes: 1 addition & 1 deletion lib/un_used_methods.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 13 additions & 3 deletions lib/un_used_methods/analyzer.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
11 changes: 9 additions & 2 deletions lib/un_used_methods/cli.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion un_used_methods.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Gem::Specification.new do |spec|
spec.email = ["[email protected]"]

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"
Expand Down

0 comments on commit 4b16092

Please sign in to comment.