torvalds/linux

View on GitHub
tools/testing/selftests/damon/_damon_sysfs.py

Summary

Maintainability
F
4 days
Test Coverage

File _damon_sysfs.py has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# SPDX-License-Identifier: GPL-2.0

import os

sysfs_root = '/sys/kernel/mm/damon/admin'
Severity: Minor
Found in tools/testing/selftests/damon/_damon_sysfs.py - About 3 hrs to fix

    Function stage has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def stage(self):
            err = write_file(
                    os.path.join(self.sysfs_dir(), 'operations'), self.ops)
            if err != None:
                return err
    Severity: Minor
    Found in tools/testing/selftests/damon/_damon_sysfs.py - 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 update_schemes_stats has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_schemes_stats(self):
            err = write_file(os.path.join(self.sysfs_dir(), 'state'),
                    'update_schemes_stats')
            if err != None:
                return err
    Severity: Minor
    Found in tools/testing/selftests/damon/_damon_sysfs.py - 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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, sample_us=5000, aggr_us=100000, update_us=1000000,
    Severity: Minor
    Found in tools/testing/selftests/damon/_damon_sysfs.py - About 35 mins to fix

      Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, nr_tried, sz_tried, nr_applied, sz_applied, qt_exceeds):
      Severity: Minor
      Found in tools/testing/selftests/damon/_damon_sysfs.py - About 35 mins to fix

        Function update_schemes_tried_bytes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_schemes_tried_bytes(self):
                err = write_file(os.path.join(self.sysfs_dir(), 'state'),
                        'update_schemes_tried_bytes')
                if err != None:
                    return err
        Severity: Minor
        Found in tools/testing/selftests/damon/_damon_sysfs.py - About 35 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

        Function start has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def start(self):
                nr_contexts_file = os.path.join(self.sysfs_dir(),
                        'contexts', 'nr_contexts')
                content, err = read_file(nr_contexts_file)
                if err != None:
        Severity: Minor
        Found in tools/testing/selftests/damon/_damon_sysfs.py - About 35 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

        Avoid too many return statements within this function.
        Open

                    return err
        Severity: Major
        Found in tools/testing/selftests/damon/_damon_sysfs.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return err
          Severity: Major
          Found in tools/testing/selftests/damon/_damon_sysfs.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return err
            Severity: Major
            Found in tools/testing/selftests/damon/_damon_sysfs.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return err
              Severity: Major
              Found in tools/testing/selftests/damon/_damon_sysfs.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return err
                Severity: Major
                Found in tools/testing/selftests/damon/_damon_sysfs.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return err
                  Severity: Major
                  Found in tools/testing/selftests/damon/_damon_sysfs.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return None
                    Severity: Major
                    Found in tools/testing/selftests/damon/_damon_sysfs.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return err
                      Severity: Major
                      Found in tools/testing/selftests/damon/_damon_sysfs.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                        return err
                        Severity: Major
                        Found in tools/testing/selftests/damon/_damon_sysfs.py - About 30 mins to fix

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

                              def stage(self):
                                  err = write_file(
                                          os.path.join(self.sysfs_dir(), 'sz', 'min'), self.size[0])
                                  if err != None:
                                      return err
                          Severity: Minor
                          Found in tools/testing/selftests/damon/_damon_sysfs.py - 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

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

                              def stage(self):
                                  err = write_file(os.path.join(self.sysfs_dir(), 'action'), self.action)
                                  if err != None:
                                      return err
                                  err = self.access_pattern.stage()
                          Severity: Minor
                          Found in tools/testing/selftests/damon/_damon_sysfs.py - 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 3 locations. Consider refactoring.
                          Open

                                  if int(content) != len(self.contexts):
                                      err = write_file(nr_contexts_file, '%d' % len(self.contexts))
                                      if err != None:
                                          return err
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 2 other locations - About 2 hrs to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 278..281
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 290..293

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

                          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 int(content) != len(self.targets):
                                      err = write_file(nr_targets_file, '%d' % len(self.targets))
                                      if err != None:
                                          return err
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 2 other locations - About 2 hrs to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 290..293
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 322..325

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

                          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 int(content) != len(self.schemes):
                                      err = write_file(nr_schemes_file, '%d' % len(self.schemes))
                                      if err != None:
                                          return err
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 2 other locations - About 2 hrs to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 278..281
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 322..325

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

                          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

                              def __init__(self, contexts=[]):
                                  self.contexts = contexts
                                  for idx, context in enumerate(self.contexts):
                                      context.idx = idx
                                      context.kdamond = self
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 1 other location - About 1 hr to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 367..371

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

                          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

                              def __init__(self, kdamonds=[]):
                                  self.kdamonds = kdamonds
                                  for idx, kdamond in enumerate(self.kdamonds):
                                      kdamond.idx = idx
                                      kdamond.kdamonds = self
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 1 other location - About 1 hr to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 307..311

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

                          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

                              def __init__(self, sample_us=5000, aggr_us=100000, update_us=1000000,
                                      min_nr_regions=10, max_nr_regions=1000):
                                  self.sample_us = sample_us
                                  self.aggr_us = aggr_us
                                  self.update_us = update_us
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 2 other locations - About 50 mins to fix
                          tools/perf/scripts/python/task-analyzer.py on lines 316..321
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 106..111

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

                          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

                              def __init__(self, nr_tried, sz_tried, nr_applied, sz_applied, qt_exceeds):
                                  self.nr_tried = nr_tried
                                  self.sz_tried = sz_tried
                                  self.nr_applied = nr_applied
                                  self.sz_applied = sz_applied
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 2 other locations - About 50 mins to fix
                          tools/perf/scripts/python/task-analyzer.py on lines 316..321
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 194..200

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

                          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 self.age == None:
                                      self.age = [0, 2**64 - 1]
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 2 other locations - About 40 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 37..38
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 39..40

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

                          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 self.nr_accesses == None:
                                      self.nr_accesses = [0, 2**64 - 1]
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 2 other locations - About 40 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 37..38
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 41..42

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

                          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 self.size == None:
                                      self.size = [0, 2**64 - 1]
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 2 other locations - About 40 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 39..40
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 41..42

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

                          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

                              def sysfs_dir(self):
                                  return os.path.join(self.kdamond.sysfs_dir(), 'contexts',
                                          '%d' % self.idx)
                          Severity: Minor
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 2 other locations - About 35 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 133..135
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 174..176

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

                          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

                              def sysfs_dir(self):
                                  return os.path.join(
                                          self.context.sysfs_dir(), 'schemes', '%d' % self.idx)
                          Severity: Minor
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 2 other locations - About 35 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 174..176
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 260..262

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

                          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

                              def sysfs_dir(self):
                                  return os.path.join(
                                          self.context.sysfs_dir(), 'targets', '%d' % self.idx)
                          Severity: Minor
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 2 other locations - About 35 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 133..135
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 260..262

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

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

                                  err = write_file(
                                          os.path.join(self.sysfs_dir(), 'sz', 'max'), self.size[1])
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 5 other locations - About 30 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 48..49
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 56..57
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 60..61
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 64..65
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 68..69

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

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

                                  err = write_file(
                                          os.path.join(self.sysfs_dir(), 'age', 'min'), self.age[0])
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 5 other locations - About 30 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 48..49
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 52..53
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 56..57
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 60..61
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 68..69

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

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

                                  err = write_file(os.path.join(self.sysfs_dir(), 'nr_accesses', 'min'),
                                          self.nr_accesses[0])
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 5 other locations - About 30 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 48..49
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 52..53
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 60..61
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 64..65
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 68..69

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

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

                                  err = write_file(
                                          os.path.join(self.sysfs_dir(), 'sz', 'min'), self.size[0])
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 5 other locations - About 30 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 52..53
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 56..57
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 60..61
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 64..65
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 68..69

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

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

                                  err = write_file(
                                          os.path.join(self.sysfs_dir(), 'age', 'max'), self.age[1])
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 5 other locations - About 30 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 48..49
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 52..53
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 56..57
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 60..61
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 64..65

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

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

                                  err = write_file(os.path.join(self.sysfs_dir(), 'nr_accesses', 'max'),
                                          self.nr_accesses[1])
                          Severity: Major
                          Found in tools/testing/selftests/damon/_damon_sysfs.py and 5 other locations - About 30 mins to fix
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 48..49
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 52..53
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 56..57
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 64..65
                          tools/testing/selftests/damon/_damon_sysfs.py on lines 68..69

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

                          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