grommet/grommet-ferret

View on GitHub
src/js/components/image/ImageIndex.js

Summary

Maintainability
D
2 days
Test Coverage

Function render has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render () {
    const { index, role, uploads } = this.props;
    const { searchText } = this.state;
    const result = index.result || {};

Severity: Major
Found in src/js/components/image/ImageIndex.js - About 2 hrs to fix

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

      componentWillReceiveProps (nextProps) {
        // if any uploads have finished, refresh to pick up notifications
        for (let i=0; i<nextProps.uploads.length; i++) {
          let upload = nextProps.uploads[i];
          if ('Uploaded' === upload.state) {
    Severity: Minor
    Found in src/js/components/image/ImageIndex.js - 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

    Function render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      render () {
        const { index, role, uploads } = this.props;
        const { searchText } = this.state;
        const result = index.result || {};
    
    
    Severity: Minor
    Found in src/js/components/image/ImageIndex.js - About 25 mins 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 2 locations. Consider refactoring.
    Open

            <Header size='large' pad={{ horizontal: 'medium' }}>
              <Title responsive={false}>
                <NavControl />
                <span>Images</span>
              </Title>
    Severity: Major
    Found in src/js/components/image/ImageIndex.js and 1 other location - About 4 hrs to fix
    src/js/components/size/SizeIndex.js on lines 83..91

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

    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

        if (result.items) {
          items = result.items.map((item, index) => (
            <ImageListItem key={item.uri} item={item} index={index} />
          ));
          if (result.count > 0 && result.count < result.total) {
    Severity: Major
    Found in src/js/components/image/ImageIndex.js and 1 other location - About 3 hrs to fix
    src/js/components/size/SizeIndex.js on lines 72..79

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

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

            <ListPlaceholder filteredTotal={result.total}
              unfilteredTotal={result.unfilteredTotal}
              emptyMessage='You do not have any images at the moment.'
              addControl={
                <Button icon={<AddIcon />} label='Add image'
    Severity: Major
    Found in src/js/components/image/ImageIndex.js and 2 other locations - About 2 hrs to fix
    src/js/components/size/SizeIndex.js on lines 96..103
    src/js/components/virtualMachine/VirtualMachineIndex.js on lines 222..229

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

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

      _onSearch (event) {
        const { index } = this.props;
        const searchText = event.target.value;
        this.setState({ searchText });
        const query = new Query(searchText);
    Severity: Major
    Found in src/js/components/image/ImageIndex.js and 3 other locations - About 2 hrs to fix
    src/js/components/activity/ActivityIndex.js on lines 64..70
    src/js/components/size/SizeIndex.js on lines 40..46
    src/js/components/virtualMachine/VirtualMachineIndex.js on lines 82..88

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

    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

      constructor () {
        super();
        this._onSearch = this._onSearch.bind(this);
        this._onMore = this._onMore.bind(this);
        this.state = { searchText: '' };
    Severity: Major
    Found in src/js/components/image/ImageIndex.js and 1 other location - About 2 hrs to fix
    src/js/components/size/SizeIndex.js on lines 23..28

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

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

        if ('read only' !== role) {
          addControl = (
            <Anchor icon={<AddIcon />} path='/images/add' a11yTitle={`Add image`} />
          );
        }
    Severity: Major
    Found in src/js/components/image/ImageIndex.js and 2 other locations - About 55 mins to fix
    src/js/components/size/SizeIndex.js on lines 59..64
    src/js/components/virtualMachine/VirtualMachineIndex.js on lines 180..185

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

    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