kleros/kleros-v2

View on GitHub

Showing 1,278 of 1,394 total issues

Function updateJurorEffectiveStake has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export function updateJurorEffectiveStake(jurorAddress: string, courtID: string): void {
  let court = Court.load(courtID);
  if (!court) {
    return;
  }
Severity: Minor
Found in subgraph/core/src/entities/JurorTokensPerCourt.ts - About 1 hr to fix

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 3 locations. Consider refactoring.
Open

export const landscapeStyle = (styleFn: () => FlattenInterpolation<ThemeProps<DefaultTheme>>) => css`
  @media (min-width: ${BREAKPOINT_LANDSCAPE}px) {
    ${() => styleFn()}
  }
`;
Severity: Major
Found in web-devtools/src/styles/landscapeStyle.ts and 2 other locations - About 1 hr to fix
web/src/styles/landscapeStyle.ts on lines 5..9
web/src/styles/portraitStyle.ts on lines 5..9

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 60.

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

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

export const debounceErrorToast = (msg: string) => {
  if (timeoutId) clearTimeout(timeoutId);

  timeoutId = setTimeout(() => {
    toast.error(msg, toastOptions);
Severity: Major
Found in web-devtools/src/utils/debounceErrorToast.ts and 1 other location - About 1 hr to fix
web/src/utils/debounceErrorToast.ts on lines 6..12

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 60.

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

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

export const debounceErrorToast = (msg: string) => {
  if (timeoutId) clearTimeout(timeoutId);

  timeoutId = setTimeout(() => {
    toast.error(msg, toastOptions);
Severity: Major
Found in web/src/utils/debounceErrorToast.ts and 1 other location - About 1 hr to fix
web-devtools/src/utils/debounceErrorToast.ts on lines 6..12

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 60.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      <StyledTabs
        currentValue={currentTab}
        items={filteredTabs}
        callback={(n: number) => {
          setCurrentTab(n);
Severity: Major
Found in web/src/pages/Courts/CourtDetails/Description.tsx and 1 other location - About 1 hr to fix
web/src/pages/Cases/CaseDetails/Tabs.tsx on lines 85..92

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 60.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    <StyledTabs
      currentValue={currentTab}
      items={tabs}
      callback={(n: number) => {
        setCurrentTab(n);
Severity: Major
Found in web/src/pages/Cases/CaseDetails/Tabs.tsx and 1 other location - About 1 hr to fix
web/src/pages/Courts/CourtDetails/Description.tsx on lines 85..92

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 60.

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

Further Reading

Function uploadToIpfs has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function uploadToIpfs(config: Config, payload: IpfsUploadPayload): Promise<string | null> {
  const formData = new FormData();
  formData.append("file", payload.file, payload.name);
  formData.append("name", payload.name);
  formData.append("product", payload.product);
Severity: Minor
Found in web/src/utils/atlas/uploadToIpfs.ts - About 1 hr to fix

Function General has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const General: React.FC = () => {
  const { address, chain } = useAccount();

  const addressExplorerLink = useMemo(() => {
    return `${chain?.blockExplorers?.default.url}/address/${address}`;
Severity: Minor
Found in web/src/layout/Header/navbar/Menu/Settings/General.tsx - About 1 hr to fix

Function deployResolver has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployResolver: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers } = hre;

  const template = `{
    "$schema": "../NewDisputeTemplate.schema.json",
Severity: Minor
Found in contracts/deploy/05-arbitrable-dispute-template.ts - About 1 hr to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

const ring = (duration: string, delay: string) => css`
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
web/src/components/DottedMenuButton.tsx on lines 22..39

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 59.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

const SecuredByKleros: React.FC = () => (
  <a className="secured-by-kleros" href="https://kleros.io" target="_blank" rel="noreferrer">
    <SecuredByKlerosLogo />
  </a>
);
Severity: Major
Found in web/src/layout/Footer/index.tsx and 1 other location - About 1 hr to fix
web-devtools/src/layout/Footer/index.tsx on lines 53..57

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 59.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

const SecuredByKleros: React.FC = () => (
  <a className="secured-by-kleros" href="https://kleros.io" target="_blank" rel="noreferrer">
    <SecuredByKlerosLogo />
  </a>
);
Severity: Major
Found in web-devtools/src/layout/Footer/index.tsx and 1 other location - About 1 hr to fix
web/src/layout/Footer/index.tsx on lines 52..56

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 59.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

const ring = (duration: string, delay: string) => css`
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
Severity: Major
Found in web/src/components/DottedMenuButton.tsx and 1 other location - About 1 hr to fix
web/src/pages/Cases/CaseDetails/MaintenanceButtons/MenuButton.tsx on lines 22..39

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 59.

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

Further Reading

Function deployForeignGateway has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
  const { deploy, execute } = deployments;
  const { zeroPadValue, toBeHex } = ethers;

Severity: Minor
Found in contracts/deploy/01-foreign-gateway-on-gnosis.ts - About 1 hr to fix

Function Court has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Court: React.FC = () => {
  const { disputeData, setDisputeData } = useNewDisputeContext();
  const { data } = useCourtTree();
  const items = useMemo(() => !isUndefined(data) && [rootCourtToItems(data.court)], [data]);

Severity: Minor
Found in web/src/pages/Resolver/Parameters/Court.tsx - About 1 hr to fix

Function Policy has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Policy: React.FC = () => {
  const { disputeData, setDisputeData, setIsPolicyUploading } = useNewDisputeContext();
  const { uploadFile } = useAtlasProvider();

  const handleFileUpload = (file: File) => {
Severity: Minor
Found in web/src/pages/Resolver/Policy/index.tsx - About 1 hr to fix

Similar blocks of code found in 8 locations. Consider refactoring.
Open

const LinksContainer = styled.div`
  display: flex;
  color: ${({ theme }) => theme.primaryBlue};
  align-items: center;
  gap: 24px;
Severity: Major
Found in web/src/pages/Dashboard/JurorInfo/Header.tsx and 7 other locations - About 1 hr to fix
web-devtools/src/layout/Footer/index.tsx on lines 11..51
web/src/components/DisputePreview/Policies.tsx on lines 32..42
web/src/layout/Footer/index.tsx on lines 10..50
web/src/pages/Home/TopJurors/Header/Coherency.tsx on lines 10..26
web/src/pages/Home/TopJurors/Header/Rewards.tsx on lines 8..28
web/src/pages/Home/TopJurors/JurorCard/Rank.tsx on lines 6..24
web/src/pages/Resolver/Preview/index.tsx on lines 43..53

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 58.

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

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

const StyledP = styled.p`
  font-size: 14px;
  margin-top: 0;
  margin-bottom: 16px;
  color: ${({ theme }) => theme.primaryBlue};
Severity: Major
Found in web/src/components/DisputePreview/Policies.tsx and 7 other locations - About 1 hr to fix
web-devtools/src/layout/Footer/index.tsx on lines 11..51
web/src/layout/Footer/index.tsx on lines 10..50
web/src/pages/Dashboard/JurorInfo/Header.tsx on lines 34..46
web/src/pages/Home/TopJurors/Header/Coherency.tsx on lines 10..26
web/src/pages/Home/TopJurors/Header/Rewards.tsx on lines 8..28
web/src/pages/Home/TopJurors/JurorCard/Rank.tsx on lines 6..24
web/src/pages/Resolver/Preview/index.tsx on lines 43..53

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 58.

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

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

const Header = styled.h2`
  margin-bottom: 32px;
  width: 84vw;
  text-align: center;
  color: ${({ theme }) => theme.secondaryPurple};
Severity: Major
Found in web/src/pages/Resolver/Preview/index.tsx and 7 other locations - About 1 hr to fix
web-devtools/src/layout/Footer/index.tsx on lines 11..51
web/src/components/DisputePreview/Policies.tsx on lines 32..42
web/src/layout/Footer/index.tsx on lines 10..50
web/src/pages/Dashboard/JurorInfo/Header.tsx on lines 34..46
web/src/pages/Home/TopJurors/Header/Coherency.tsx on lines 10..26
web/src/pages/Home/TopJurors/Header/Rewards.tsx on lines 8..28
web/src/pages/Home/TopJurors/JurorCard/Rank.tsx on lines 6..24

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 58.

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

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

const Container = styled.div`
  height: 122px;
  width: 100%;
  background-color: ${({ theme }) => theme.klerosUIComponentsPrimaryPurple};
  display: flex;
Severity: Major
Found in web-devtools/src/layout/Footer/index.tsx and 7 other locations - About 1 hr to fix
web/src/components/DisputePreview/Policies.tsx on lines 32..42
web/src/layout/Footer/index.tsx on lines 10..50
web/src/pages/Dashboard/JurorInfo/Header.tsx on lines 34..46
web/src/pages/Home/TopJurors/Header/Coherency.tsx on lines 10..26
web/src/pages/Home/TopJurors/Header/Rewards.tsx on lines 8..28
web/src/pages/Home/TopJurors/JurorCard/Rank.tsx on lines 6..24
web/src/pages/Resolver/Preview/index.tsx on lines 43..53

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 58.

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

Further Reading

Severity
Category
Status
Source
Language