-
Notifications
You must be signed in to change notification settings - Fork 12
✨ add insights. #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ add insights. #155
Conversation
Signed-off-by: Jeff Ortel <[email protected]>
Signed-off-by: Jeff Ortel <[email protected]>
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]>
WalkthroughThe 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
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
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
toinsights.go
for consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ 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
toInsights
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 ofIssues
are consistent. Note that the output file name has changed fromissues.yaml
toinsights.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 toinsights
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
Signed-off-by: Jeff Ortel <[email protected]>
Report insights.
Requires: konveyor/tackle2-hub#841
Summary by CodeRabbit