Skip to content

Conversation

lposen
Copy link
Contributor

@lposen lposen commented Oct 14, 2025

🔹 JIRA Ticket(s) if any

✏️ Description

Created IterableEmbeddedCard component

@lposen lposen added the embedded Issues/PRs related to Embedded Messages label Oct 14, 2025
@github-actions
Copy link

Lines Statements Branches Functions
Coverage: 41%
42.01% (321/764) 16.8% (59/351) 38.2% (102/267)

@qltysh
Copy link

qltysh bot commented Oct 14, 2025

Diff Coverage: The code coverage on the diff in this pull request is 35.7%.

Total Coverage: This PR will increase coverage by 0.08%.

File Coverage Changes
Path File Coverage Δ Indirect
src/embedded/components/IterableEmbeddedCard.tsx -20.0
src/embedded/components/IterableEmbeddedCard/IterableEmbeddedCard.styles.ts 100.0
src/embedded/components/IterableEmbeddedCard/IterableEmbeddedCard.tsx 11.1
src/embedded/components/IterableEmbeddedCard/index.ts 100.0
🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

This is from Qlty Cloud, the successor to Code Climate Quality. Learn more.

@qltysh
Copy link

qltysh bot commented Oct 14, 2025

3 new issues

Tool Category Rule Count
qlty Duplication Found 19 lines of similar code in 3 locations (mass = 65) 2
qlty Structure Function with high complexity (count = 13): IterableEmbeddedCard 1

This is from Qlty Cloud, the successor to Code Climate Quality. Learn more.

Comment on lines +21 to +135
export const IterableEmbeddedCard = ({
config,
message,
onButtonClick = () => {},
onMessageClick = () => {},
}: IterableEmbeddedComponentProps) => {
const {
componentRef,
handleButtonClick,
handleLayout,
handleMessageClick,
media,
parsedStyles,
} = useEmbeddedView(IterableEmbeddedViewType.Card, {
message,
config,
onButtonClick,
onMessageClick,
});
const buttons = message?.elements?.buttons ?? [];

return (
<Pressable onPress={() => handleMessageClick()}>
<View
ref={componentRef}
focusable={true}
removeClippedSubviews={true}
onLayout={handleLayout}
style={[
styles.container,
{
backgroundColor: parsedStyles.backgroundColor,
borderColor: parsedStyles.borderColor,
borderRadius: parsedStyles.borderCornerRadius,
borderWidth: parsedStyles.borderWidth,
} as ViewStyle,
]}
>
<View
style={[
styles.mediaContainer,
media.shouldShow ? {} : styles.mediaContainerNoImage,
]}
>
<Image
source={
media.shouldShow
? {
uri: media.url as string,
height: PixelRatio.getPixelSizeForLayoutSize(IMAGE_HEIGHT),
}
: // eslint-disable-next-line @typescript-eslint/no-require-imports
require('../../../core/images/logo-grey.png')
}
style={
media.shouldShow
? styles.mediaImage
: styles.mediaImagePlaceholder
}
alt={media.caption as string}
/>
</View>
<View style={styles.bodyContainer}>
<View style={styles.textContainer}>
<Text
style={[
styles.title,
{ color: parsedStyles.titleTextColor } as TextStyle,
]}
>
{message.elements?.title}
</Text>
<Text
style={[
styles.body,
{ color: parsedStyles.bodyTextColor } as TextStyle,
]}
>
{message.elements?.body}
</Text>
</View>
{buttons.length > 0 && (
<View style={styles.buttonContainer}>
{buttons.map((button, index) => {
const backgroundColor =
index === 0
? parsedStyles.primaryBtnBackgroundColor
: parsedStyles.secondaryBtnBackgroundColor;
const textColor =
index === 0
? parsedStyles.primaryBtnTextColor
: parsedStyles.secondaryBtnTextColor;
return (
<TouchableOpacity
style={[styles.button, { backgroundColor } as ViewStyle]}
onPress={() => handleButtonClick(button)}
key={button.id}
>
<Text
style={[
styles.buttonText,
{ color: textColor } as TextStyle,
]}
>
{button.title}
</Text>
</TouchableOpacity>
);
})}
</View>
)}
</View>
</View>
</Pressable>
);
Copy link

Choose a reason for hiding this comment

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

Function with high complexity (count = 13): IterableEmbeddedCard [qlty:function-complexity]

Comment on lines +83 to +100
<View style={styles.bodyContainer}>
<View style={styles.textContainer}>
<Text
style={[
styles.title,
{ color: parsedStyles.titleTextColor } as TextStyle,
]}
>
{message.elements?.title}
</Text>
<Text
style={[
styles.body,
{ color: parsedStyles.bodyTextColor } as TextStyle,
]}
>
{message.elements?.body}
</Text>
Copy link

Choose a reason for hiding this comment

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

Found 19 lines of similar code in 3 locations (mass = 65) [qlty:similar-code]

Comment on lines +101 to +130
</View>
{buttons.length > 0 && (
<View style={styles.buttonContainer}>
{buttons.map((button, index) => {
const backgroundColor =
index === 0
? parsedStyles.primaryBtnBackgroundColor
: parsedStyles.secondaryBtnBackgroundColor;
const textColor =
index === 0
? parsedStyles.primaryBtnTextColor
: parsedStyles.secondaryBtnTextColor;
return (
<TouchableOpacity
style={[styles.button, { backgroundColor } as ViewStyle]}
onPress={() => handleButtonClick(button)}
key={button.id}
>
<Text
style={[
styles.buttonText,
{ color: textColor } as TextStyle,
]}
>
{button.title}
</Text>
</TouchableOpacity>
);
})}
</View>
Copy link

Choose a reason for hiding this comment

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

Found 31 lines of similar code in 3 locations (mass = 113) [qlty:similar-code]

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

Labels

embedded Issues/PRs related to Embedded Messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant