Showing 8,855 of 8,855 total issues
Function Row
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const Row = ({
name,
row,
onChange,
disableAllRow,
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function router
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const router = (handlerData) => {
handlerData.userStep = userSteps('getStep', handlerData.userJID);
if (messageCheck(handlerData.message, 'close') || messageCheck(handlerData.message, 'leave')) {
return leaveHandler(handlerData);
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function produceNfmtItems
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const produceNfmtItems = (array = []) => {
const result = [];
const rareTotal = 20;
const uniqueTotal = 1;
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function EditAcl
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const EditAcl: React.FC<IEditAcl> = ({ userId, updateData }) => {
const [userAcl, setUserAcl] = useState<IUserAcl>();
const [userAclApplicationKeys, setUserAclApplicationKeys] = useState<
Array<TKeys>
>([]);
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getPosition
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const getPosition = (
arr: TMessageHistory[],
message: TMessageHistory,
index: number
) => {
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if (START_BOT_COMMANDS.includes(msgText.toLocaleLowerCase())) {
const data = stanza.getChild('data')
if (data) {
const newParticipant: Participant = {
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (isValid) {
// next question
participant.answers[currentQuestion.name] = participant.msg
await nextMessage(
participant,
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (isValid) {
// next question
participant.answers[currentQuestion.name] = participant.msg;
await nextMessage(
participant,
- Create a ticketCreate a ticket
Function OtherProfile
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function OtherProfile(props: TProps) {
const [loading, setLoading] = useState(true);
const [profile, setProfile] = useState<TProfile>();
const [transactions, setTransactions] =
useState<ExplorerRespose<ITransaction[]>>();
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function nextMessage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
participant: Participant,
questions: Question[],
participants: { [key: string]: Participant },
onEnd: (p: Participant, client: Client, walletAddress: string) => Promise<void>,
client: Client,
- Create a ticketCreate a ticket
Function repeatMessage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
participant: Participant,
questions: Question[],
participants: { [key: string]: Participant },
onEnd: (p: Participant, client: Client, walletAddress: string) => Promise<void>,
client: Client,
- Create a ticketCreate a ticket
Function nextMessage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
participant: Participant,
questions: Question[],
participants: { [key: string]: Participant },
onEnd: (p: Participant, client: Client, walletAddress: string) => Promise<void>,
client: Client,
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (START_BOT_COMMANDS.includes(msgText.toLocaleLowerCase())) {
const data = stanza.getChild("data");
if (data) {
const newParticipant: Participant = {
- Create a ticketCreate a ticket
Function repeatMessage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
participant: Participant,
questions: Question[],
participants: { [key: string]: Participant },
onEnd: (p: Participant, client: Client, walletAddress: string) => Promise<void>,
client: Client,
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (
this.blackList.find(item => item.userJid === message.user._id)
?.userJid
) {
return;
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (message.isReply && message.mainMessage?.id) {
const thread = temporaryArchiveMessages.filter(
item => item.mainMessage?.id === message.mainMessage?.id,
);
this.updateMessageProperty(
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (message.system) {
if (message?.contractAddress && message.nftId) {
await updateMessageToWrapped(message.receiverMessageId, {
nftId: message.nftId,
contractAddress: message.contractAddress,
- Create a ticketCreate a ticket
Function NftListItem
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const NftListItem = (props: NftListItemProps) => {
const {
assetUrl,
assetsYouHave,
totalAssets,
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function EnterInviteCode
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const EnterInviteCode = observer(() => {
const [code, setCode] = useState('');
const [loading, setLoading] = useState(false);
const {loginStore, apiStore} = useStores();
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (userStep === 5 && receiverData.attrs.isSystemMessage && receiverData.attrs.tokenAmount >= 1) {
return searchItemsHandler(handlerData)
}
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 50.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76