Skip to content

Commit 6ba8650

Browse files
refactor(#121): Change log level to debug for class analysis messages (#128)
1 parent ba53483 commit 6ba8650

File tree

10 files changed

+179
-168
lines changed

10 files changed

+179
-168
lines changed

internal/critic/agent.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type promptData struct {
3030
// Review sends the provided Java class to the Critic for analysis and returns suggested improvements.
3131
func (c *agent) Review(job *domain.Job) (*domain.Artifacts, error) {
3232
class := job.Classes[0]
33-
c.log.Info("Received class %q for analysis", class.Name())
33+
c.log.Debug("Received class %q for analysis", class.Name())
3434
imperfections := tool.NewCombined(c.tools...).Imperfections()
3535
var imp []string
3636
if imperfections != "" {
@@ -81,15 +81,13 @@ func parseAnswer(answer string) []string {
8181
return suggestions
8282
}
8383

84-
func (c *agent) associated(suggestions []string, class string) []domain.Suggestion {
84+
func (c *agent) associated(critique []string, class string) []domain.Suggestion {
8585
res := make([]domain.Suggestion, 0)
86-
for i, suggestion := range suggestions {
87-
if strings.EqualFold(suggestion, notFound) {
88-
c.log.Info("No suggestions found for the class #%d: %s", i+1, class)
89-
} else {
90-
res = append(res, *domain.NewSuggestion(suggestion, class))
86+
for _, c := range critique {
87+
if !strings.EqualFold(c, notFound) {
88+
res = append(res, *domain.NewSuggestion(c, class))
9189
}
9290
}
93-
c.log.Info("Total suggestions associated with class %s: %d", class, len(res))
91+
c.log.Info("Found %d suggestions for %s", len(res), class)
9492
return res
9593
}

internal/critic/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (c *Critic) ListenAndServe() error {
4848
// Review sends the provided Java class to the Critic for analysis and returns suggested improvements.
4949
func (c *Critic) Review(job *domain.Job) (*domain.Artifacts, error) {
5050
address := fmt.Sprintf("http://localhost:%d", c.port)
51-
c.log.Info("Asking critic (%s) to lint the class...", address)
51+
c.log.Debug("Asking critic (%s) to lint the class...", address)
5252
critic := protocol.NewClient(address)
5353
resp, err := critic.SendMessage(job.Marshal())
5454
if err != nil {

internal/domain/agents.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package domain
22

3-
import "fmt"
3+
import (
4+
"fmt"
5+
"strconv"
6+
)
47

58
// Facilitator represents an interface to refactor tasks into multiple classes.
69
type Facilitator interface {
@@ -37,6 +40,15 @@ func (j *Job) Param(key string) (any, bool) {
3740
return res, ok
3841
}
3942

43+
func (j *Job) MaxSize() (int, error) {
44+
size, ok := j.Param("max-size")
45+
ssize := fmt.Sprintf("%v", size)
46+
if !ok {
47+
ssize = "200"
48+
}
49+
return strconv.Atoi(ssize)
50+
}
51+
4052
type Artifacts struct {
4153
Descr *Description
4254
Classes []Class

0 commit comments

Comments
 (0)