| Conditions | 5 | 
| Total Lines | 52 | 
| Lines | 0 | 
| Ratio | 0 % | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import os.path  | 
            ||
| 107 | @classmethod  | 
            ||
| 108 | def load(cls, language, docstyle):  | 
            ||
| 109 | """  | 
            ||
| 110 | Returns a `DocstyleDefinition` defined for the given language and  | 
            ||
| 111 | docstyle from the coala docstyle definition files.  | 
            ||
| 112 | |||
| 113 | The marker settings are loaded from the according coalang-files. Each  | 
            ||
| 114 | setting inside them are considered a marker setting.  | 
            ||
| 115 | |||
| 116 | :param language: The programming language. For example  | 
            ||
| 117 | `"CPP"` for C++ or `"PYTHON3"` for Python 3.  | 
            ||
| 118 | The given string is automatically lowered,  | 
            ||
| 119 | so passing i.e. "CPP" or "cpp" makes no  | 
            ||
| 120 | difference.  | 
            ||
| 121 | :param docstyle: The documentation style/tool used. For  | 
            ||
| 122 | example `"default"` or `"doxygen"`.  | 
            ||
| 123 | The given string is automatically lowered,  | 
            ||
| 124 | so passing i.e. "default" or "DEFAULT" makes  | 
            ||
| 125 | no difference.  | 
            ||
| 126 | :raises FileNotFoundError: Raised when the given docstyle was not  | 
            ||
| 127 | found. This is a compatability exception  | 
            ||
| 128 | from `coalib.misc.Compatability` module.  | 
            ||
| 129 | :raises KeyError: Raised when the given language is not  | 
            ||
| 130 | defined for given docstyle.  | 
            ||
| 131 | :return: The `DocstyleDefinition` for giving language  | 
            ||
| 132 | and docstyle.  | 
            ||
| 133 | """  | 
            ||
| 134 | |||
| 135 | docstyle = docstyle.lower()  | 
            ||
| 136 | |||
| 137 | language_config_parser = ConfParser(remove_empty_iter_elements=False)  | 
            ||
| 138 | try:  | 
            ||
| 139 | docstyle_settings = language_config_parser.parse(  | 
            ||
| 140 | os.path.dirname(__file__) + "/" + docstyle + ".coalang")  | 
            ||
| 141 | except FileNotFoundError as ex:  | 
            ||
| 142 |             raise type(ex)("Docstyle definition " + repr(docstyle) + " not " | 
            ||
| 143 | "found.")  | 
            ||
| 144 | |||
| 145 | language = language.lower()  | 
            ||
| 146 | |||
| 147 | try:  | 
            ||
| 148 | docstyle_settings = docstyle_settings[language]  | 
            ||
| 149 | except KeyError:  | 
            ||
| 150 |             raise KeyError("Language {} is not defined for docstyle {}." | 
            ||
| 151 | .format(repr(language), repr(docstyle)))  | 
            ||
| 152 | |||
| 153 | marker_sets = (tuple(value)  | 
            ||
| 154 | for key, value in  | 
            ||
| 155 |                            filter(lambda kv: not kv[0].startswith("comment"), | 
            ||
| 156 | docstyle_settings.contents.items()))  | 
            ||
| 157 | |||
| 158 | return cls(language, docstyle, marker_sets)  | 
            ||
| 159 |