Skip to content

Conversation

@visz11
Copy link

@visz11 visz11 commented Nov 10, 2025

CodeAnt-AI Description

Add HrBarChart component to show language acceptance rates with detailed tooltip

What Changed

  • New vertical, responsive bar chart that displays languages ranked by acceptance rate and uses provided axis labels from chart metadata
  • Bars animate and show a percentage label at the end only for positive numeric rates; zero or invalid rates do not show a label
  • Hover tooltip shows acceptance rate plus related stats (acceptance count, avg active users, lines accepted/suggested, max active users, suggestion count); acceptance rate in the tooltip falls back to "0" when the value is missing or not a positive number

Impact

✅ Sorted language ranking by acceptance rate
✅ Fewer misleading bar labels for zero or invalid rates
✅ Clearer acceptance-rate values in tooltips

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • New Features
    • Added a new horizontal bar chart component for visualizing key performance metrics and data trends
    • Displays custom interactive tooltips featuring multiple data points and percentage value labels for detailed insights
    • Automatically sorts displayed data by acceptance rate in descending order
    • Includes responsive sizing with robust error handling for invalid or missing data

@codeant-ai
Copy link

codeant-ai bot commented Nov 10, 2025

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link

coderabbitai bot commented Nov 10, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

A new HrBarChart component is introduced that renders a vertical bar chart using Recharts and Chakra UI theming. It transforms input data through sorting, includes custom tooltip and bar label components, configures axis labels from metadata, handles edge cases, and supports responsive container sizing.

Changes

Cohort / File(s) Summary
New HrBarChart Component
HrBarChart.tsx
Introduces a vertical bar chart component with sorted data transformation, custom tooltip displaying multiple metrics, bar labels showing percentages, Chakra UI theme integration, and responsive sizing with edge case handling

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Data transformation logic: Verify sorting by acceptanceRate and field mapping accuracy
  • Tooltip rendering: Review NaN/invalid value handling and metric display correctness
  • Recharts configuration: Confirm bar positioning, axis labels, and responsive container behavior
  • Chakra UI integration: Validate theme color usage and responsive styling

Poem

🐰 A chart hops in, so tall and bright,
Bars dance with data, metrics in sight,
Sorted by acceptance, colors so true,
HrBarChart arrives—hooray, something new! 📊

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: introducing a new HrBarChart component for displaying bar charts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Add-HrBarChart-component-for-displaying-bar-chart

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @visz11, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new, dedicated component for rendering interactive bar charts, specifically tailored to visualize acceptance rates and associated metrics. This enhancement improves the application's ability to present complex data clearly and intuitively, offering users a more insightful view into performance statistics.

Highlights

  • New HrBarChart Component: Introduces a new React component HrBarChart.tsx designed to display vertical bar charts using recharts and @chakra-ui/react.
  • Detailed Tooltips: Implements a CustomTooltip to provide comprehensive statistics (acceptance rate, acceptance count, average active users, lines accepted, lines suggested, max active users, suggestion count) upon hovering over chart bars.
  • Dynamic Bar Labels: Adds a CustomBarLabel to display the acceptance rate percentage directly next to each bar, with logic to hide labels for zero or invalid values.
  • Data Transformation and Sorting: Includes logic to transform raw data by capitalizing language names and sorting the bars based on acceptance rate in descending order.
  • Robust Data Handling: Enhances the tooltip and bar label to gracefully handle cases where acceptance rate values might be NaN, null, or 0.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@visz11
Copy link
Author

visz11 commented Nov 10, 2025

/refacto-visz

@codeant-ai codeant-ai bot added the size:L This PR changes 100-499 lines, ignoring generated files label Nov 10, 2025
@refacto-visz
Copy link

refacto-visz bot commented Nov 10, 2025

Refacto is reviewing this PR. Please wait for the review comments to be posted.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a new HrBarChart component. My main concern is that the file HrBarChart.tsx appears to be corrupted, as it contains a duplicated implementation of the component, leading to a syntax error. This is a critical issue that needs to be addressed first. The duplicated code block does contain some improvements over the first one, which I've commented on; these should be merged into the single, correct component implementation.

Additionally, I've identified several opportunities to improve the code quality:

  • Type Safety: The code frequently uses the any type, which undermines the benefits of TypeScript. I've suggested using more specific types for props to improve type safety and code clarity.
  • Performance: The data transformation logic is executed on every render, which could lead to performance issues. I've recommended using React.useMemo to memoize the result.
  • Robustness: There's a potential runtime error when processing data that could be null or undefined.
  • Code Quality: There are minor issues like an unused import and a hardcoded color value.

Please review the detailed comments for specific suggestions.

</ResponsiveContainer>
</Box>
);
};import { Box, Flex, Text } from '@chakra-ui/react';

Choose a reason for hiding this comment

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

critical

This file appears to be corrupted. It contains a duplicated implementation of the HrBarChart component, with the second one starting on this line. This causes a syntax error and prevents the code from being used. Please remove the duplicated code from line 167 to 340. Note that the duplicated code contains some useful changes (e.g., in CustomTooltip and CustomBarLabel) which should be integrated into the primary component definition before deleting this block.

Comment on lines +13 to +17
interface HrBarChartProps {
data: any;
keys: any;
chartMetadata: any;
}

Choose a reason for hiding this comment

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

high

To improve type safety and code clarity, avoid using any. Please define specific types for the component's props. Additionally, the keys prop is declared but never used in the component and should be removed.

interface HrBarChartProps {
  data: { data?: Record<string, any> }; // It's highly recommended to replace 'any' with a specific interface for stats.
  chartMetadata: { xlabel?: string; ylabel?: string };
}

chartMetadata: any;
}

const CustomTooltip = ({ active, payload, label }: any) => {

Choose a reason for hiding this comment

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

high

The props for CustomTooltip are typed as any. You can use TooltipProps from recharts for proper typing. You'll need to add these imports:

import { TooltipProps } from 'recharts';
import { ValueType, NameType } from 'recharts/types/component/DefaultTooltipContent';
const CustomTooltip = ({ active, payload, label }: TooltipProps<ValueType, NameType>) => {

Comment on lines +76 to +88
const transformedData = Object.entries(data?.data)?.map(
([language, stats]: [string, any]) => ({
language: language.charAt(0).toUpperCase() + language.slice(1),
acceptanceRate: parseFloat(stats.acceptanceRate),
acceptanceCount: parseInt(stats.acceptanceCount),
avgActiveUsers: parseFloat(stats.avgActiveUsers).toFixed(2),
lineAccepted: parseInt(stats.lineAccepted),
lineSuggested: parseInt(stats.lineSuggested),
maxActiveUsers: parseInt(stats.maxActiveUsers),
suggestionCount: parseInt(stats.suggestionCount),
})
);
transformedData?.sort((a, b) => b.acceptanceRate - a.acceptanceRate);

Choose a reason for hiding this comment

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

high

This data transformation logic has a couple of issues:

  1. Performance: It runs on every render. This should be wrapped in a useMemo hook to memoize the result and avoid re-computation. You will need to import useMemo from 'react'.
  2. Robustness: Object.entries(data?.data) will crash if data.data is nullish. It should be Object.entries(data?.data || {}).
  3. Readability: The optional chaining on .map() and transformedData?.sort() can be removed if you handle the nullish case for data.data correctly.

);
transformedData?.sort((a, b) => b.acceptanceRate - a.acceptanceRate);

const CustomBarLabel = (props: any) => {

Choose a reason for hiding this comment

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

high

Avoid using any for props. You can define a specific interface for the props passed to CustomBarLabel by recharts for better type safety.

  const CustomBarLabel = (props: { x: number; y: number; width: number; value: number }) => {

YAxis,
ResponsiveContainer,
Tooltip,
CartesianGrid,

Choose a reason for hiding this comment

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

medium

The CartesianGrid component is imported but not used.

<text
x={x + width + 10}
y={y + 10}
fill="#667085"

Choose a reason for hiding this comment

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

medium

The fill color for the bar label is hardcoded. It's better to use a color from the Chakra UI theme (e.g., colors.text.secondary or colors.gray.600) to ensure consistency and support for different themes like dark mode.

        fill={colors.text.primary} /* Or another appropriate color from your theme */

Comment on lines +194 to +198
{payload[0]?.value &&
!isNaN(payload[0]?.value) &&
payload[0]?.value > 0
? `${payload[0]?.value}%`
: '0'}

Choose a reason for hiding this comment

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

medium

This logic for displaying the acceptance rate is a bit confusing. If the value is 0, it will display '0' instead of '0%'. If the value is invalid, it also displays '0'. It would be more consistent to always show the percentage sign for valid numbers (including 0) and handle invalid values differently, for example by showing 'N/A'.

              {typeof payload[0]?.value === 'number'
                ? `${payload[0].value}%`
                : 'N/A'}

@refacto-visz
Copy link

refacto-visz bot commented Nov 10, 2025

Code Review: HrBarChart Component - Critical Duplication Issue

👍 Well Done
Responsive Chart Implementation

ResponsiveContainer ensures proper chart scaling across different viewport sizes with effective cross-device compatibility

Efficient Data Transformation

Single-pass data transformation with proper sorting optimizes rendering performance

📁 Selected files for review (1)
  • HrBarChart.tsx
🎯 Custom Instructions
✅ Applied Instructions
Organization Guidelines
  • Keep pull requests small and focused (prefer < 400 lines of code).
  • All CI/CD checks, linting, and unit tests must pass before merge.
  • Use feature flags for new functionality and include a clear rollback plan.
  • Follow the company security checklist:
    • No hard-coded secrets or credentials.
    • Validate all external inputs.
    • Use parameterized queries for DB access.

Scope: All files

📝 Additional Comments
HrBarChart.tsx (3)
Inefficient Number Parsing

Multiple parsing operations without validation may cause NaN values and runtime errors. parseFloat and parseInt operations on potentially invalid data create performance overhead and error-prone behavior. Unvalidated parsing can lead to chart rendering failures with malformed data.

Standards:

  • ISO-IEC-25010-Performance-Efficiency-Time-Behavior
  • Input-Validation-Performance
  • Error-Handling-Optimization
Hardcoded Style Values

Magic numbers and hardcoded color values scattered throughout component reduce maintainability and theme consistency. Values like '10', '#667085', '11', '500' should be extracted to theme constants or configuration objects. This improves consistency and enables centralized styling updates.

Standards:

  • Clean-Code-Magic-Numbers
  • Maintainability-Quality-Configuration
Missing Error Boundaries

Chart component lacks error boundary implementation for handling rendering failures gracefully. Recharts library errors propagate uncaught causing complete component tree unmounting. Users experience blank screens instead of fallback UI during chart rendering failures.

Standards:

  • ISO-IEC-25010-Reliability-Fault-Tolerance
  • SRE-Error-Handling

Comment on lines +1 to +10
import { Box, Flex, Text } from '@chakra-ui/react';
import {
BarChart,
Bar,
XAxis,
YAxis,
ResponsiveContainer,
Tooltip,
CartesianGrid,
} from 'recharts';
Copy link

Choose a reason for hiding this comment

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

Duplicate Component Definition

Complete component definition duplicated starting at line 167, creating identical imports, interfaces, and component implementations. This duplication will cause compilation errors due to duplicate symbol definitions and violates DRY principles. The second definition overwrites the first, making the initial 166 lines unreachable dead code.

Standards
  • Algorithm-Correctness-Code-Structure
  • Logic-Verification-Symbol-Uniqueness
  • Org-Guideline-Keep pull requests small and focused

return (
<Box bg="white" p={2} boxShadow="md" borderRadius="md" border="none">
<Flex gap={0.5} flexDirection={'column'} fontSize={'sm'}>
<Text fontWeight={'bold'}>{label}</Text>
Copy link

Choose a reason for hiding this comment

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

XSS via Dynamic Labels

User-controlled label data rendered directly in JSX without sanitization enables XSS attacks. Malicious language names in data could inject scripts into tooltip display. Attackers can execute arbitrary JavaScript in user browsers through crafted chart data.

          <Text fontWeight={'bold'}>{String(label).replace(/<[^>]*>/g, '')}</Text>
Commitable Suggestion
Suggested change
<Text fontWeight={'bold'}>{label}</Text>
<Text fontWeight={'bold'}>{String(label).replace(/<[^>]*>/g, '')}</Text>
Standards
  • CWE-79
  • OWASP-A03
  • NIST-SSDF-PW.1

const { colors } = useTheme();
const transformedData = Object.entries(data?.data)?.map(
([language, stats]: [string, any]) => ({
language: language.charAt(0).toUpperCase() + language.slice(1),
Copy link

Choose a reason for hiding this comment

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

XSS via Language Names

Language names from external data transformed and displayed without sanitization creates XSS vulnerability. Malicious language identifiers containing script tags could execute when rendered in chart labels. User browsers vulnerable to code injection through chart data manipulation.

      language: String(language).replace(/<[^>]*>/g, '').charAt(0).toUpperCase() + String(language).replace(/<[^>]*>/g, '').slice(1),
Commitable Suggestion
Suggested change
language: language.charAt(0).toUpperCase() + language.slice(1),
language: String(language).replace(/<[^>]*>/g, '').charAt(0).toUpperCase() + String(language).replace(/<[^>]*>/g, '').slice(1),
Standards
  • CWE-79
  • OWASP-A03
  • NIST-SSDF-PW.1

Comment on lines +76 to +79
const transformedData = Object.entries(data?.data)?.map(
([language, stats]: [string, any]) => ({
language: language.charAt(0).toUpperCase() + language.slice(1),
acceptanceRate: parseFloat(stats.acceptanceRate),
Copy link

Choose a reason for hiding this comment

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

Unsafe Data Access

Data transformation lacks null safety checks for nested properties causing runtime TypeError exceptions. Missing validation for stats object properties leads to parseFloat(undefined) returning NaN values. Chart rendering fails with invalid data producing blank or corrupted visualizations.

Standards
  • ISO-IEC-25010-Reliability-Fault-Tolerance
  • ISO-IEC-25010-Functional-Correctness-Appropriateness
  • DbC-Preconditions

Comment on lines +13 to +16
interface HrBarChartProps {
data: any;
keys: any;
chartMetadata: any;
Copy link

Choose a reason for hiding this comment

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

Weak Type Definitions

Interface uses 'any' types eliminating TypeScript benefits for type safety and IntelliSense. Weak typing reduces maintainability by hiding data structure contracts and preventing compile-time error detection. Proper interface definitions would improve code documentation and catch integration errors early.

Standards
  • Clean-Code-Meaningful-Names
  • Maintainability-Quality-Type-Safety

Comment on lines +194 to +198
{payload[0]?.value &&
!isNaN(payload[0]?.value) &&
payload[0]?.value > 0
? `${payload[0]?.value}%`
: '0'}
Copy link

Choose a reason for hiding this comment

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

Inconsistent Validation Logic

Tooltip validation logic differs from bar label validation logic for the same data. Tooltip uses comprehensive validation (exists, not NaN, greater than 0) while bar label uses simpler validation (isNaN, null, <= 0). This inconsistency creates different display behaviors for identical edge cases, potentially confusing users when tooltip shows '0' but bar shows no label.

Standards
  • Logic-Verification-Consistency
  • Business-Rule-Display-Logic
  • Algorithm-Correctness-Validation-Patterns

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: 3

🧹 Nitpick comments (2)
HrBarChart.tsx (2)

269-269: Use theme colors consistently instead of hardcoded values.

The component uses theme colors for some elements (e.g., colors.primary, colors.text.primary) but hardcodes others (#667085, #E2E8F0). This makes theming incomplete and harder to maintain.

Consider extracting these colors to your theme:

       <text
         x={x + width + 10}
         y={y + 10}
-        fill="#667085"
+        fill={colors.text.secondary}
         fontSize={11}
         fontWeight={500}
         textAnchor="start"
       >

And for the axes:

-          axisLine={{ stroke: '#E2E8F0', strokeWidth: 1 }}
+          axisLine={{ stroke: colors.border.default, strokeWidth: 1 }}

Also applies to: 291-291, 307-307


168-177: Remove unused CartesianGrid import.

CartesianGrid is imported but never used in the component.

Apply this diff:

 import {
   BarChart,
   Bar,
   XAxis,
   YAxis,
   ResponsiveContainer,
   Tooltip,
-  CartesianGrid,
 } from 'recharts';
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e184110 and 19e6fed.

📒 Files selected for processing (1)
  • HrBarChart.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (2.1.2)
HrBarChart.tsx

[error] 167-167: Shouldn't redeclare 'Box'. Consider to delete it or rename it.

'Box' is defined here:

(lint/suspicious/noRedeclare)


[error] 167-167: Shouldn't redeclare 'Flex'. Consider to delete it or rename it.

'Flex' is defined here:

(lint/suspicious/noRedeclare)


[error] 167-167: Shouldn't redeclare 'Text'. Consider to delete it or rename it.

'Text' is defined here:

(lint/suspicious/noRedeclare)


[error] 169-169: Shouldn't redeclare 'BarChart'. Consider to delete it or rename it.

'BarChart' is defined here:

(lint/suspicious/noRedeclare)


[error] 170-170: Shouldn't redeclare 'Bar'. Consider to delete it or rename it.

'Bar' is defined here:

(lint/suspicious/noRedeclare)


[error] 171-171: Shouldn't redeclare 'XAxis'. Consider to delete it or rename it.

'XAxis' is defined here:

(lint/suspicious/noRedeclare)


[error] 172-172: Shouldn't redeclare 'YAxis'. Consider to delete it or rename it.

'YAxis' is defined here:

(lint/suspicious/noRedeclare)


[error] 173-173: Shouldn't redeclare 'ResponsiveContainer'. Consider to delete it or rename it.

'ResponsiveContainer' is defined here:

(lint/suspicious/noRedeclare)


[error] 174-174: Shouldn't redeclare 'Tooltip'. Consider to delete it or rename it.

'Tooltip' is defined here:

(lint/suspicious/noRedeclare)


[error] 175-175: Shouldn't redeclare 'CartesianGrid'. Consider to delete it or rename it.

'CartesianGrid' is defined here:

(lint/suspicious/noRedeclare)


[error] 177-177: Shouldn't redeclare 'useTheme'. Consider to delete it or rename it.

'useTheme' is defined here:

(lint/suspicious/noRedeclare)


[error] 185-185: Shouldn't redeclare 'CustomTooltip'. Consider to delete it or rename it.

'CustomTooltip' is defined here:

(lint/suspicious/noRedeclare)


[error] 244-244: Shouldn't redeclare 'HrBarChart'. Consider to delete it or rename it.

'HrBarChart' is defined here:

(lint/suspicious/noRedeclare)

Comment on lines +167 to +340
};import { Box, Flex, Text } from '@chakra-ui/react';
import {
BarChart,
Bar,
XAxis,
YAxis,
ResponsiveContainer,
Tooltip,
CartesianGrid,
} from 'recharts';
import { useTheme } from '@chakra-ui/react';

interface HrBarChartProps {
data: any;
keys: any;
chartMetadata: any;
}

const CustomTooltip = ({ active, payload, label }: any) => {
if (active && payload && payload.length) {
return (
<Box bg="white" p={2} boxShadow="md" borderRadius="md" border="none">
<Flex gap={0.5} flexDirection={'column'} fontSize={'sm'}>
<Text fontWeight={'bold'}>{label}</Text>
<Text color="text.secondary2">
Acceptance rate:{' '}
<Text as="span" color="text.primary">
{payload[0]?.value &&
!isNaN(payload[0]?.value) &&
payload[0]?.value > 0
? `${payload[0]?.value}%`
: '0'}
</Text>
</Text>
<Text color="text.secondary2">
Acceptance Count:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.acceptanceCount}
</Text>
</Text>
<Text color="text.secondary2">
Avg Active Users:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.avgActiveUsers}
</Text>
</Text>
<Text color="text.secondary2">
Line Accepted:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.lineAccepted}
</Text>
</Text>
<Text color="text.secondary2">
Line Suggested:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.lineSuggested}
</Text>
</Text>
<Text color="text.secondary2">
Max Active Users:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.maxActiveUsers}
</Text>
</Text>
<Text color="text.secondary2">
Suggestion Count:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.suggestionCount}
</Text>
</Text>
</Flex>
</Box>
);
}
return null;
};

export const HrBarChart = ({ data, chartMetadata }: HrBarChartProps) => {
const { colors } = useTheme();
const transformedData = Object.entries(data?.data)?.map(
([language, stats]: [string, any]) => ({
language: language.charAt(0).toUpperCase() + language.slice(1),
acceptanceRate: parseFloat(stats.acceptanceRate),
acceptanceCount: parseInt(stats.acceptanceCount),
avgActiveUsers: parseFloat(stats.avgActiveUsers).toFixed(2),
lineAccepted: parseInt(stats.lineAccepted),
lineSuggested: parseInt(stats.lineSuggested),
maxActiveUsers: parseInt(stats.maxActiveUsers),
suggestionCount: parseInt(stats.suggestionCount),
})
);
transformedData?.sort((a, b) => b.acceptanceRate - a.acceptanceRate);

const CustomBarLabel = (props: any) => {
const { x, y, width, value } = props;
if (isNaN(value) || value == null || value <= 0) {
return null;
}
return (
<text
x={x + width + 10}
y={y + 10}
fill="#667085"
fontSize={11}
fontWeight={500}
textAnchor="start"
>
{`${value}%`}
</text>
);
};

return (
<Box height="100%" width="100%">
<ResponsiveContainer width="100%" height="100%">
<BarChart
layout="vertical"
data={transformedData}
margin={{ top: 10, right: 10, left: 60, bottom: 10 }}
>
<XAxis
type="number"
domain={[0, 100]}
unit="%"
axisLine={{ stroke: '#E2E8F0', strokeWidth: 1 }}
tickLine={false}
style={{ fontSize: 11, fontWeight: 400, fill: colors.text.primary }}
label={{
value: chartMetadata?.xlabel,
position: 'bottom',
offset: 0,
style: {
textAnchor: 'middle',
fontSize: 11,
},
}}
/>
<YAxis
type="category"
dataKey="language"
axisLine={{ stroke: '#E2E8F0', strokeWidth: 1 }}
tickLine={false}
interval={0}
style={{ fontSize: 13, fontWeight: 400, fill: colors.text.primary }}
label={{
value: chartMetadata?.ylabel,
angle: -90,
position: 'outsideLeft',
fontSize: 11,
fontWeight: 400,
dy: 40,
dx: -60,
zIndex: 1000,
}}
/>
<Tooltip
cursor={false}
content={<CustomTooltip />}
wrapperStyle={{ outline: 'none' }}
/>
<Bar
dataKey="acceptanceRate"
fill={colors.primary}
radius={[0, 4, 4, 0]}
barSize={20}
label={<CustomBarLabel />}
animationDuration={1000}
animationBegin={0}
/>
</BarChart>
</ResponsiveContainer>
</Box>
);
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Remove duplicate code - the entire file is repeated.

The entire file content is duplicated starting at line 167. This causes redeclaration errors for all imports, interfaces, and components. The second version (lines 167-340) includes improvements like NaN validation in the tooltip and bar label, so the first version (lines 1-166) should be removed.

Apply this diff to remove the duplicate:

-import { Box, Flex, Text } from '@chakra-ui/react';
-import {
-  BarChart,
-  Bar,
-  XAxis,
-  YAxis,
-  ResponsiveContainer,
-  Tooltip,
-  CartesianGrid,
-} from 'recharts';
-import { useTheme } from '@chakra-ui/react';
-
-interface HrBarChartProps {
-  data: any;
-  keys: any;
-  chartMetadata: any;
-}
-
-const CustomTooltip = ({ active, payload, label }: any) => {
-  if (active && payload && payload.length) {
-    return (
-      <Box bg="white" p={2} boxShadow="md" borderRadius="md" border="none">
-        <Flex gap={0.5} flexDirection={'column'} fontSize={'sm'}>
-          <Text fontWeight={'bold'}>{label}</Text>
-          <Text color="text.secondary2">
-            Acceptance rate:{' '}
-            <Text as="span" color="text.primary">
-              {payload[0]?.value}%
-            </Text>
-          </Text>
-          <Text color="text.secondary2">
-            Acceptance Count:{' '}
-            <Text as="span" color="text.primary">
-              {payload[0]?.payload.acceptanceCount}
-            </Text>
-          </Text>
-          <Text color="text.secondary2">
-            Avg Active Users:{' '}
-            <Text as="span" color="text.primary">
-              {payload[0]?.payload.avgActiveUsers}
-            </Text>
-          </Text>
-          <Text color="text.secondary2">
-            Line Accepted:{' '}
-            <Text as="span" color="text.primary">
-              {payload[0]?.payload.lineAccepted}
-            </Text>
-          </Text>
-          <Text color="text.secondary2">
-            Line Suggested:{' '}
-            <Text as="span" color="text.primary">
-              {payload[0]?.payload.lineSuggested}
-            </Text>
-          </Text>
-          <Text color="text.secondary2">
-            Max Active Users:{' '}
-            <Text as="span" color="text.primary">
-              {payload[0]?.payload.maxActiveUsers}
-            </Text>
-          </Text>
-          <Text color="text.secondary2">
-            Suggestion Count:{' '}
-            <Text as="span" color="text.primary">
-              {payload[0]?.payload.suggestionCount}
-            </Text>
-          </Text>
-        </Flex>
-      </Box>
-    );
-  }
-  return null;
-};
-
-export const HrBarChart = ({ data, chartMetadata }: HrBarChartProps) => {
-  const { colors } = useTheme();
-  const transformedData = Object.entries(data?.data)?.map(
-    ([language, stats]: [string, any]) => ({
-      language: language.charAt(0).toUpperCase() + language.slice(1),
-      acceptanceRate: parseFloat(stats.acceptanceRate),
-      acceptanceCount: parseInt(stats.acceptanceCount),
-      avgActiveUsers: parseFloat(stats.avgActiveUsers).toFixed(2),
-      lineAccepted: parseInt(stats.lineAccepted),
-      lineSuggested: parseInt(stats.lineSuggested),
-      maxActiveUsers: parseInt(stats.maxActiveUsers),
-      suggestionCount: parseInt(stats.suggestionCount),
-    })
-  );
-  transformedData?.sort((a, b) => b.acceptanceRate - a.acceptanceRate);
-
-  const CustomBarLabel = (props: any) => {
-    const { x, y, width, value } = props;
-    return (
-      <text
-        x={x + width + 10}
-        y={y + 10}
-        fill="#667085"
-        fontSize={11}
-        fontWeight={500}
-        textAnchor="start"
-      >
-        {`${value}%`}
-      </text>
-    );
-  };
-
-  return (
-    <Box height="100%" width="100%">
-      <ResponsiveContainer width="100%" height="100%">
-        <BarChart
-          layout="vertical"
-          data={transformedData}
-          margin={{ top: 10, right: 10, left: 60, bottom: 10 }}
-        >
-          <XAxis
-            type="number"
-            domain={[0, 100]}
-            unit="%"
-            axisLine={{ stroke: '#E2E8F0', strokeWidth: 1 }}
-            tickLine={false}
-            style={{ fontSize: 11, fontWeight: 400, fill: colors.text.primary }}
-            label={{
-              value: chartMetadata?.xlabel,
-              position: 'bottom',
-              offset: 0,
-              style: {
-                textAnchor: 'middle',
-                fontSize: 11,
-              },
-            }}
-          />
-          <YAxis
-            type="category"
-            dataKey="language"
-            axisLine={{ stroke: '#E2E8F0', strokeWidth: 1 }}
-            tickLine={false}
-            interval={0}
-            style={{ fontSize: 13, fontWeight: 400, fill: colors.text.primary }}
-            label={{
-              value: chartMetadata?.ylabel,
-              angle: -90,
-              position: 'outsideLeft',
-              fontSize: 11,
-              fontWeight: 400,
-              dy: 40,
-              dx: -60,
-              zIndex: 1000,
-            }}
-          />
-          <Tooltip
-            cursor={false}
-            content={<CustomTooltip />}
-            wrapperStyle={{ outline: 'none' }}
-          />
-          <Bar
-            dataKey="acceptanceRate"
-            fill={colors.primary}
-            radius={[0, 4, 4, 0]}
-            barSize={20}
-            label={<CustomBarLabel />}
-            animationDuration={1000}
-            animationBegin={0}
-          />
-        </BarChart>
-      </ResponsiveContainer>
-    </Box>
-  );
-};

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Biome (2.1.2)

[error] 167-167: Shouldn't redeclare 'Box'. Consider to delete it or rename it.

'Box' is defined here:

(lint/suspicious/noRedeclare)


[error] 167-167: Shouldn't redeclare 'Flex'. Consider to delete it or rename it.

'Flex' is defined here:

(lint/suspicious/noRedeclare)


[error] 167-167: Shouldn't redeclare 'Text'. Consider to delete it or rename it.

'Text' is defined here:

(lint/suspicious/noRedeclare)


[error] 169-169: Shouldn't redeclare 'BarChart'. Consider to delete it or rename it.

'BarChart' is defined here:

(lint/suspicious/noRedeclare)


[error] 170-170: Shouldn't redeclare 'Bar'. Consider to delete it or rename it.

'Bar' is defined here:

(lint/suspicious/noRedeclare)


[error] 171-171: Shouldn't redeclare 'XAxis'. Consider to delete it or rename it.

'XAxis' is defined here:

(lint/suspicious/noRedeclare)


[error] 172-172: Shouldn't redeclare 'YAxis'. Consider to delete it or rename it.

'YAxis' is defined here:

(lint/suspicious/noRedeclare)


[error] 173-173: Shouldn't redeclare 'ResponsiveContainer'. Consider to delete it or rename it.

'ResponsiveContainer' is defined here:

(lint/suspicious/noRedeclare)


[error] 174-174: Shouldn't redeclare 'Tooltip'. Consider to delete it or rename it.

'Tooltip' is defined here:

(lint/suspicious/noRedeclare)


[error] 175-175: Shouldn't redeclare 'CartesianGrid'. Consider to delete it or rename it.

'CartesianGrid' is defined here:

(lint/suspicious/noRedeclare)


[error] 177-177: Shouldn't redeclare 'useTheme'. Consider to delete it or rename it.

'useTheme' is defined here:

(lint/suspicious/noRedeclare)


[error] 185-185: Shouldn't redeclare 'CustomTooltip'. Consider to delete it or rename it.

'CustomTooltip' is defined here:

(lint/suspicious/noRedeclare)


[error] 244-244: Shouldn't redeclare 'HrBarChart'. Consider to delete it or rename it.

'HrBarChart' is defined here:

(lint/suspicious/noRedeclare)

🤖 Prompt for AI Agents
In HrBarChart.tsx around lines 167-340 there is a duplicated copy of the file
(imports, interface and component re-declared), causing redeclaration errors;
remove the earlier duplicate (lines 1-166) so only the improved version (the one
with NaN validation in tooltip and bar label) remains, ensuring a single set of
imports, the HrBarChartProps interface, CustomTooltip, CustomBarLabel and
HrBarChart component; after removing, save and run build/lint to confirm no
redeclarations remain.

Comment on lines +179 to +183
interface HrBarChartProps {
data: any;
keys: any;
chartMetadata: any;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Replace any types with proper TypeScript interfaces and remove unused keys prop.

All props are typed as any, which eliminates type safety. The keys prop is defined but never used in the component, suggesting it may be unnecessary or the implementation is incomplete.

Consider defining proper types:

interface ChartStats {
  acceptanceRate: string | number;
  acceptanceCount: string | number;
  avgActiveUsers: string | number;
  lineAccepted: string | number;
  lineSuggested: string | number;
  maxActiveUsers: string | number;
  suggestionCount: string | number;
}

interface ChartData {
  data: Record<string, ChartStats>;
}

interface ChartMetadata {
  xlabel?: string;
  ylabel?: string;
}

interface HrBarChartProps {
  data: ChartData;
  chartMetadata: ChartMetadata;
  // Remove keys prop if not needed, or add implementation if required
}
🤖 Prompt for AI Agents
In HrBarChart.tsx around lines 179 to 183, replace the loose any types and
remove the unused keys prop: define and use specific interfaces for the incoming
props (e.g., ChartStats for each metric, ChartData for the data container and
ChartMetadata for chart labels) and update HrBarChartProps to accept data:
ChartData and chartMetadata: ChartMetadata (omit keys); update any internal
usages to match the new property shapes and run type checks to fix any type
errors that result.

Comment on lines +246 to +258
const transformedData = Object.entries(data?.data)?.map(
([language, stats]: [string, any]) => ({
language: language.charAt(0).toUpperCase() + language.slice(1),
acceptanceRate: parseFloat(stats.acceptanceRate),
acceptanceCount: parseInt(stats.acceptanceCount),
avgActiveUsers: parseFloat(stats.avgActiveUsers).toFixed(2),
lineAccepted: parseInt(stats.lineAccepted),
lineSuggested: parseInt(stats.lineSuggested),
maxActiveUsers: parseInt(stats.maxActiveUsers),
suggestionCount: parseInt(stats.suggestionCount),
})
);
transformedData?.sort((a, b) => b.acceptanceRate - a.acceptanceRate);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add null checks and error handling for data transformation.

The transformation assumes data?.data exists after optional chaining. If it's undefined, Object.entries(undefined) will throw. Additionally, the sort operation on transformedData will fail if it's undefined.

Apply this diff to add proper guards:

 export const HrBarChart = ({ data, chartMetadata }: HrBarChartProps) => {
   const { colors } = useTheme();
+  
+  if (!data?.data) {
+    return null; // or a fallback UI
+  }
+  
   const transformedData = Object.entries(data.data)?.map(
     ([language, stats]: [string, any]) => ({
       language: language.charAt(0).toUpperCase() + language.slice(1),
-      acceptanceRate: parseFloat(stats.acceptanceRate),
+      acceptanceRate: parseFloat(stats.acceptanceRate) || 0,
       acceptanceCount: parseInt(stats.acceptanceCount) || 0,
-      avgActiveUsers: parseFloat(stats.avgActiveUsers).toFixed(2),
+      avgActiveUsers: parseFloat(stats.avgActiveUsers || 0).toFixed(2),
       lineAccepted: parseInt(stats.lineAccepted) || 0,
       lineSuggested: parseInt(stats.lineSuggested) || 0,
       maxActiveUsers: parseInt(stats.maxActiveUsers) || 0,
       suggestionCount: parseInt(stats.suggestionCount) || 0,
     })
   );
-  transformedData?.sort((a, b) => b.acceptanceRate - a.acceptanceRate);
+  transformedData.sort((a, b) => b.acceptanceRate - a.acceptanceRate);

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +80 to +85
acceptanceCount: parseInt(stats.acceptanceCount),
avgActiveUsers: parseFloat(stats.avgActiveUsers).toFixed(2),
lineAccepted: parseInt(stats.lineAccepted),
lineSuggested: parseInt(stats.lineSuggested),
maxActiveUsers: parseInt(stats.maxActiveUsers),
suggestionCount: parseInt(stats.suggestionCount),
Copy link

Choose a reason for hiding this comment

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

Suggestion: Add an explicit radix (10) to all parseInt calls inside the data transformation to ensure decimal parsing. [best practice]

Severity Level: Minor ⚠️

Suggested change
acceptanceCount: parseInt(stats.acceptanceCount),
avgActiveUsers: parseFloat(stats.avgActiveUsers).toFixed(2),
lineAccepted: parseInt(stats.lineAccepted),
lineSuggested: parseInt(stats.lineSuggested),
maxActiveUsers: parseInt(stats.maxActiveUsers),
suggestionCount: parseInt(stats.suggestionCount),
acceptanceCount: parseInt(stats.acceptanceCount, 10),
lineAccepted: parseInt(stats.lineAccepted, 10),
lineSuggested: parseInt(stats.lineSuggested, 10),
maxActiveUsers: parseInt(stats.maxActiveUsers, 10),
suggestionCount: parseInt(stats.suggestionCount, 10),
Why it matters? ⭐

The file currently calls parseInt(...) without an explicit radix in multiple places (e.g. lines shown by grep). While modern engines default to base 10 for most inputs, explicitly passing 10 is a simple, standard best practice that avoids surprising behavior for strings with leading zeros or non-decimal contexts. This change is low risk and improves clarity.

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** HrBarChart.tsx
**Line:** 80:85
**Comment:**
	*Best Practice: Add an explicit radix (10) to all parseInt calls inside the data transformation to ensure decimal parsing.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.

Comment on lines +167 to +340
};import { Box, Flex, Text } from '@chakra-ui/react';
import {
BarChart,
Bar,
XAxis,
YAxis,
ResponsiveContainer,
Tooltip,
CartesianGrid,
} from 'recharts';
import { useTheme } from '@chakra-ui/react';

interface HrBarChartProps {
data: any;
keys: any;
chartMetadata: any;
}

const CustomTooltip = ({ active, payload, label }: any) => {
if (active && payload && payload.length) {
return (
<Box bg="white" p={2} boxShadow="md" borderRadius="md" border="none">
<Flex gap={0.5} flexDirection={'column'} fontSize={'sm'}>
<Text fontWeight={'bold'}>{label}</Text>
<Text color="text.secondary2">
Acceptance rate:{' '}
<Text as="span" color="text.primary">
{payload[0]?.value &&
!isNaN(payload[0]?.value) &&
payload[0]?.value > 0
? `${payload[0]?.value}%`
: '0'}
</Text>
</Text>
<Text color="text.secondary2">
Acceptance Count:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.acceptanceCount}
</Text>
</Text>
<Text color="text.secondary2">
Avg Active Users:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.avgActiveUsers}
</Text>
</Text>
<Text color="text.secondary2">
Line Accepted:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.lineAccepted}
</Text>
</Text>
<Text color="text.secondary2">
Line Suggested:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.lineSuggested}
</Text>
</Text>
<Text color="text.secondary2">
Max Active Users:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.maxActiveUsers}
</Text>
</Text>
<Text color="text.secondary2">
Suggestion Count:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.suggestionCount}
</Text>
</Text>
</Flex>
</Box>
);
}
return null;
};

export const HrBarChart = ({ data, chartMetadata }: HrBarChartProps) => {
const { colors } = useTheme();
const transformedData = Object.entries(data?.data)?.map(
([language, stats]: [string, any]) => ({
language: language.charAt(0).toUpperCase() + language.slice(1),
acceptanceRate: parseFloat(stats.acceptanceRate),
acceptanceCount: parseInt(stats.acceptanceCount),
avgActiveUsers: parseFloat(stats.avgActiveUsers).toFixed(2),
lineAccepted: parseInt(stats.lineAccepted),
lineSuggested: parseInt(stats.lineSuggested),
maxActiveUsers: parseInt(stats.maxActiveUsers),
suggestionCount: parseInt(stats.suggestionCount),
})
);
transformedData?.sort((a, b) => b.acceptanceRate - a.acceptanceRate);

const CustomBarLabel = (props: any) => {
const { x, y, width, value } = props;
if (isNaN(value) || value == null || value <= 0) {
return null;
}
return (
<text
x={x + width + 10}
y={y + 10}
fill="#667085"
fontSize={11}
fontWeight={500}
textAnchor="start"
>
{`${value}%`}
</text>
);
};

return (
<Box height="100%" width="100%">
<ResponsiveContainer width="100%" height="100%">
<BarChart
layout="vertical"
data={transformedData}
margin={{ top: 10, right: 10, left: 60, bottom: 10 }}
>
<XAxis
type="number"
domain={[0, 100]}
unit="%"
axisLine={{ stroke: '#E2E8F0', strokeWidth: 1 }}
tickLine={false}
style={{ fontSize: 11, fontWeight: 400, fill: colors.text.primary }}
label={{
value: chartMetadata?.xlabel,
position: 'bottom',
offset: 0,
style: {
textAnchor: 'middle',
fontSize: 11,
},
}}
/>
<YAxis
type="category"
dataKey="language"
axisLine={{ stroke: '#E2E8F0', strokeWidth: 1 }}
tickLine={false}
interval={0}
style={{ fontSize: 13, fontWeight: 400, fill: colors.text.primary }}
label={{
value: chartMetadata?.ylabel,
angle: -90,
position: 'outsideLeft',
fontSize: 11,
fontWeight: 400,
dy: 40,
dx: -60,
zIndex: 1000,
}}
/>
<Tooltip
cursor={false}
content={<CustomTooltip />}
wrapperStyle={{ outline: 'none' }}
/>
<Bar
dataKey="acceptanceRate"
fill={colors.primary}
radius={[0, 4, 4, 0]}
barSize={20}
label={<CustomBarLabel />}
animationDuration={1000}
animationBegin={0}
/>
</BarChart>
</ResponsiveContainer>
</Box>
);
};
Copy link

Choose a reason for hiding this comment

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

Suggestion: Remove the duplicated entire component block (the second copy) to avoid duplicate imports and duplicate HrBarChart declarations. [possible bug]

Severity Level: Critical 🚨

Suggested change
};import { Box, Flex, Text } from '@chakra-ui/react';
import {
BarChart,
Bar,
XAxis,
YAxis,
ResponsiveContainer,
Tooltip,
CartesianGrid,
} from 'recharts';
import { useTheme } from '@chakra-ui/react';
interface HrBarChartProps {
data: any;
keys: any;
chartMetadata: any;
}
const CustomTooltip = ({ active, payload, label }: any) => {
if (active && payload && payload.length) {
return (
<Box bg="white" p={2} boxShadow="md" borderRadius="md" border="none">
<Flex gap={0.5} flexDirection={'column'} fontSize={'sm'}>
<Text fontWeight={'bold'}>{label}</Text>
<Text color="text.secondary2">
Acceptance rate:{' '}
<Text as="span" color="text.primary">
{payload[0]?.value &&
!isNaN(payload[0]?.value) &&
payload[0]?.value > 0
? `${payload[0]?.value}%`
: '0'}
</Text>
</Text>
<Text color="text.secondary2">
Acceptance Count:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.acceptanceCount}
</Text>
</Text>
<Text color="text.secondary2">
Avg Active Users:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.avgActiveUsers}
</Text>
</Text>
<Text color="text.secondary2">
Line Accepted:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.lineAccepted}
</Text>
</Text>
<Text color="text.secondary2">
Line Suggested:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.lineSuggested}
</Text>
</Text>
<Text color="text.secondary2">
Max Active Users:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.maxActiveUsers}
</Text>
</Text>
<Text color="text.secondary2">
Suggestion Count:{' '}
<Text as="span" color="text.primary">
{payload[0]?.payload.suggestionCount}
</Text>
</Text>
</Flex>
</Box>
);
}
return null;
};
export const HrBarChart = ({ data, chartMetadata }: HrBarChartProps) => {
const { colors } = useTheme();
const transformedData = Object.entries(data?.data)?.map(
([language, stats]: [string, any]) => ({
language: language.charAt(0).toUpperCase() + language.slice(1),
acceptanceRate: parseFloat(stats.acceptanceRate),
acceptanceCount: parseInt(stats.acceptanceCount),
avgActiveUsers: parseFloat(stats.avgActiveUsers).toFixed(2),
lineAccepted: parseInt(stats.lineAccepted),
lineSuggested: parseInt(stats.lineSuggested),
maxActiveUsers: parseInt(stats.maxActiveUsers),
suggestionCount: parseInt(stats.suggestionCount),
})
);
transformedData?.sort((a, b) => b.acceptanceRate - a.acceptanceRate);
const CustomBarLabel = (props: any) => {
const { x, y, width, value } = props;
if (isNaN(value) || value == null || value <= 0) {
return null;
}
return (
<text
x={x + width + 10}
y={y + 10}
fill="#667085"
fontSize={11}
fontWeight={500}
textAnchor="start"
>
{`${value}%`}
</text>
);
};
return (
<Box height="100%" width="100%">
<ResponsiveContainer width="100%" height="100%">
<BarChart
layout="vertical"
data={transformedData}
margin={{ top: 10, right: 10, left: 60, bottom: 10 }}
>
<XAxis
type="number"
domain={[0, 100]}
unit="%"
axisLine={{ stroke: '#E2E8F0', strokeWidth: 1 }}
tickLine={false}
style={{ fontSize: 11, fontWeight: 400, fill: colors.text.primary }}
label={{
value: chartMetadata?.xlabel,
position: 'bottom',
offset: 0,
style: {
textAnchor: 'middle',
fontSize: 11,
},
}}
/>
<YAxis
type="category"
dataKey="language"
axisLine={{ stroke: '#E2E8F0', strokeWidth: 1 }}
tickLine={false}
interval={0}
style={{ fontSize: 13, fontWeight: 400, fill: colors.text.primary }}
label={{
value: chartMetadata?.ylabel,
angle: -90,
position: 'outsideLeft',
fontSize: 11,
fontWeight: 400,
dy: 40,
dx: -60,
zIndex: 1000,
}}
/>
<Tooltip
cursor={false}
content={<CustomTooltip />}
wrapperStyle={{ outline: 'none' }}
/>
<Bar
dataKey="acceptanceRate"
fill={colors.primary}
radius={[0, 4, 4, 0]}
barSize={20}
label={<CustomBarLabel />}
animationDuration={1000}
animationBegin={0}
/>
</BarChart>
</ResponsiveContainer>
</Box>
);
};
Why it matters? ⭐

The repository file HrBarChart.tsx currently contains two full copies of the component (I observed two export const HrBarChart declarations — at lines reported by grep). That produces duplicate imports/definitions and will cause conflicts / duplicate identifier errors in TypeScript. Removing the duplicated second block is the correct fix — it removes the redundant imports and the duplicate component declaration and leaves a single valid component.

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** HrBarChart.tsx
**Line:** 167:340
**Comment:**
	*Possible Bug: Remove the duplicated entire component block (the second copy) to avoid duplicate imports and duplicate `HrBarChart` declarations.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.

@codeant-ai
Copy link

codeant-ai bot commented Nov 10, 2025

CodeAnt AI finished reviewing your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants