mumukit 2.36.0 → 2.40.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe34db4bf2fe3ea13c66a83ad0783b868bf12ff315073ee44d3802b74888722f
4
- data.tar.gz: 1943fa82dc1cfb03c956a9222e5dc7244278d0064bbdd627153273f41129fd3b
3
+ metadata.gz: 7df39585e9af97eafeaa33f6189749ed29458e5a55ab37cf3339ae4200fc3f97
4
+ data.tar.gz: 0d272a7e75b9cd754314cdaafac2e3158b3b80374e88099be3633066d0098ef0
5
5
  SHA512:
6
- metadata.gz: a3022b139dccd0a786edc7c02fad38e1c31978f397683e80c2c1f91ae6276084a7d82229022a1be2dc0c85421e1bd0b57853f24433ffa28aefd5f05300ba1f6e
7
- data.tar.gz: 1790b05e1f0361b501e89bba0c3fdd9cdd07971d41905cb24f1e503bb60f0a18625e4a196bd240251703dca3454db524a6fa43cf19bdb6b0eeffbb38f0f57604
6
+ metadata.gz: 7d7868073a960f5c0476bb8dd09aa84bb3d3aa1427ea1fef0700c4d664778cb40c60a18f6db212fc641e784839913e17ba23863788c393535b186764e2f44cdb
7
+ data.tar.gz: ca71c3f73c932143b403e4758e110f1e2f209f15cca3ada46365f95bc4974bef8042939e558ac5e11ef6e280b239dbd5abc48aa836fd8206b6098904b3473141
@@ -1,15 +1,17 @@
1
1
  module Mumukit
2
2
  class ErrorPattern
3
- def initialize(regexp)
3
+ def initialize(regexp, status: :failed, replace: '')
4
4
  @regexp = regexp
5
+ @status = status
6
+ @replacement = replace
5
7
  end
6
8
 
7
- def matches?(result)
8
- @regexp.matches? result
9
+ def matches?(result, status)
10
+ @status.like?(status) && @regexp.matches?(result)
9
11
  end
10
12
 
11
13
  def sanitize(result)
12
- result.gsub(@regexp, '').strip
14
+ result.gsub(@regexp, @replacement).strip
13
15
  end
14
16
 
15
17
  def transform(result, status)
@@ -1,11 +1,17 @@
1
1
  class Mumukit::Explainer
2
+ include Mumukit::WithContentType
3
+
2
4
  def explain(content, test_results)
5
+ content_type.enumerate(explanations(content, test_results))
6
+ end
7
+
8
+ private
9
+
10
+ def explanations(content, test_results)
3
11
  explain_methods
4
12
  .map { |selector, key| eval_explain(selector, key, content, test_results) }
5
13
  .compact
6
14
  .map { |explain| I18n.t(explain[:key], explain[:binding]) }
7
- .map { |it| "* #{it}" }
8
- .join("\n")
9
15
  end
10
16
 
11
17
  def eval_explain(selector, key, content, test_results)
@@ -64,7 +64,7 @@ module Mumukit::Metatest
64
64
 
65
65
  # Implementors should override this method if they want access to
66
66
  # the error details and produce more complex test results
67
- def build_error_output(builder, input, _example, error)
67
+ def build_error_output(builder, _example, input, error)
68
68
  builder.result = render_error_output input, error.message
69
69
  end
70
70
 
@@ -2,12 +2,12 @@ require 'mulang'
2
2
 
3
3
  module Mumukit
4
4
  class Templates::MulangExpectationsHook < Mumukit::Templates::ExpectationsHook
5
- LOGIC_SMELLS = %w(UsesCut UsesFail UsesUnificationOperator HasRedundantReduction)
6
- FUNCTIONAL_SMELLS = %w(HasRedundantParameter HasRedundantGuards)
7
- OBJECT_ORIENTED_SMELLS = %w(DoesNullTest ReturnsNull)
8
- IMPERATIVE_SMELLS = %w(HasRedundantLocalVariableReturn HasAssignmentReturn)
9
- EXPRESSIVENESS_SMELLS = %w(HasTooShortIdentifiers HasWrongCaseIdentifiers HasMisspelledIdentifiers)
10
- GENERIC_SMELLS = %w(IsLongCode HasCodeDuplication HasRedundantLambda HasRedundantIf DoesTypeTest HasRedundantBooleanComparison HasEmptyIfBranches)
5
+ LOGIC_SMELLS = Mulang::Expectation::LOGIC_SMELLS
6
+ FUNCTIONAL_SMELLS = Mulang::Expectation::FUNCTIONAL_SMELLS
7
+ OBJECT_ORIENTED_SMELLS = Mulang::Expectation::OBJECT_ORIENTED_SMELLS
8
+ IMPERATIVE_SMELLS = Mulang::Expectation::IMPERATIVE_SMELLS
9
+ EXPRESSIVENESS_SMELLS = Mulang::Expectation::EXPRESSIVENESS_SMELLS
10
+ GENERIC_SMELLS = Mulang::Expectation::GENERIC_SMELLS
11
11
 
12
12
  required :language, 'You have to provide a Mulang-compatible language in order to use this hook'
13
13
 
@@ -16,14 +16,19 @@ module Mumukit
16
16
  end
17
17
 
18
18
  def compile_mulang_analysis(request, expectations)
19
- mulang_code(request).analysis(
19
+ mulang_code(request).analysis({
20
20
  expectations: expectations[:ast],
21
21
  customExpectations: expectations[:custom],
22
22
  smellsSet: {
23
23
  tag: 'AllSmells',
24
24
  exclude: (expectations[:exceptions] + default_smell_exceptions)
25
25
  },
26
- domainLanguage: domain_language)
26
+ domainLanguage: domain_language
27
+ }.merge({
28
+ originalLanguage: original_language,
29
+ autocorrectionRules: autocorrection_rules.try { |it| positive_and_negative it }.presence,
30
+ normalizationOptions: normalization_options(request).presence
31
+ }.compact))
27
32
  end
28
33
 
29
34
  def run_mulang_analysis(analysis)
@@ -32,7 +37,6 @@ module Mumukit
32
37
  raise Mumukit::CompilationError, "Can not handle mulang results for analysis #{analysis}"
33
38
  end
34
39
 
35
-
36
40
  def domain_language
37
41
  {
38
42
  caseStyle: "CamelCase",
@@ -41,6 +45,17 @@ module Mumukit
41
45
  }
42
46
  end
43
47
 
48
+ def normalization_options(request)
49
+ request.dig(:settings, :normalization_options) || {}
50
+ end
51
+
52
+ def autocorrection_rules
53
+ {}
54
+ end
55
+
56
+ def original_language
57
+ end
58
+
44
59
  def default_smell_exceptions
45
60
  []
46
61
  end
@@ -76,5 +91,11 @@ module Mumukit
76
91
  include Mumukit::Templates::WithCodeSmells
77
92
  end
78
93
  end
94
+
95
+ private
96
+
97
+ def positive_and_negative(rules)
98
+ rules.flat_map { |k, v| [[k, v], ["Not:#{k}", "Not:#{v}"]] }.to_h
99
+ end
79
100
  end
80
101
  end
@@ -1,8 +1,8 @@
1
1
  module Mumukit::Templates
2
2
  module WithErrorPatterns
3
3
  def post_process_file(_file, result, status)
4
- error_patterns.each { |it| return it.transform(result, status) if it.matches? result } if status.failed?
5
- super
4
+ pattern = error_patterns.find { |it| it.matches? result, status }
5
+ pattern ? pattern.transform(result, status) : super
6
6
  end
7
7
 
8
8
  def error_patterns
@@ -7,7 +7,7 @@ module Mumukit::Templates::WithStructuredResults
7
7
  post_process_unstructured_result(file, result, status)
8
8
  end
9
9
  rescue JSON::ParserError
10
- [result, :errored]
10
+ post_process_unstructured_result(file, result, :errored)
11
11
  end
12
12
 
13
13
  def post_process_unstructured_result(_file, result, status)
@@ -1,3 +1,3 @@
1
1
  module Mumukit
2
- VERSION = '2.36.0'
2
+ VERSION = '2.40.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.36.0
4
+ version: 2.40.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-29 00:00:00.000000000 Z
11
+ date: 2021-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -212,28 +212,34 @@ dependencies:
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: '5.1'
215
+ version: '6.0'
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: 6.0.4
216
219
  type: :runtime
217
220
  prerelease: false
218
221
  version_requirements: !ruby/object:Gem::Requirement
219
222
  requirements:
220
223
  - - "~>"
221
224
  - !ruby/object:Gem::Version
222
- version: '5.1'
225
+ version: '6.0'
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: 6.0.4
223
229
  - !ruby/object:Gem::Dependency
224
230
  name: mumukit-inspection
225
231
  requirement: !ruby/object:Gem::Requirement
226
232
  requirements:
227
233
  - - "~>"
228
234
  - !ruby/object:Gem::Version
229
- version: '5.0'
235
+ version: '6.0'
230
236
  type: :runtime
231
237
  prerelease: false
232
238
  version_requirements: !ruby/object:Gem::Requirement
233
239
  requirements:
234
240
  - - "~>"
235
241
  - !ruby/object:Gem::Version
236
- version: '5.0'
242
+ version: '6.0'
237
243
  - !ruby/object:Gem::Dependency
238
244
  name: mumukit-core
239
245
  requirement: !ruby/object:Gem::Requirement
@@ -266,22 +272,16 @@ dependencies:
266
272
  name: mumukit-content-type
267
273
  requirement: !ruby/object:Gem::Requirement
268
274
  requirements:
269
- - - ">="
270
- - !ruby/object:Gem::Version
271
- version: '0.2'
272
- - - "<"
275
+ - - "~>"
273
276
  - !ruby/object:Gem::Version
274
- version: '2'
277
+ version: '1.10'
275
278
  type: :runtime
276
279
  prerelease: false
277
280
  version_requirements: !ruby/object:Gem::Requirement
278
281
  requirements:
279
- - - ">="
280
- - !ruby/object:Gem::Version
281
- version: '0.2'
282
- - - "<"
282
+ - - "~>"
283
283
  - !ruby/object:Gem::Version
284
- version: '2'
284
+ version: '1.10'
285
285
  description: Helpers for building a Mumuki Test Server
286
286
  email:
287
287
  - flbulgarelli@yahoo.com.ar
@@ -375,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
375
375
  - !ruby/object:Gem::Version
376
376
  version: '0'
377
377
  requirements: []
378
- rubygems_version: 3.0.8
378
+ rubygems_version: 3.0.3
379
379
  signing_key:
380
380
  specification_version: 4
381
381
  summary: Mumuki Test Server Development Kit