| Conditions | 1 |
| Total Lines | 55 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 | import contextlib |
||
| 15 | def openapi_schema(request): |
||
| 16 | schema = SchemaGenerator( |
||
| 17 | { |
||
| 18 | "openapi": "3.0.0", |
||
| 19 | "info": {"title": "Graphinate API", "version": "1.0"}, |
||
| 20 | "paths": { |
||
| 21 | "/graphql": { |
||
| 22 | "get": { |
||
| 23 | "responses": { |
||
| 24 | 200: { |
||
| 25 | "description": "GraphQL" |
||
| 26 | } |
||
| 27 | } |
||
| 28 | } |
||
| 29 | }, |
||
| 30 | "/graphiql": { |
||
| 31 | "get": { |
||
| 32 | "responses": { |
||
| 33 | 200: { |
||
| 34 | "description": "GraphiQL UI." |
||
| 35 | } |
||
| 36 | } |
||
| 37 | } |
||
| 38 | }, |
||
| 39 | "/metrics": { |
||
| 40 | "get": { |
||
| 41 | "responses": { |
||
| 42 | 200: { |
||
| 43 | "description": "Prometheus metrics." |
||
| 44 | } |
||
| 45 | } |
||
| 46 | } |
||
| 47 | }, |
||
| 48 | "/viewer": { |
||
| 49 | "get": { |
||
| 50 | "responses": { |
||
| 51 | 200: { |
||
| 52 | "description": "3D Force-Directed Graph Viewer" |
||
| 53 | } |
||
| 54 | } |
||
| 55 | } |
||
| 56 | }, |
||
| 57 | "/voyager": { |
||
| 58 | "get": { |
||
| 59 | "responses": { |
||
| 60 | 200: { |
||
| 61 | "description": "Voyager GraphQL Schema Viewer" |
||
| 62 | } |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } |
||
| 66 | } |
||
| 67 | } |
||
| 68 | ) |
||
| 69 | return schema.OpenAPIResponse(request=request) |
||
| 70 | |||
| 109 |