| Conditions | 8 |
| Total Lines | 65 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 | # vim: set expandtab sw=4 ts=4: |
||
| 74 | def load_build_matrix_env_vars(settings): |
||
| 75 | """ |
||
| 76 | Retrieve build matrix data from environment variables. |
||
| 77 | |||
| 78 | Load Travis CI build matrix environment variables |
||
| 79 | and assign their values to the corresponding setting value. |
||
| 80 | |||
| 81 | Properties : |
||
| 82 | - language |
||
| 83 | - language version (if applicable) |
||
| 84 | - compiler (if applicable) |
||
| 85 | - operating system |
||
| 86 | - environment parameters |
||
| 87 | |||
| 88 | Parameters: |
||
| 89 | - settings: Settings instance |
||
| 90 | """ |
||
| 91 | if "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true": |
||
| 92 | build_matrix = Collection() |
||
| 93 | |||
| 94 | if "TRAVIS_OS_NAME" in os.environ: |
||
| 95 | build_matrix.add_item("os", os.environ["TRAVIS_OS_NAME"]) |
||
| 96 | |||
| 97 | # set language and language version |
||
| 98 | language_env_vars = { |
||
| 99 | 'TRAVIS_DART_VERSION': 'dart', |
||
| 100 | 'TRAVIS_GO_VERSION': 'go', |
||
| 101 | 'TRAVIS_HAXE_VERSION': 'haxe', |
||
| 102 | 'TRAVIS_JDK_VERSION': 'java', |
||
| 103 | 'TRAVIS_JULIA_VERSION': 'julia', |
||
| 104 | 'TRAVIS_NODE_VERSION': 'javascript', |
||
| 105 | 'TRAVIS_OTP_RELEASE': 'erlang', |
||
| 106 | 'TRAVIS_PERL_VERSION': 'perl', |
||
| 107 | 'TRAVIS_PHP_VERSION': 'php', |
||
| 108 | 'TRAVIS_PYTHON_VERSION': 'python', |
||
| 109 | 'TRAVIS_R_VERSION': 'r', |
||
| 110 | 'TRAVIS_RUBY_VERSION': 'ruby', |
||
| 111 | 'TRAVIS_RUST_VERSION': 'rust', |
||
| 112 | 'TRAVIS_SCALA_VERSION': 'scala' |
||
| 113 | } |
||
| 114 | for env_var, language in language_env_vars.items(): |
||
| 115 | if env_var in os.environ: |
||
| 116 | build_matrix.add_item("language", language) |
||
| 117 | build_matrix.add_item( |
||
| 118 | "language_version", |
||
| 119 | str(os.environ[env_var]) |
||
| 120 | ) |
||
| 121 | |||
| 122 | # language specific build matrix parameters |
||
| 123 | parameters = { |
||
| 124 | 'TRAVIS_XCODE_SDK': 'xcode_sdk', # Objective-C |
||
| 125 | 'TRAVIS_XCODE_SCHEME': 'xcode_scheme', # Objective-C |
||
| 126 | 'TRAVIS_XCODE_PROJECT': 'xcode_project', # Objective-C |
||
| 127 | 'TRAVIS_XCODE_WORKSPACE': 'xcode_workspace', # Objective-C |
||
| 128 | 'CC': 'compiler', # C, C++ |
||
| 129 | 'ENV': 'parameters' |
||
| 130 | } |
||
| 131 | |||
| 132 | for parameter, name in parameters.items(): |
||
| 133 | if parameter in os.environ: |
||
| 134 | build_matrix.add_item(name, str(os.environ[parameter])) |
||
| 135 | |||
| 136 | settings.add_setting( |
||
| 137 | "build_matrix", |
||
| 138 | build_matrix.get_items_with_summary() |
||
| 139 | ) |
||
| 171 |