wikimedia/pywikibot

View on GitHub

Showing 737 of 737 total issues

Avoid too many return statements within this function.
Open

        return True
Severity: Major
Found in pywikibot/site/_apisite.py - About 30 mins to fix

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

        def redirectpages(
            self,
            total: int | None = None,
        ) -> Iterable[pywikibot.Page]:
            """Yield redirect pages from Special:ListRedirects.
    Severity: Major
    Found in pywikibot/site/_generators.py and 16 other locations - About 30 mins to fix
    pywikibot/site/_generators.py on lines 2098..2106
    pywikibot/site/_generators.py on lines 2123..2131
    pywikibot/site/_generators.py on lines 2133..2141
    pywikibot/site/_generators.py on lines 2143..2151
    pywikibot/site/_generators.py on lines 2153..2161
    pywikibot/site/_generators.py on lines 2163..2171
    pywikibot/site/_generators.py on lines 2173..2181
    pywikibot/site/_generators.py on lines 2183..2191
    pywikibot/site/_generators.py on lines 2193..2201
    pywikibot/site/_generators.py on lines 2206..2214
    pywikibot/site/_generators.py on lines 2216..2224
    pywikibot/site/_generators.py on lines 2226..2234
    pywikibot/site/_generators.py on lines 2236..2244
    pywikibot/site/_generators.py on lines 2246..2254
    pywikibot/site/_generators.py on lines 2256..2264
    pywikibot/site/_generators.py on lines 2266..2274

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

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

        def unwatchedpages(
            self,
            total: int | None = None,
        ) -> Iterable[pywikibot.Page]:
            """Yield Pages from Special:Unwatchedpages (requires Admin privileges).
    Severity: Major
    Found in pywikibot/site/_generators.py and 16 other locations - About 30 mins to fix
    pywikibot/site/_generators.py on lines 2098..2106
    pywikibot/site/_generators.py on lines 2123..2131
    pywikibot/site/_generators.py on lines 2143..2151
    pywikibot/site/_generators.py on lines 2153..2161
    pywikibot/site/_generators.py on lines 2163..2171
    pywikibot/site/_generators.py on lines 2173..2181
    pywikibot/site/_generators.py on lines 2183..2191
    pywikibot/site/_generators.py on lines 2193..2201
    pywikibot/site/_generators.py on lines 2206..2214
    pywikibot/site/_generators.py on lines 2216..2224
    pywikibot/site/_generators.py on lines 2226..2234
    pywikibot/site/_generators.py on lines 2236..2244
    pywikibot/site/_generators.py on lines 2246..2254
    pywikibot/site/_generators.py on lines 2256..2264
    pywikibot/site/_generators.py on lines 2266..2274
    pywikibot/site/_generators.py on lines 2276..2284

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

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

        def broken_redirects(
            self,
            total: int | None = None,
        ) -> Iterable[pywikibot.Page]:
            """Yield Pages with broken redirects from Special:BrokenRedirects.
    Severity: Major
    Found in pywikibot/site/_generators.py and 16 other locations - About 30 mins to fix
    pywikibot/site/_generators.py on lines 2098..2106
    pywikibot/site/_generators.py on lines 2123..2131
    pywikibot/site/_generators.py on lines 2133..2141
    pywikibot/site/_generators.py on lines 2143..2151
    pywikibot/site/_generators.py on lines 2153..2161
    pywikibot/site/_generators.py on lines 2163..2171
    pywikibot/site/_generators.py on lines 2173..2181
    pywikibot/site/_generators.py on lines 2183..2191
    pywikibot/site/_generators.py on lines 2193..2201
    pywikibot/site/_generators.py on lines 2206..2214
    pywikibot/site/_generators.py on lines 2216..2224
    pywikibot/site/_generators.py on lines 2226..2234
    pywikibot/site/_generators.py on lines 2236..2244
    pywikibot/site/_generators.py on lines 2246..2254
    pywikibot/site/_generators.py on lines 2266..2274
    pywikibot/site/_generators.py on lines 2276..2284

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

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

        def uncategorizedcategories(
            self,
            total: int | None = None,
        ) -> Iterable[pywikibot.Page]:
            """Yield Categories from Special:Uncategorizedcategories.
    Severity: Major
    Found in pywikibot/site/_generators.py and 16 other locations - About 30 mins to fix
    pywikibot/site/_generators.py on lines 2098..2106
    pywikibot/site/_generators.py on lines 2123..2131
    pywikibot/site/_generators.py on lines 2133..2141
    pywikibot/site/_generators.py on lines 2143..2151
    pywikibot/site/_generators.py on lines 2153..2161
    pywikibot/site/_generators.py on lines 2163..2171
    pywikibot/site/_generators.py on lines 2173..2181
    pywikibot/site/_generators.py on lines 2193..2201
    pywikibot/site/_generators.py on lines 2206..2214
    pywikibot/site/_generators.py on lines 2216..2224
    pywikibot/site/_generators.py on lines 2226..2234
    pywikibot/site/_generators.py on lines 2236..2244
    pywikibot/site/_generators.py on lines 2246..2254
    pywikibot/site/_generators.py on lines 2256..2264
    pywikibot/site/_generators.py on lines 2266..2274
    pywikibot/site/_generators.py on lines 2276..2284

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

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

        def double_redirects(
            self,
            total: int | None = None,
        ) -> Iterable[pywikibot.Page]:
            """Yield Pages with double redirects from Special:DoubleRedirects.
    Severity: Major
    Found in pywikibot/site/_generators.py and 16 other locations - About 30 mins to fix
    pywikibot/site/_generators.py on lines 2098..2106
    pywikibot/site/_generators.py on lines 2123..2131
    pywikibot/site/_generators.py on lines 2133..2141
    pywikibot/site/_generators.py on lines 2143..2151
    pywikibot/site/_generators.py on lines 2153..2161
    pywikibot/site/_generators.py on lines 2163..2171
    pywikibot/site/_generators.py on lines 2173..2181
    pywikibot/site/_generators.py on lines 2183..2191
    pywikibot/site/_generators.py on lines 2193..2201
    pywikibot/site/_generators.py on lines 2206..2214
    pywikibot/site/_generators.py on lines 2216..2224
    pywikibot/site/_generators.py on lines 2226..2234
    pywikibot/site/_generators.py on lines 2236..2244
    pywikibot/site/_generators.py on lines 2246..2254
    pywikibot/site/_generators.py on lines 2256..2264
    pywikibot/site/_generators.py on lines 2276..2284

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

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

        def withoutinterwiki(
            self,
            total: int | None = None,
        ) -> Iterable[pywikibot.Page]:
            """Yield Pages without language links from Special:Withoutinterwiki.
    Severity: Major
    Found in pywikibot/site/_generators.py and 16 other locations - About 30 mins to fix
    pywikibot/site/_generators.py on lines 2098..2106
    pywikibot/site/_generators.py on lines 2123..2131
    pywikibot/site/_generators.py on lines 2133..2141
    pywikibot/site/_generators.py on lines 2143..2151
    pywikibot/site/_generators.py on lines 2153..2161
    pywikibot/site/_generators.py on lines 2163..2171
    pywikibot/site/_generators.py on lines 2173..2181
    pywikibot/site/_generators.py on lines 2183..2191
    pywikibot/site/_generators.py on lines 2193..2201
    pywikibot/site/_generators.py on lines 2206..2214
    pywikibot/site/_generators.py on lines 2216..2224
    pywikibot/site/_generators.py on lines 2226..2234
    pywikibot/site/_generators.py on lines 2236..2244
    pywikibot/site/_generators.py on lines 2256..2264
    pywikibot/site/_generators.py on lines 2266..2274
    pywikibot/site/_generators.py on lines 2276..2284

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

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

        def wantedtemplates(
            self,
            total: int | None = None,
        ) -> Iterable[pywikibot.Page]:
            """Yield Pages from Special:Wantedtemplates.
    Severity: Major
    Found in pywikibot/site/_generators.py and 16 other locations - About 30 mins to fix
    pywikibot/site/_generators.py on lines 2098..2106
    pywikibot/site/_generators.py on lines 2123..2131
    pywikibot/site/_generators.py on lines 2133..2141
    pywikibot/site/_generators.py on lines 2143..2151
    pywikibot/site/_generators.py on lines 2153..2161
    pywikibot/site/_generators.py on lines 2173..2181
    pywikibot/site/_generators.py on lines 2183..2191
    pywikibot/site/_generators.py on lines 2193..2201
    pywikibot/site/_generators.py on lines 2206..2214
    pywikibot/site/_generators.py on lines 2216..2224
    pywikibot/site/_generators.py on lines 2226..2234
    pywikibot/site/_generators.py on lines 2236..2244
    pywikibot/site/_generators.py on lines 2246..2254
    pywikibot/site/_generators.py on lines 2256..2264
    pywikibot/site/_generators.py on lines 2266..2274
    pywikibot/site/_generators.py on lines 2276..2284

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

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

        def wantedcategories(
            self,
            total: int | None = None,
        ) -> Iterable[pywikibot.Page]:
            """Yield Pages from Special:Wantedcategories.
    Severity: Major
    Found in pywikibot/site/_generators.py and 16 other locations - About 30 mins to fix
    pywikibot/site/_generators.py on lines 2098..2106
    pywikibot/site/_generators.py on lines 2123..2131
    pywikibot/site/_generators.py on lines 2133..2141
    pywikibot/site/_generators.py on lines 2143..2151
    pywikibot/site/_generators.py on lines 2153..2161
    pywikibot/site/_generators.py on lines 2163..2171
    pywikibot/site/_generators.py on lines 2183..2191
    pywikibot/site/_generators.py on lines 2193..2201
    pywikibot/site/_generators.py on lines 2206..2214
    pywikibot/site/_generators.py on lines 2216..2224
    pywikibot/site/_generators.py on lines 2226..2234
    pywikibot/site/_generators.py on lines 2236..2244
    pywikibot/site/_generators.py on lines 2246..2254
    pywikibot/site/_generators.py on lines 2256..2264
    pywikibot/site/_generators.py on lines 2266..2274
    pywikibot/site/_generators.py on lines 2276..2284

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

    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

            data.found_in[self.pages['pl']] = [self.pages['en'], self.pages['fr']]
    Severity: Minor
    Found in tests/interwiki_graph_tests.py and 2 other locations - About 30 mins to fix
    tests/interwiki_graph_tests.py on lines 55..55
    tests/interwiki_graph_tests.py on lines 56..56

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 40.

    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

            with self.assertRaisesRegex(
                    ValidationError,
                    '|'.join((self.ISBN_DIGITERROR_RE,
                              self.ISBN_INVALIDERROR_RE,
                              self.ISBN_INVALIDLENGTHERROR_RE))):
    Severity: Minor
    Found in tests/cosmetic_changes_tests.py and 2 other locations - About 30 mins to fix
    tests/cosmetic_changes_tests.py on lines 583..588
    tests/cosmetic_changes_tests.py on lines 605..610

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

    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

            data.found_in[self.pages['fr']] = [self.pages['en'], self.pages['pl']]
    Severity: Minor
    Found in tests/interwiki_graph_tests.py and 2 other locations - About 30 mins to fix
    tests/interwiki_graph_tests.py on lines 55..55
    tests/interwiki_graph_tests.py on lines 57..57

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 40.

    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

            with self.assertRaisesRegex(
                ValidationError,
                '|'.join((self.ISBN_INVALIDCHARERROR_RE,
                          self.ISBN_INVALIDERROR_RE,
                          self.ISBN_INVALIDLENGTHERROR_RE))):
    Severity: Minor
    Found in tests/cosmetic_changes_tests.py and 2 other locations - About 30 mins to fix
    tests/cosmetic_changes_tests.py on lines 583..588
    tests/cosmetic_changes_tests.py on lines 598..603

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

    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

            data.found_in[self.pages['en']] = [self.pages['fr'], self.pages['pl']]
    Severity: Minor
    Found in tests/interwiki_graph_tests.py and 2 other locations - About 30 mins to fix
    tests/interwiki_graph_tests.py on lines 56..56
    tests/interwiki_graph_tests.py on lines 57..57

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 40.

    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

            with self.assertRaisesRegex(
                    ValidationError,
                    '|'.join((self.ISBN_DIGITERROR_RE,
                              self.ISBN_INVALIDERROR_RE,
                              self.ISBN_INVALIDLENGTHERROR_RE))):
    Severity: Minor
    Found in tests/cosmetic_changes_tests.py and 2 other locations - About 30 mins to fix
    tests/cosmetic_changes_tests.py on lines 598..603
    tests/cosmetic_changes_tests.py on lines 605..610

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

    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 get_target has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
    Open

        def get_target(self, page):
            """Get the target page for a given page."""
            target = None
            if not page.exists():
                if not self.opt.ignoremoves:
    Severity: Minor
    Found in scripts/fixing_redirects.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 main has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
    Open

    def main(*args: str) -> None:
        """Process command line arguments and invoke ParserFunctionCountBot."""
        local_args = pywikibot.handle_args(*args)
        options = {}
    
    
    Severity: Minor
    Found in scripts/parser_function_count.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 test_pages_with_property_generator has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
    Open

        def test_pages_with_property_generator(self):
            """Test the pages_with_property_generator method."""
            mysite = self.get_site()
            for item in ('defaultsort', 'disambiguation', 'displaytitle',
                         'hiddencat', 'invalid_property'):
    Severity: Minor
    Found in tests/pagegenerators_tests.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 main has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
    Open

    def main(*args: str) -> None:
        """
        Process command line arguments and invoke bot.
    
        If args is an empty list, sys.argv is used.
    Severity: Minor
    Found in scripts/cosmetic_changes.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 main has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
    Open

    def main(*args: str) -> None:
        """
        Process command line arguments and invoke bot.
    
        If args is an empty list, sys.argv is used.
    Severity: Minor
    Found in scripts/category_redirect.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

    Severity
    Category
    Status
    Source
    Language