Class: Gergich::Capture::AndroidlintCapture
- Inherits:
-
BaseCapture
- Object
- BaseCapture
- Gergich::Capture::AndroidlintCapture
- Defined in:
- lib/gergich/capture/androidlint_capture.rb
Constant Summary collapse
- SEVERITY_MAP =
{ "Warning" => "warn", "Error" => "error", "Fatal" => "error" }.freeze
Instance Method Summary collapse
Methods inherited from BaseCapture
inherited, normalize_captor_class_name
Instance Method Details
#run(output) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gergich/capture/androidlint_capture.rb', line 13 def run(output) # rubocop:disable Metrics/LineLength # # Example: # /path/to/some.xml:27: Warning: Consider adding android:drawableStart="@drawable/a_media" to better support right-to-left layouts [RtlHardcoded] # android:drawableLeft="@drawable/ic_cv_media"/> # ~~~~~~~~~~~~~~~~~~~~ # # /path/to/AndroidManifest.xml: Warning: The project references RTL attributes, but does not explicitly enable or disable RTL support with android:supportsRtl in the manifest [RtlEnabled] # # /path/to/library/0.0.2: Error: No .class files were found in project "0.0.2", so none of the classfile based checks could be run. Does the project need to be built first? [LintError] # # /path/to/values.xml:5: Warning: For language "fr" (French) the following quantities are not relevant: few, zero [UnusedQuantity] # <plurals name="number"> # ^ # # rubocop:enable Metrics/LineLength pattern = / ^([^:\n]+):(\d+)?:?\s(\w+):\s(.*?)\n ([^\n]+\n [\s~\^]+\n)? /mx output.scan(pattern).map { |file, line, severity, error, context| context = "\n\n" + context if context { path: file, message: "[androidlint] #{error}#{context}".strip, position: (line || 0).to_i, severity: SEVERITY_MAP[severity] } }.compact end |