coala / coala-bears

Bears for coala
https://coala.io/
GNU Affero General Public License v3.0
295 stars 580 forks source link

Remove use of generic coverage pragma: no cover #1618

Open jayvdb opened 7 years ago

jayvdb commented 7 years ago

# pragma: no cover avoids the requirement to test code. It should be used extremely sparingly, and even when used for expediency, follow up patches should remove them.

$ git grep pragma
bears/__init__.py:def assert_supported_version():  # pragma: no cover
bears/__init__.py:    except ImportError:  # pragma: no cover
bears/c_languages/ClangBear.py:    except LibclangError as error:  # pragma: no cover
bears/c_languages/codeclone_detection/ClangCountingConditions.py:    return FOR_POSITION.UNKNOWN  # pragma: no cover
bears/c_languages/codeclone_detection/ClangCountingConditions.py:    return None  # pragma: no cover
bears/c_languages/codeclone_detection/ClangCountingConditions.py:            if operator is None:  # pragma: no cover
bears/elm/ElmLintBear.py:    def check_prerequisites(cls):  # pragma: no cover
bears/general/CPDBear.py:    def check_prerequisites(cls):  # pragma: no cover
bears/general/CPDBear.py:        if language not in self.lowered_lang_dict:  # pragma: no cover
bears/general/IndentationBear.py:    BEAR_DEPS = {AnnotationBear}  # pragma: no cover
bears/generate_package.py:if __name__ == '__main__':  # pragma: no cover
bears/java/JavaPMDBear.py:    def check_prerequisites(cls):  # pragma: no cover
bears/natural_language/AlexBear.py:        if parent_prereqs is not True:  # pragma: no cover
bears/natural_language/LanguageToolBear.py:            except ImportError:  # pragma: no cover
bears/python/requirements/PySafetyBear.py:            line_number, line = next(  # pragma: no branch
bears/vcs/git/GitCommitBear.py:        except LookupError as error:  # pragma: no cover
bears/vhdl/VHDLLintBear.py:    def check_prerequisites(cls):  # pragma: no cover

A lot of them seem to be in the check_prerequisites stage.

When doing this task , take only one bear and create a separate issue for it, linking back to this issue.

jayvdb commented 7 years ago

All of the # pragma: no cover in checking pre-requisites should be fixed by declaring requirements, i.e. the tasks in https://github.com/coala/coala-bears/issues/1650

jayvdb commented 5 years ago

https://github.com/coala/coala/pull/5645 is an example of how to tests which cover ImportError code