rails_code_auditor 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83cd23ea4027538587a1814cbf2a3472bd818fe0cb15bf492a3ab54b565c2e63
4
- data.tar.gz: 40438e254bed8d07966559ac52df8a3063f427167fbc236a8eac0fba6a591c1d
3
+ metadata.gz: 598189dda2fba4a0b37869531aae8cb254a7effbcdff35b5be9638892c79eafb
4
+ data.tar.gz: d90fc145ba60a605012b332a8c74a2400ba7607f0278387ec74eed58a0211677
5
5
  SHA512:
6
- metadata.gz: e1cdd901ff82b3f2c2d5f0be65175a03b534a6d3a401c34a9c85861401ea2cf416162a1045fe34b2e8cf0ef79a3a220a1c1e9f87b81fff05d06b973735974227
7
- data.tar.gz: 721d41c939a3e00321508a4c36033221e58b6f67a6fd1f0ee9df090e1ae289fafe0b65c94e0f07b7e20c6b3c4bad375463b763f00d440c7a96c29af529e6cde2
6
+ metadata.gz: 506c2a77006ff53ac87a5e58e86d322f79323d10f5a0714d1c0a9a75fa3b27ec32082894af8bd314146be709a464cce296558c5b01e3496100fc862fd2f5938e
7
+ data.tar.gz: 97a84b00a918e79e7a7ec9ab4e5b1c6100b6f1c719267649120b13ce9d4c3279d6b119cc5f91c3da7ced0cb4832309efbe987ed20b13f76fd8f74d9047c93b90
@@ -9,12 +9,13 @@ module RailsCodeAuditor
9
9
  tool.dup.tap do |entry|
10
10
  if entry.is_a?(Hash) && entry[:details].is_a?(String)
11
11
  entry[:details] = entry[:details].slice(0, 500) # Trim details to avoid LLM overload
12
- entry[:details].gsub!(/\e\[[\d;]*m/, '') # Remove ANSI color codes
12
+ entry[:details].gsub!(/\e\[[\d;]*m/, "") # Remove ANSI color codes
13
13
  end
14
14
  end
15
15
  end
16
16
  end
17
- def self.score_with_llm(json_results)
17
+
18
+ def self.score_with_llm(json_results, endpoint: "http://localhost:11434/api/generate", model: "llama3")
18
19
  sanitized = sanitize_results(json_results)
19
20
  puts "[*] Scoring with LLM (LLaMA3)..."
20
21
 
@@ -34,9 +35,9 @@ module RailsCodeAuditor
34
35
  #{JSON.pretty_generate(sanitized)}
35
36
  PROMPT
36
37
 
37
- uri = URI("http://localhost:11434/api/generate")
38
+ uri = URI(endpoint)
38
39
  body = {
39
- model: "llama3",
40
+ model: model,
40
41
  prompt: prompt,
41
42
  stream: false
42
43
  }
@@ -48,24 +49,21 @@ module RailsCodeAuditor
48
49
  # Try to extract JSON from any surrounding text
49
50
  json_match = raw_output.match(/\{.*\}/m)
50
51
 
51
- if json_match
52
- parsed_scores = JSON.parse(json_match[0])
53
- scored_results = parsed_scores.transform_values do |score|
54
- remark = case score
55
- when 90..100 then "Excellent"
56
- when 75..89 then "Good"
57
- when 60..74 then "Average"
58
- else "Needs Improvement"
59
- end
60
- { score: score, remark: remark }
61
- end
62
- scored_results
63
- else
64
- raise "Response did not contain valid JSON"
52
+ raise "Response did not contain valid JSON" unless json_match
53
+
54
+ parsed_scores = JSON.parse(json_match[0])
55
+ parsed_scores.transform_values do |score|
56
+ remark = case score
57
+ when 90..100 then "Excellent"
58
+ when 75..89 then "Good"
59
+ when 60..74 then "Average"
60
+ else "Needs Improvement"
61
+ end
62
+ { score: score, remark: remark }
65
63
  end
66
- rescue => e
64
+ rescue StandardError => e
67
65
  puts "[!] LLM scoring failed: #{e.message}"
68
66
  nil
69
67
  end
70
68
  end
71
- end
69
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsCodeAuditor
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -15,11 +15,17 @@ module RailsCodeAuditor
15
15
  def self.run(args)
16
16
  puts "[*] Running Rails Code Auditor..."
17
17
 
18
+ # Parse CLI options
19
+ use_llm = args.include?("--use-llm")
20
+ model_arg = args[args.index("--llm-model") + 1] if args.include?("--llm-model")
21
+ endpoint_arg = args[args.index("--llm-endpoint") + 1] if args.include?("--llm-endpoint")
22
+
18
23
  raw_results = Analyzer.run_all
19
24
  results = ReportGenerator.normalize(raw_results)
20
25
  results[:simplecov] = SimpleCovRunner.run
21
- scores = if args.include?("--use-llm")
22
- LlmClient.score_with_llm(results) || Scorer.score(results)
26
+ scores = if use_llm
27
+ LlmClient.score_with_llm(results, model: model_arg || "llama3",
28
+ endpoint: endpoint_arg || "http://localhost:11434/api/generate") || Scorer.score(results)
23
29
  else
24
30
  Scorer.score(results)
25
31
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_code_auditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sivamanikandan
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-07-24 00:00:00.000000000 Z
10
+ date: 2025-07-25 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: brakeman