LivInTheLookingGlass/ManifoldMarketManager

View on GitHub

Showing 34 of 39 total issues

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

        ret = f"{'  ' * indent}- Resolves based on GitHub PR {self.owner}/{self.repo}#{self.number}\n"
Severity: Minor
Found in ManifoldMarketManager/rule/github.py and 1 other location - About 40 mins to fix
ManifoldMarketManager/rule/github.py on lines 126..126

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

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

        ret = f"{'  ' * indent}- Resolves based on GitHub PR {self.owner}/{self.repo}#{self.number}\n"
Severity: Minor
Found in ManifoldMarketManager/rule/github.py and 1 other location - About 40 mins to fix
ManifoldMarketManager/rule/github.py on lines 96..96

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

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

def date_deserialization_hook(json_dict):
    """JSON deserializer for datetime objects."""
    for key, value in json_dict.items():
        if isinstance(value, str):
            if match(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$', value):
Severity: Minor
Found in example_json.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 __post_init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def __post_init__(self):
        if not self.manifold.description.get("processed"):
            explanation = "\n" + explain_abstract(
                time_rules=self.time_rules, value_rules=self.value_rules
            )
Severity: Minor
Found in example_json.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 from_env has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def from_env() -> 'Account':
        """Try to infer an account from environment variables."""
        kwargs = {}
        for f in fields(Account):
            if f.init:
Severity: Minor
Found in ManifoldMarketManager/account.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 resolve has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def resolve(self, override: Optional[AnyResolution] = None) -> Response:
        """Resolve this market according to our resolution rules.

        Returns
        -------
Severity: Minor
Found in ManifoldMarketManager/market.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 _binary_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _binary_value(self, market: Market, mkt: APIMarket | None = None) -> float:
        if mkt is None:
            mkt = self.api_market(market=market)

        if mkt.resolution == "YES":
Severity: Minor
Found in ManifoldMarketManager/rule/manifold/other.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

Use $((..)) for arithmetics, e.g. i=$((i - 2))
Open

            min=min-1
Severity: Minor
Found in daemon.sh by shellcheck

Use $((..)) for arithmetics, e.g. i=$((i - 2))
Open

                sec=sec-1
Severity: Minor
Found in daemon.sh by shellcheck

Use $((..)) for arithmetics, e.g. i=$((i - 2))
Open

        hour=hour-1
Severity: Minor
Found in daemon.sh by shellcheck

TODO found
Open

    # TODO: turn this into an event queue instead
Severity: Minor
Found in ManifoldMarketManager/application.py by fixme

TODO found
Open

2. (TODO) Unless flagged otherwise, for each market in `pending`:
Severity: Minor
Found in README.md by fixme

TODO found
Open

1. (TODO) If flagged, scan a JSON file
Severity: Minor
Found in README.md by fixme

TODO found
Open

    # TODO: add templates here
Severity: Minor
Found in ManifoldMarketManager/application.py by fixme
Severity
Category
Status
Source
Language