Skip to content

Conversation

jortel
Copy link
Contributor

@jortel jortel commented Jun 9, 2025

Report insights.

Requires: konveyor/tackle2-hub#841

Summary by CodeRabbit

  • Refactor
    • Updated terminology throughout the application from "issues" to "insights" for analysis results, including all related fields, methods, and output files.
    • Enhanced output structure to provide more detailed incident and link information in analysis results.
  • Chores
    • Updated module dependency to use a new version of an external library.

@jortel jortel added this to Planning Jun 9, 2025
@github-project-automation github-project-automation bot moved this to 🆕 New in Planning Jun 9, 2025
@jortel jortel added this to the v0.8.0 milestone Jun 9, 2025
@jortel jortel moved this from 🆕 New to 🏗 In progress in Planning Jun 9, 2025
jortel added 2 commits July 8, 2025 12:41
Signed-off-by: Jeff Ortel <[email protected]>
Signed-off-by: Jeff Ortel <[email protected]>
jortel added a commit to konveyor/tackle2-hub that referenced this pull request Jul 8, 2025
Add support for insights.
With the addition of insights, the term _issue_ is no longer appropriate
for the base level thing reported by a rule. Rather, rules report
insights about the code. Some insights (with effort) report issues to be
resolved.
The analysis report will rename issue to: insight.

Query & filtering:
- insights that are NOT issues: `?filter=effort=0`
- insights that ARE issues: `?filter=effort>0`

Consider this with an analogy of: Fruit (=insight) and Apple
(=issue/violation). I would be odd and backwards to consider fruit as:
apples with (without) some specific characteristic.

Definition: Insight: 
- _an instance of apprehending the true nature of a thing, especially
through intuitive understanding_.
- _the capacity to gain an accurate and deep understanding of a person
or thing_.

Related: 
- addon: konveyor/tackle2-addon-analyzer#155
- UI: _TBD_

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* All references to "issues" have been renamed to "insights" across the
user interface, API endpoints, documentation, and data exports.
* API routes, responses, and related terminology now consistently use
"insight" instead of "issue".
* Database migration and models have been updated to reflect the new
naming.
* Documentation and script outputs now reference "insights" for improved
clarity and consistency.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jeff Ortel <[email protected]>
Copy link

coderabbitai bot commented Jul 8, 2025

Walkthrough

The changes refactor the codebase to shift terminology and data structures from "issues" to "insights." All related types, methods, fields, and file outputs are renamed accordingly. Output structures are enhanced with more detailed information for each insight. The Go module dependency version is updated without adding a replace directive.

Changes

File(s) Change Summary
builder/issue.go Renamed Issues to Insights, updated all related methods, enriched output structure for insights.
builder/manifest.go Renamed Issues field to Insights in Manifest, updated related method calls.
cmd/analyzer.go Updated Run method to return *builder.Insights instead of *builder.Issues; updated file outputs.
cmd/main.go Replaced all issues variables/types with insights, updated function signatures and usages.
go.mod Updated version of github.com/konveyor/tackle2-hub dependency to a newer version.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Analyzer
    participant Builder (Insights)
    participant Manifest

    User->>Analyzer: Run()
    Analyzer->>Builder (Insights): NewInsights(output)
    Builder (Insights)-->>Analyzer: *Insights
    Analyzer-->>User: *Insights, *Deps, error

    User->>Manifest: Manifest{Insights: insights, ...}
    Manifest->>Manifest: Write()
    Manifest->>Builder (Insights): Insights.Write(file)
    Builder (Insights)-->>Manifest: Write insights data
Loading

Poem

🐇
Goodbye to issues, insights now bloom,
With richer details, they banish the gloom.
Fields and functions with names so bright,
Output markers changed, everything’s right!
A hop to new modules, dependencies tuned—
The codebase refreshed, by rabbits festooned.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7fe25d and 320d358.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • go.mod
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-and-upload-for-global-ci

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
builder/issue.go (1)

44-128: Refactor to eliminate code duplication.

The code for processing Violations (lines 50-89) and Insights (lines 90-123) is nearly identical. Consider extracting a helper function to reduce duplication.

Apply this refactor to eliminate duplication:

+// processIncidents converts incidents to API incidents
+func (b *Insights) processIncidents(incidents []output.Incident) []api.Incident {
+	result := []api.Incident{}
+	for _, i := range incidents {
+		incident := api.Incident{
+			File:     b.fileRef(i.URI),
+			Line:     pointer.IntDeref(i.LineNumber, 0),
+			Message:  i.Message,
+			CodeSnip: i.CodeSnip,
+			Facts:    i.Variables,
+		}
+		result = append(result, incident)
+	}
+	return result
+}
+
+// processLinks converts links to API links
+func (b *Insights) processLinks(links []output.Link) []api.Link {
+	result := []api.Link{}
+	for _, l := range links {
+		result = append(result, api.Link{
+			URL:   l.URL,
+			Title: l.Title,
+		})
+	}
+	return result
+}

 // Write insights section.
 func (b *Insights) Write(writer io.Writer) (err error) {
 	encoder := yaml.NewEncoder(writer)
 	_, _ = writer.Write([]byte(api.BeginInsightsMarker))
 	_, _ = writer.Write([]byte{'\n'})
 	for _, ruleset := range b.input {
 		for ruleid, v := range ruleset.Violations {
 			insight := api.Insight{
 				RuleSet:     ruleset.Name,
 				Rule:        ruleid,
 				Description: v.Description,
 				Labels:      v.Labels,
 			}
 			if v.Category != nil {
 				insight.Category = string(*v.Category)
 			}
 			if v.Effort != nil {
 				insight.Effort = *v.Effort
 			}
-			insight.Links = []api.Link{}
-			for _, l := range v.Links {
-				insight.Links = append(
-					insight.Links,
-					api.Link{
-						URL:   l.URL,
-						Title: l.Title,
-					})
-			}
-			insight.Incidents = []api.Incident{}
-			for _, i := range v.Incidents {
-				incident := api.Incident{
-					File:     b.fileRef(i.URI),
-					Line:     pointer.IntDeref(i.LineNumber, 0),
-					Message:  i.Message,
-					CodeSnip: i.CodeSnip,
-					Facts:    i.Variables,
-				}
-				insight.Incidents = append(
-					insight.Incidents,
-					incident)
-			}
+			insight.Links = b.processLinks(v.Links)
+			insight.Incidents = b.processIncidents(v.Incidents)
 			err = encoder.Encode(&insight)
 			if err != nil {
 				return
 			}
 		}
 		for ruleid, v := range ruleset.Insights {
 			insight := api.Insight{
 				RuleSet:     ruleset.Name,
 				Rule:        ruleid,
 				Description: v.Description,
 				Labels:      v.Labels,
 			}
-			insight.Links = []api.Link{}
-			for _, l := range v.Links {
-				insight.Links = append(
-					insight.Links,
-					api.Link{
-						URL:   l.URL,
-						Title: l.Title,
-					})
-			}
-			insight.Incidents = []api.Incident{}
-			for _, i := range v.Incidents {
-				incident := api.Incident{
-					File:     b.fileRef(i.URI),
-					Line:     pointer.IntDeref(i.LineNumber, 0),
-					Message:  i.Message,
-					CodeSnip: i.CodeSnip,
-					Facts:    i.Variables,
-				}
-				insight.Incidents = append(
-					insight.Incidents,
-					incident)
-			}
+			insight.Links = b.processLinks(v.Links)
+			insight.Incidents = b.processIncidents(v.Incidents)
 			err = encoder.Encode(&insight)
 			if err != nil {
 				return
 			}
 		}
 	}
 	_, _ = writer.Write([]byte(api.EndInsightsMarker))
 	_, _ = writer.Write([]byte{'\n'})
 	return
 }
🧹 Nitpick comments (1)
builder/issue.go (1)

1-1: Consider renaming the file to match the new terminology.

Since all types and functions have been renamed from "Issues" to "Insights", the file should be renamed from issue.go to insights.go for consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c274351 and a7fe25d.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (5)
  • builder/issue.go (4 hunks)
  • builder/manifest.go (2 hunks)
  • cmd/analyzer.go (2 hunks)
  • cmd/main.go (4 hunks)
  • go.mod (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
builder/manifest.go (1)
builder/issue.go (1)
  • Insights (30-34)
cmd/analyzer.go (3)
builder/issue.go (2)
  • Insights (30-34)
  • NewInsights (23-27)
builder/deps.go (1)
  • Deps (20-22)
cmd/main.go (1)
  • Dir (23-23)
cmd/main.go (3)
builder/issue.go (2)
  • RuleError (169-171)
  • Insights (30-34)
builder/deps.go (1)
  • Deps (20-22)
cmd/tagger.go (1)
  • Tagger (13-16)
builder/issue.go (1)
cmd/rules.go (1)
  • Labels (331-334)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-and-upload-for-global-ci
🔇 Additional comments (4)
builder/manifest.go (1)

13-13: LGTM!

The field renaming from Issues to Insights and corresponding method call update are consistent with the broader refactoring across the codebase.

Also applies to: 37-37

cmd/analyzer.go (1)

28-29: Changes look good - note the output file name change.

The updates to use Insights instead of Issues are consistent. Note that the output file name has changed from issues.yaml to insights.yaml, which may impact downstream consumers.

Also applies to: 59-59

cmd/main.go (1)

111-111: LGTM!

All references to issues have been consistently updated to insights throughout the file, including variable names, function parameters, and method calls.

Also applies to: 117-117, 121-121, 134-134, 141-141, 153-153, 176-176

builder/issue.go (1)

22-27: Good enhancement to include detailed incident information.

The expansion of the output structure to include Links and detailed Incidents (with file references, line numbers, messages, code snippets, and facts) provides much richer reporting capabilities.

Also applies to: 29-34, 44-128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants