Skip to content

Commit bebcdce

Browse files
author
Vitaly
authored
632 remake coderunners (hexlet-codebattle#723)
1 parent 0b49f73 commit bebcdce

File tree

17 files changed

+324
-210
lines changed

17 files changed

+324
-210
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- uses: actions/[email protected]
2525
with:
2626
otp-version: 22.x
27-
elixir-version: 1.10.x
27+
elixir-version: 1.10.2
2828

2929
- uses: actions/cache@v1
3030
with:

services/app/.credo.exs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
configs: [
1111
%{
1212
#
13-
# Run any exec using `mix credo -C <name>`. If no exec name is given
13+
# Run any config using `mix credo -C <name>`. If no config name is given
1414
# "default" is used.
1515
#
1616
name: "default",
@@ -21,7 +21,16 @@
2121
# You can give explicit globs or simply directories.
2222
# In the latter case `**/*.{ex,exs}` will be used.
2323
#
24-
included: ["lib/", "src/", "test/", "web/", "apps/"],
24+
included: [
25+
"lib/",
26+
"src/",
27+
"test/",
28+
"web/",
29+
"apps/*/lib/",
30+
"apps/*/src/",
31+
"apps/*/test/",
32+
"apps/*/web/"
33+
],
2534
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
2635
},
2736
#
@@ -39,6 +48,10 @@
3948
#
4049
strict: false,
4150
#
51+
# To modify the timeout for parsing files, change this value:
52+
#
53+
parse_timeout: 5000,
54+
#
4255
# If you want to use uncolored output by default, you can change `color`
4356
# to `false` below:
4457
#
@@ -75,7 +88,7 @@
7588
# set this value to 0 (zero).
7689
#
7790
{Credo.Check.Design.TagTODO, [exit_status: 0]},
78-
{Credo.Check.Design.TagFIXME, [exit_status: 0]},
91+
{Credo.Check.Design.TagFIXME, []},
7992

8093
#
8194
## Readability Checks
@@ -97,8 +110,7 @@
97110
{Credo.Check.Readability.StringSigils, []},
98111
{Credo.Check.Readability.TrailingBlankLine, []},
99112
{Credo.Check.Readability.TrailingWhiteSpace, []},
100-
# TODO: enable by default in Credo 1.1
101-
{Credo.Check.Readability.UnnecessaryAliasExpansion, false},
113+
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
102114
{Credo.Check.Readability.VariableNames, []},
103115

104116
#
@@ -107,7 +119,7 @@
107119
{Credo.Check.Refactor.CondStatements, []},
108120
{Credo.Check.Refactor.CyclomaticComplexity, false},
109121
{Credo.Check.Refactor.FunctionArity, []},
110-
{Credo.Check.Refactor.LongQuoteBlocks, []},
122+
{Credo.Check.Refactor.LongQuoteBlocks, false},
111123
{Credo.Check.Refactor.MapInto, []},
112124
{Credo.Check.Refactor.MatchInCondition, []},
113125
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
@@ -124,6 +136,7 @@
124136
{Credo.Check.Warning.IExPry, []},
125137
{Credo.Check.Warning.IoInspect, []},
126138
{Credo.Check.Warning.LazyLogging, []},
139+
{Credo.Check.Warning.MixEnv, false},
127140
{Credo.Check.Warning.OperationOnSameValues, []},
128141
{Credo.Check.Warning.OperationWithConstantResult, []},
129142
{Credo.Check.Warning.RaiseInsideRescue, []},
@@ -135,22 +148,31 @@
135148
{Credo.Check.Warning.UnusedRegexOperation, []},
136149
{Credo.Check.Warning.UnusedStringOperation, []},
137150
{Credo.Check.Warning.UnusedTupleOperation, []},
151+
{Credo.Check.Warning.UnsafeExec, []},
152+
153+
#
154+
# Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`)
138155

139156
#
140157
# Controversial and experimental checks (opt-in, just replace `false` with `[]`)
141158
#
159+
{Credo.Check.Readability.StrictModuleLayout, false},
142160
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
143161
{Credo.Check.Consistency.UnusedVariableNames, false},
144162
{Credo.Check.Design.DuplicatedCode, false},
163+
{Credo.Check.Readability.AliasAs, false},
145164
{Credo.Check.Readability.MultiAlias, false},
146165
{Credo.Check.Readability.Specs, false},
147166
{Credo.Check.Readability.SinglePipe, false},
167+
{Credo.Check.Readability.WithCustomTaggedTuple, false},
148168
{Credo.Check.Refactor.ABCSize, false},
149169
{Credo.Check.Refactor.AppendSingleItem, false},
150170
{Credo.Check.Refactor.DoubleBooleanNegation, false},
151171
{Credo.Check.Refactor.ModuleDependencies, false},
172+
{Credo.Check.Refactor.NegatedIsNil, false},
152173
{Credo.Check.Refactor.PipeChainStart, false},
153174
{Credo.Check.Refactor.VariableRebinding, false},
175+
{Credo.Check.Warning.LeakyEnvironment, false},
154176
{Credo.Check.Warning.MapGetUnsafePass, false},
155177
{Credo.Check.Warning.UnsafeToAtom, false}
156178

services/app/assets/js/widgets/components/ExecutionOutput.jsx

Lines changed: 0 additions & 132 deletions
This file was deleted.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
import React, { useState } from 'react';
2+
import cn from 'classnames';
3+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4+
import _ from 'lodash';
5+
6+
7+
const AccordeonBox = ({ children }) => (
8+
<div className="accordion card-body border-top" id="accordionExample">
9+
{ children }
10+
</div>
11+
);
12+
13+
14+
const Menu = ({
15+
count = 0, children, statusColor, message,
16+
}) => {
17+
const [show, setShow] = useState(false);
18+
const classCollapse = cn('collapse', {
19+
show,
20+
});
21+
const handleClick = () => {
22+
setShow(!show);
23+
};
24+
const uniqIndex = _.uniqueId('heading');
25+
26+
return (
27+
<div className="card">
28+
{(statusColor === 'warning' || statusColor === 'danger')
29+
? (
30+
<div className="card-header" id={`heading${uniqIndex}`}>
31+
<button
32+
className={`btn btn-sm btn-outline-${statusColor}`}
33+
type="button"
34+
onClick={handleClick}
35+
data-toggle="collapse"
36+
aria-expanded="true"
37+
aria-controls={`collapse${uniqIndex}`}
38+
>
39+
{ show ? <FontAwesomeIcon icon="arrow-circle-up" /> : <FontAwesomeIcon icon="arrow-circle-down" /> }
40+
</button>
41+
<span className={`badge badge-${statusColor} ml-2`}>{count}</span>
42+
<span className={`badge badge-${statusColor} ml-2`}>{message}</span>
43+
</div>
44+
) : <span className={`badge badge-${statusColor}`}>{message}</span>}
45+
<div id={`collapse${uniqIndex}`} className={classCollapse} aria-labelledby={`heading${uniqIndex}`}>
46+
{children}
47+
</div>
48+
49+
</div>
50+
);
51+
};
52+
53+
54+
const SubMenu = ({
55+
children, statusColor, assert,
56+
}) => {
57+
const [show, setShow] = useState(false);
58+
const classCollapse = cn('collapse', {
59+
show,
60+
});
61+
const handleClick = () => {
62+
setShow(!show);
63+
};
64+
const uniqIndex = _.uniqueId('heading');
65+
66+
return (
67+
<div className="card ">
68+
69+
<div className="card-header" id={`heading${uniqIndex}`}>
70+
<button
71+
className={`btn btn-sm btn-outline-${statusColor}`}
72+
type="button"
73+
onClick={handleClick}
74+
data-toggle="collapse"
75+
aria-expanded="true"
76+
aria-controls={`collapse${uniqIndex}`}
77+
>
78+
{statusColor === 'success'
79+
? <FontAwesomeIcon className="mr-2" icon="check-circle" />
80+
: <FontAwesomeIcon className="mr-2" icon="exclamation-circle" />}
81+
{ show ? <FontAwesomeIcon icon="arrow-circle-up" /> : <FontAwesomeIcon icon="arrow-circle-down" /> }
82+
</button>
83+
<span className={`badge badge-${statusColor} ml-2`}>{assert.status}</span>
84+
{assert.execution_time ? (
85+
<span className={`badge badge-${statusColor} ml-2`}>
86+
{`executionTime: ${assert.execution_time} ms`}
87+
</span>
88+
) : null}
89+
<pre className={`text-${statusColor} mt-2`}>
90+
{assert.result !== undefined ? <b>{`Receive: ${assert.result} \n`}</b> : null}
91+
{assert.expected !== undefined ? <b>{`Expected: ${assert.expected} \n`}</b> : null}
92+
{assert.arguments !== undefined ? <b>{`Arguments: [${assert.arguments}]`}</b> : null}
93+
</pre>
94+
</div>
95+
96+
97+
<div id={`collapse${uniqIndex}`} className={classCollapse} aria-labelledby={`heading${uniqIndex}`}>
98+
{children}
99+
</div>
100+
101+
</div>
102+
);
103+
};
104+
105+
106+
const Item = ({ output, result }) => (
107+
<>
108+
{output ? (
109+
<div className="card-body ">
110+
<span>
111+
{result ? (
112+
<pre className="card-text d-none d-md-block mt-3">
113+
Result:
114+
{'\n'}
115+
{result}
116+
</pre>
117+
) : null}
118+
119+
<pre className="card-text d-none d-md-block mt-3">
120+
Output:
121+
{'\n'}
122+
{output}
123+
</pre>
124+
125+
</span>
126+
127+
</div>
128+
) : null}
129+
</>
130+
);
131+
132+
133+
AccordeonBox.Item = Item;
134+
AccordeonBox.Menu = Menu;
135+
AccordeonBox.SubMenu = SubMenu;
136+
export default AccordeonBox;

0 commit comments

Comments
 (0)