grommet/grommet

View on GitHub
src/js/components/DateInput/stories/FormatInline.js

Summary

Maintainability
F
4 days
Test Coverage

Function FormatInline has 188 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const FormatInline = () => {
  const [date, setDate] = useState();
  const [emptyDate, setEmptyDate] = useState();
  const [dateRange, setDateRange] = useState();
  const [dateNoTZ, setDateNoTZ] = useState();
Severity: Major
Found in src/js/components/DateInput/stories/FormatInline.js - About 7 hrs to fix

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

          <Box gap="small" align="start">
            <Text weight="bold">
              5) When defaultValue is a range and has no timezone, everything is
              returned without a timezone and is assumed to be local time
            </Text>
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 1 other location - About 6 hrs to fix
    src/js/components/DateInput/stories/FormatInline.js on lines 129..146

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

    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

          <Box gap="small" align="start">
            <Text weight="bold">
              4) When defaultValue is a range and has a timezone, everything stays
              in that timezone
            </Text>
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 1 other location - About 6 hrs to fix
    src/js/components/DateInput/stories/FormatInline.js on lines 147..164

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

    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

          <Box gap="small" align="start">
            <Text weight="bold">
              8) When state has default value w/o TZ, everything is returned without
              a timezone and is assumed to be local time
            </Text>
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 1 other location - About 3 hrs to fix
    src/js/components/DateInput/stories/FormatInline.js on lines 178..191

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

    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

          <Box gap="small" align="start">
            <Text weight="bold">
              7) When state has default value with TZ, everything everything stays
              in that timezone
            </Text>
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 1 other location - About 3 hrs to fix
    src/js/components/DateInput/stories/FormatInline.js on lines 192..205

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

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

      const onChangeRangeNoTZ = (event) => {
        const nextValue = event.value;
        console.log('onChange iso date:', nextValue);
        console.log('onChange utc date:', new Date(nextValue));
        setDateRangeNoTZ(nextValue);
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 10 other locations - About 1 hr to fix
    src/js/components/DateInput/stories/Format.js on lines 7..12
    src/js/components/DateInput/stories/FormatInline.js on lines 20..25
    src/js/components/DateInput/stories/FormatInline.js on lines 27..32
    src/js/components/DateInput/stories/FormatInline.js on lines 34..39
    src/js/components/DateInput/stories/FormatInline.js on lines 41..46
    src/js/components/DateInput/stories/FormatInline.js on lines 55..60
    src/js/components/DateInput/stories/FormatInline.js on lines 62..67
    src/js/components/DateInput/stories/FormatInline.js on lines 69..74
    src/js/components/DateInput/stories/Inline.js on lines 7..12
    src/js/components/DateInput/stories/Simple.js on lines 7..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 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 11 locations. Consider refactoring.
    Open

      const onChangeStateDefault = (event) => {
        const nextValue = event.value;
        console.log('onChange iso date:', nextValue);
        console.log('onChange utc date:', new Date(nextValue));
        setDateStateDefault(nextValue);
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 10 other locations - About 1 hr to fix
    src/js/components/DateInput/stories/Format.js on lines 7..12
    src/js/components/DateInput/stories/FormatInline.js on lines 20..25
    src/js/components/DateInput/stories/FormatInline.js on lines 27..32
    src/js/components/DateInput/stories/FormatInline.js on lines 34..39
    src/js/components/DateInput/stories/FormatInline.js on lines 41..46
    src/js/components/DateInput/stories/FormatInline.js on lines 48..53
    src/js/components/DateInput/stories/FormatInline.js on lines 55..60
    src/js/components/DateInput/stories/FormatInline.js on lines 69..74
    src/js/components/DateInput/stories/Inline.js on lines 7..12
    src/js/components/DateInput/stories/Simple.js on lines 7..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 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 11 locations. Consider refactoring.
    Open

      const onChangeStateDefaultNoTZ = (event) => {
        const nextValue = event.value;
        console.log('onChange iso date:', nextValue);
        console.log('onChange utc date:', new Date(nextValue));
        setDateStateDefaultNoTZ(nextValue);
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 10 other locations - About 1 hr to fix
    src/js/components/DateInput/stories/Format.js on lines 7..12
    src/js/components/DateInput/stories/FormatInline.js on lines 20..25
    src/js/components/DateInput/stories/FormatInline.js on lines 27..32
    src/js/components/DateInput/stories/FormatInline.js on lines 34..39
    src/js/components/DateInput/stories/FormatInline.js on lines 41..46
    src/js/components/DateInput/stories/FormatInline.js on lines 48..53
    src/js/components/DateInput/stories/FormatInline.js on lines 55..60
    src/js/components/DateInput/stories/FormatInline.js on lines 62..67
    src/js/components/DateInput/stories/Inline.js on lines 7..12
    src/js/components/DateInput/stories/Simple.js on lines 7..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 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 11 locations. Consider refactoring.
    Open

      const onChangeTZ = (event) => {
        const nextValue = event.value;
        console.log('onChange iso date:', nextValue);
        console.log('onChange utc date:', new Date(nextValue));
        setDate(nextValue);
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 10 other locations - About 1 hr to fix
    src/js/components/DateInput/stories/Format.js on lines 7..12
    src/js/components/DateInput/stories/FormatInline.js on lines 20..25
    src/js/components/DateInput/stories/FormatInline.js on lines 34..39
    src/js/components/DateInput/stories/FormatInline.js on lines 41..46
    src/js/components/DateInput/stories/FormatInline.js on lines 48..53
    src/js/components/DateInput/stories/FormatInline.js on lines 55..60
    src/js/components/DateInput/stories/FormatInline.js on lines 62..67
    src/js/components/DateInput/stories/FormatInline.js on lines 69..74
    src/js/components/DateInput/stories/Inline.js on lines 7..12
    src/js/components/DateInput/stories/Simple.js on lines 7..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 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 11 locations. Consider refactoring.
    Open

      const onChangeRange = (event) => {
        const nextValue = event.value;
        console.log('onChange iso date:', nextValue);
        console.log('onChange utc date:', new Date(nextValue));
        setDateRange(nextValue);
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 10 other locations - About 1 hr to fix
    src/js/components/DateInput/stories/Format.js on lines 7..12
    src/js/components/DateInput/stories/FormatInline.js on lines 20..25
    src/js/components/DateInput/stories/FormatInline.js on lines 27..32
    src/js/components/DateInput/stories/FormatInline.js on lines 34..39
    src/js/components/DateInput/stories/FormatInline.js on lines 48..53
    src/js/components/DateInput/stories/FormatInline.js on lines 55..60
    src/js/components/DateInput/stories/FormatInline.js on lines 62..67
    src/js/components/DateInput/stories/FormatInline.js on lines 69..74
    src/js/components/DateInput/stories/Inline.js on lines 7..12
    src/js/components/DateInput/stories/Simple.js on lines 7..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 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 11 locations. Consider refactoring.
    Open

      const onChangeEmpty = (event) => {
        const nextValue = event.value;
        console.log('onChange iso date:', nextValue);
        console.log('onChange utc date:', new Date(nextValue));
        setEmptyDate(nextValue);
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 10 other locations - About 1 hr to fix
    src/js/components/DateInput/stories/Format.js on lines 7..12
    src/js/components/DateInput/stories/FormatInline.js on lines 27..32
    src/js/components/DateInput/stories/FormatInline.js on lines 34..39
    src/js/components/DateInput/stories/FormatInline.js on lines 41..46
    src/js/components/DateInput/stories/FormatInline.js on lines 48..53
    src/js/components/DateInput/stories/FormatInline.js on lines 55..60
    src/js/components/DateInput/stories/FormatInline.js on lines 62..67
    src/js/components/DateInput/stories/FormatInline.js on lines 69..74
    src/js/components/DateInput/stories/Inline.js on lines 7..12
    src/js/components/DateInput/stories/Simple.js on lines 7..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 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 11 locations. Consider refactoring.
    Open

      const onChangeNoTZ = (event) => {
        const nextValue = event.value;
        console.log('onChange iso date:', nextValue);
        console.log('onChange utc date:', new Date(nextValue));
        setDateNoTZ(nextValue);
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 10 other locations - About 1 hr to fix
    src/js/components/DateInput/stories/Format.js on lines 7..12
    src/js/components/DateInput/stories/FormatInline.js on lines 20..25
    src/js/components/DateInput/stories/FormatInline.js on lines 27..32
    src/js/components/DateInput/stories/FormatInline.js on lines 41..46
    src/js/components/DateInput/stories/FormatInline.js on lines 48..53
    src/js/components/DateInput/stories/FormatInline.js on lines 55..60
    src/js/components/DateInput/stories/FormatInline.js on lines 62..67
    src/js/components/DateInput/stories/FormatInline.js on lines 69..74
    src/js/components/DateInput/stories/Inline.js on lines 7..12
    src/js/components/DateInput/stories/Simple.js on lines 7..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 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 11 locations. Consider refactoring.
    Open

      const onChangeNoDefault = (event) => {
        const nextValue = event.value;
        console.log('onChange iso date:', nextValue);
        console.log('onChange utc date:', new Date(nextValue));
        setDateNoDefault(nextValue);
    Severity: Major
    Found in src/js/components/DateInput/stories/FormatInline.js and 10 other locations - About 1 hr to fix
    src/js/components/DateInput/stories/Format.js on lines 7..12
    src/js/components/DateInput/stories/FormatInline.js on lines 20..25
    src/js/components/DateInput/stories/FormatInline.js on lines 27..32
    src/js/components/DateInput/stories/FormatInline.js on lines 34..39
    src/js/components/DateInput/stories/FormatInline.js on lines 41..46
    src/js/components/DateInput/stories/FormatInline.js on lines 48..53
    src/js/components/DateInput/stories/FormatInline.js on lines 62..67
    src/js/components/DateInput/stories/FormatInline.js on lines 69..74
    src/js/components/DateInput/stories/Inline.js on lines 7..12
    src/js/components/DateInput/stories/Simple.js on lines 7..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 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

    There are no issues that match your filters.

    Category
    Status