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